ReturnFromAdd.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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 required label="退款单位">
  6. <u-input @click="goPage('/pagesT/customer/selCustomer')" disabled class="dis-input" v-model="add_form.unitName" placeholder="请选择" />
  7. <u-icon name="arrow-right" size="24" color="#6c6c6c"></u-icon>
  8. </u-form-item>
  9. <u-form-item label="单据日期">
  10. <picker mode="date" @change="bindDateChange">
  11. <view style="width: 524rpx;text-align: right;display: inline-block;margin-right: 10rpx;">
  12. <text v-if="add_form.refundTime">{{ $u.timeFormat(add_form.refundTime, 'yyyy-mm-dd') }}</text>
  13. <text style="color:#B8C0C8;" v-else>请选择</text>
  14. </view>
  15. <u-icon name="arrow-right" size="24" color="#6c6c6c"></u-icon>
  16. </picker>
  17. </u-form-item>
  18. <u-form-item required label="所属店铺">
  19. <u-input @click="goPage('/pagesT/shop/selShop')" disabled class="dis-input" v-model="add_form.shopName" placeholder="请选择" />
  20. <u-icon name="arrow-right" size="24" color="#6c6c6c"></u-icon>
  21. </u-form-item>
  22. </view>
  23. <view class="form-model-view">
  24. <u-form-item label="退款单明细">
  25. <view class="form-value add-btn-go" @click="addAccount">
  26. <u-icon name="plus" size="24"></u-icon>
  27. <text>新增</text>
  28. </view>
  29. </u-form-item>
  30. <view class="detail-ul">
  31. <view class="detail-li" v-for="(item, index) in add_form.accountList" :key="index">
  32. <view class="del-icon" @click="delAccount(index)"><u-icon name="minus-circle-fill" size="40" color="#fa3534"></u-icon></view>
  33. <u-form-item label="结算账户">
  34. <view class="in-form-item">
  35. <u-input @click="settlementAccount(index)" disabled v-model="item.accountName" placeholder="请选择" />
  36. <view class="icon-arrow-right"><u-icon name="arrow-right" size="24" color="#6c6c6c"></u-icon></view>
  37. </view>
  38. </u-form-item>
  39. <u-form-item label="退款金额"><input placeholder-style="color:#B8C0C8" type="digit" v-model="item.money" placeholder="请输入退款金额" /></u-form-item>
  40. <view class="bottom clearfix"><input placeholder-style="color:#B8C0C8" type="text" v-model="item.remark" placeholder="说点什么吧" /></view>
  41. </view>
  42. </view>
  43. </view>
  44. </u-form>
  45. <view class="detail-bottom"><u-button class="handel-btn" @click="submit" :loading="sub_load" :ripple="true" type="primary">提交</u-button></view>
  46. </view>
  47. </template>
  48. <script>
  49. export default {
  50. data() {
  51. return {
  52. sub_load: false,
  53. add_form: {
  54. unitId: '',
  55. unitName: '',
  56. sourceNo: '',
  57. sourceNoMoney: '',
  58. currentAccountName: '',
  59. financeType: '销售退款',
  60. financeTypeId: 12,
  61. shopId: '',
  62. money: '',
  63. shopName: '',
  64. refundTime: '',
  65. createTime: '',
  66. accountList: [
  67. {
  68. accountId: '',
  69. accountNumber: '',
  70. accountName: '',
  71. money: '',
  72. discountMoney: '',
  73. finalMoney: '',
  74. payWay: '',
  75. remark: ''
  76. }
  77. ]
  78. },
  79. methods_show: false,
  80. account_index: 0,
  81. customerData: '',
  82. account_id: '',
  83. shopData: '',
  84. AccountData: '',
  85. tag: ''
  86. };
  87. },
  88. computed: {
  89. userInfo() {
  90. return this.$store.state.userInfo;
  91. }
  92. },
  93. watch: {
  94. customerData(val) {
  95. if (val) {
  96. console.log(val);
  97. this.add_form.unitId = val.id;
  98. this.add_form.unitName = val.name;
  99. this.add_form.money = val.money;
  100. this.add_form.type = val.type;
  101. }
  102. },
  103. // 店铺
  104. shopData(val) {
  105. if (val) {
  106. this.add_form.shopName = val.name;
  107. this.add_form.shopId = val.id;
  108. }
  109. },
  110. AccountData(val) {
  111. if (val) {
  112. this.add_form.accountList[this.account_index].accountId = val.id;
  113. this.add_form.accountList[this.account_index].accountName = val.name;
  114. this.add_form.accountList[this.account_index].accountNumber = val.accountNumber;
  115. }
  116. }
  117. },
  118. onLoad(options) {
  119. this.add_form.refundTime = parseInt(new Date().getTime() / 1000);
  120. },
  121. methods: {
  122. change(e) {
  123. this.refundTime = new Date().getTime();
  124. },
  125. addAccount() {
  126. this.add_form.receiptOffsetData.push({
  127. collectionAmount: '',
  128. preferentialAmount: '',
  129. actualAmount: '',
  130. settlementMethod: '',
  131. remark: ''
  132. });
  133. },
  134. delAccount(index) {
  135. if (this.add_form.accountList.length === 1) {
  136. this.$u.toast('至少保留一条');
  137. return;
  138. }
  139. this.add_form.accountList.splice(index, 1);
  140. },
  141. // 添加
  142. submit() {
  143. if (!this.add_form.unitName) {
  144. this.$u.toast('请选择退款单位');
  145. return;
  146. }
  147. if (!this.add_form.shopId) {
  148. this.$u.toast('请选择所属店铺');
  149. return;
  150. }
  151. let isSub = true;
  152. for (let i in this.add_form.accountList) {
  153. let item = this.add_form.accountList[i];
  154. if (!item.accountName) {
  155. isSub = false;
  156. this.$u.toast('请选择结算账户');
  157. break;
  158. }
  159. if (!item.money) {
  160. isSub = false;
  161. this.$u.toast('请输入退款金额');
  162. break;
  163. }
  164. }
  165. if (!isSub) {
  166. return;
  167. }
  168. this.sub_load = true;
  169. this.$u.api
  170. .addRefund({
  171. ...this.add_form,
  172. currentAccountName: this.userInfo.name
  173. })
  174. .then(res => {
  175. this.sub_load = false;
  176. this.$u.toast('新增成功');
  177. setTimeout(() => {
  178. uni.navigateBack();
  179. }, 1500);
  180. })
  181. .catch(err => {
  182. this.sub_load = false;
  183. });
  184. },
  185. settlementAccount(index) {
  186. if (!this.add_form.shopId) {
  187. this.$u.toast('请先选择商铺');
  188. return;
  189. }
  190. this.goPage('/pagesT/account/selAccount?shopId=' + this.add_form.shopId);
  191. this.account_index = index;
  192. },
  193. bindDateChange(e) {
  194. this.add_form.refundTime = this.$utils.timeByTimestamp(e.detail.value + ' 00:00:00');
  195. }
  196. }
  197. };
  198. </script>
  199. <style lang="scss" scoped>
  200. .detail-ul {
  201. .detail-li {
  202. padding-left: 60rpx;
  203. position: relative;
  204. border-bottom: 1px solid #eeeeee;
  205. &:last-child {
  206. border-bottom: 0 none;
  207. }
  208. .del-icon {
  209. position: absolute;
  210. top: 36%;
  211. left: 0;
  212. transform: translateY(-50%);
  213. }
  214. .title {
  215. line-height: 80rpx;
  216. }
  217. .money-ul {
  218. border-top: 1px solid #eeeeee;
  219. padding: 20rpx 0;
  220. display: flex;
  221. .money-li {
  222. flex: 3;
  223. border-right: 1px solid #eeeeee;
  224. input {
  225. height: 80rpx;
  226. line-height: 80rpx;
  227. text-align: center;
  228. }
  229. &:last-child {
  230. border-right: 0 none;
  231. }
  232. }
  233. }
  234. .bottom {
  235. // border-top: 1px solid #eeeeee;
  236. input {
  237. height: 80rpx;
  238. line-height: 80rpx;
  239. }
  240. }
  241. }
  242. }
  243. .in-form-item {
  244. position: relative;
  245. padding-right: 30rpx;
  246. .icon-arrow-right {
  247. position: absolute;
  248. right: 0;
  249. top: 50%;
  250. transform: translateY(-50%);
  251. }
  252. }
  253. </style>