AddAcount.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. <template>
  2. <view class="detail-view">
  3. <u-form label-width="150" :model="add_form" ref="uForm">
  4. <view class="form-model-view">
  5. <u-form-item label='所属店铺' prop="shopName">
  6. <view class="clearfix form-val" @click="goPage('/pagesT/shop/selShop')">
  7. <view class="float_right" @click.stop="add_form.shopId = ''">
  8. <u-icon :name="!add_form.shopId ? 'arrow-right' : 'close-circle-fill'" size="28"
  9. color="#999999">
  10. </u-icon>
  11. </view>
  12. <text class="float_right ellipsis">{{ add_form.shopId ? add_form.shopName : '请选择' }}</text>
  13. </view>
  14. </u-form-item>
  15. <u-form-item label="账户名称">
  16. <view class="form-value">
  17. <input v-model="add_form.name" placeholder="请输入账户名称"/>
  18. </view>
  19. </u-form-item>
  20. <u-form-item label="账户号">
  21. <view class="form-value">
  22. <input v-model="add_form.accountNumber" placeholder="请输入账户号"/>
  23. </view>
  24. </u-form-item>
  25. <u-form-item label="期初余额">
  26. <view class="form-value">
  27. <input v-model="add_form.money" :disabled="!!account_id" placeholder="请输入期初余额"/>
  28. </view>
  29. </u-form-item>
  30. <u-form-item label="开户行名称" v-if="add_form.type === 3">
  31. <view class="form-value">
  32. <input v-model="add_form.bankName" placeholder="请输入开户行名称"/>
  33. </view>
  34. </u-form-item>
  35. <u-form-item label="账户类型" prop="settlementMethod">
  36. <view class="float_right" @click="openMethods(index)">
  37. <text>{{add_form.settlementMethod|| '请选择' }}</text>
  38. <u-icon name="arrow-right" size="24" color="#6c6c6c"></u-icon>
  39. </view>
  40. </u-form-item>
  41. <u-form-item label="备注">
  42. <view class="form-value">
  43. <input v-model="add_form.remark" />
  44. </view>
  45. </u-form-item>
  46. </view>
  47. </u-form>
  48. <u-select @confirm="methodsConfirm" v-model="methods_show" :list="pay_type_list"></u-select>
  49. <view class="detail-bottom">
  50. <view class="handel-btn" @click="submit">提交订单</view>
  51. </view>
  52. </view>
  53. </template>
  54. <script>
  55. export default {
  56. data() {
  57. return {
  58. rules: {
  59. shopName: [{
  60. required: true,
  61. message: '请选择所属店铺',
  62. trigger: ['change', 'blur']
  63. }],
  64. settlementMethod:[
  65. {
  66. required: true,
  67. message: '请选择账户类型',
  68. trigger: ['change', 'blur']
  69. }
  70. ]
  71. },
  72. add_form: {
  73. isDefault: 5,
  74. remark:'',
  75. settlementMethod: '',
  76. accountNumber: '',
  77. money: '',
  78. name: '',
  79. enableStatus:'',
  80. operatorName: '',
  81. receivable: '',
  82. type:'',
  83. shopId: "",
  84. shopName: "",
  85. bankName:'',
  86. receiptRequisitionAccountDate: [{
  87. collectionAmount: '',
  88. preferentialAmount: '',
  89. actualAmount: '',
  90. settlementMethod: '',
  91. remark: '',
  92. accountName: "",
  93. accountId: "",
  94. }]
  95. },
  96. methods_show: false,
  97. account_index: 0,
  98. pay_type_list: [{
  99. label: "普通账户",
  100. value: 4
  101. },
  102. {
  103. label: "支付宝账户",
  104. value: 1
  105. },
  106. {
  107. label: "微信账户",
  108. value: 2
  109. },
  110. {
  111. label: "银行账户",
  112. value: 3
  113. },
  114. ],
  115. customerData: '',
  116. account_id: '',
  117. shopData: {},
  118. AccountData: {},
  119. index: ''
  120. };
  121. },
  122. computed: {
  123. userInfo() {
  124. return this.$store.state.userInfo;
  125. }
  126. },
  127. watch: {
  128. customerData(val) {
  129. if (val) {
  130. this.add_form.custormerId = val.id;
  131. this.add_form.custormerName = val.name;
  132. this.add_form.receivable = val.money;
  133. }
  134. },
  135. // 店铺
  136. shopData(val) {
  137. if (val) {
  138. this.add_form.shopName = val.name;
  139. this.add_form.shopId = val.id;
  140. }
  141. },
  142. AccountData(val) {
  143. if (val) {
  144. console.log(val);
  145. this.add_form.receiptRequisitionAccountDate[this.index].accountId = val.id
  146. this.add_form.receiptRequisitionAccountDate[this.index].accountName = val.name
  147. }
  148. }
  149. },
  150. onLoad(options) {
  151. if (options.id) {
  152. this.account_id = options.id;
  153. uni.setNavigationBarTitle({
  154. title: '编辑账户'
  155. });
  156. this.getAccountInfo();
  157. } else {
  158. this.add_form.operatorId = this.userInfo.userCenterId;
  159. this.add_form.operatorName = this.userInfo.name;
  160. }
  161. },
  162. methods: {
  163. // 详情
  164. getAccountInfo() {
  165. this.$u.api.getAccountInfo(this.account_id).then(({
  166. data
  167. }) => {
  168. this.add_form = {
  169. accountNumber: data.accountNumber,
  170. beginMoney:data.beginMoney,
  171. enableStatus: data.enableStatus,
  172. money:data.money,
  173. name:data.name,
  174. shopId:data.shopId,
  175. shopName:data.shopName,
  176. type:data.type,
  177. remark:data.remark
  178. };
  179. });
  180. },
  181. openMethods(index) {
  182. console.log(index)
  183. this.methods_show = true;
  184. this.account_index = index;
  185. },
  186. methodsConfirm(arr) {
  187. console.log(arr)
  188. this.add_form.settlementMethod = arr[0].label;
  189. this.add_form.type=arr[0].value;
  190. },
  191. // 添加
  192. submit() {
  193. const params = {
  194. money:this.add_form.money,
  195. bankName:this.add_form.bankName,
  196. accountNumber: this.add_form.accountNumber,
  197. beginMoney:this.add_form.beginMoney,
  198. enableStatus: this.add_form.enableStatus,
  199. name:this.add_form.name,
  200. shopId:this.add_form.shopId,
  201. shopName:this.add_form.shopName,
  202. type:this.add_form.type,
  203. remark:this.add_form.remark
  204. };
  205. if (this.account_id) {
  206. this.$u.api.editAccount(this.account_id, params).then(res => {
  207. this.$u.toast('修改成功');
  208. setTimeout(() => {
  209. uni.navigateBack();
  210. }, 1500);
  211. });
  212. } else {
  213. this.$u.api.addAccount(params).then(res => {
  214. this.$u.toast('新增成功');
  215. setTimeout(() => {
  216. uni.navigateBack();
  217. }, 1500);
  218. });
  219. }
  220. },
  221. settlementAccount(index) {
  222. if (!this.add_form.shopId) {
  223. this.$u.toast('必须先选择商铺');
  224. return
  225. }
  226. this.goPage('/pagesT/account/selAccount')
  227. this.index = index
  228. },
  229. delsettlementAccount() {
  230. this.add_form.receiptRequisitionAccountDate[this.index].accountId = "";
  231. this.add_form.receiptRequisitionAccountDate[this.index].accountName = "";
  232. }
  233. },
  234. // 必须要在onReady生命周期,因为onLoad生命周期组件可能尚未创建完毕
  235. onReady() {
  236. this.$refs.uForm.setRules(this.rules);
  237. }
  238. };
  239. </script>
  240. <style lang="scss" scoped>
  241. .detail-ul {
  242. .detail-li {
  243. padding-left: 60rpx;
  244. position: relative;
  245. border-bottom: 1px solid #eeeeee;
  246. &:last-child {
  247. border-bottom: 0 none;
  248. }
  249. .del-icon {
  250. position: absolute;
  251. top: 50%;
  252. left: 0;
  253. transform: translateY(-50%);
  254. }
  255. .title {
  256. line-height: 80rpx;
  257. }
  258. .money-ul {
  259. border-top: 1px solid #eeeeee;
  260. padding: 20rpx 0;
  261. display: flex;
  262. .money-li {
  263. flex: 3;
  264. border-right: 1px solid #eeeeee;
  265. input {
  266. height: 80rpx;
  267. line-height: 80rpx;
  268. text-align: center;
  269. }
  270. &:last-child {
  271. border-right: 0 none;
  272. }
  273. }
  274. }
  275. .bottom {
  276. border-top: 1px solid #eeeeee;
  277. input {
  278. height: 80rpx;
  279. line-height: 80rpx;
  280. }
  281. }
  282. }
  283. }
  284. </style>