index.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <template>
  2. <view>
  3. <z-navbar title="确认收款" back></z-navbar>
  4. <w-picker mode="date" startYear="2000" endYear="2100" v-model="info.operateTime" :current="true" fields="day"
  5. @confirm="onConfirmWantDate($event)" @cancel="onCancel" :disabled-after="false" ref="operateTime">
  6. </w-picker>
  7. <z-card class="mt-30 ptb-10">
  8. <z-form :model="info" :rules="rules" ref="info">
  9. <z-form-item label="收款时间" prop="operateTime" showline>
  10. <date-select v-model="info.operateTime" placeholder="选择收款时间"></date-select>
  11. </z-form-item>
  12. </z-form-item>
  13. <z-form-item height="100rpx" label="支付方式" prop="payment" showline>
  14. <z-text :value="paymentText" arrow placeholder="请选择" @click="showPayWay=true"></z-text>
  15. <z-select-popup class="payway_area" :visible.sync="showPayWay" doText="确定" @cancel="toPayment">
  16. <view v-for="(item,index) in paywayList" :key="index">
  17. <view class="flex-n fac fjb plr-40">
  18. <view class="payway_area_text">{{item.dicName}}</view>
  19. <z-input class="payway_area_input" v-model="item.price" type="number" placeholder="¥">
  20. </z-input>
  21. </view>
  22. <view class="line" v-if="index<paywayList.length-1"></view>
  23. </view>
  24. </z-select-popup>
  25. </z-form-item>
  26. <z-form-item label="备注信息" prop="remark" labelPos="top">
  27. <textarea class="textarea" v-model="info.remark" placeholder="请输入备注信息" maxlength="512"
  28. auto-height></textarea>
  29. </z-form-item>
  30. </z-form>
  31. </z-card>
  32. <view class="common_btn" @click="submit">
  33. 确认收款
  34. </view>
  35. <u-toast ref="uToast"></u-toast>
  36. </view>
  37. </template>
  38. <script>
  39. import dateSelect from '../supplement/date-select.vue';
  40. const app = getApp({
  41. allowDefault: true
  42. });
  43. export default {
  44. components: {
  45. dateSelect
  46. },
  47. data() {
  48. var validateConfirmMoney = (rule, value, callback) => {
  49. if (this.info.confirmMoney <= 0) {
  50. return {
  51. state: false,
  52. message: '确认收款金额必须大于0'
  53. };
  54. } else
  55. return true;
  56. };
  57. return {
  58. id: '',
  59. type: 0,
  60. info: {
  61. payment: [],
  62. operateTime: '',
  63. remark: ''
  64. },
  65. rules: {
  66. operateTime: [{
  67. required: true,
  68. message: ''
  69. }],
  70. },
  71. switchAlert: false,
  72. showPayWay: false,
  73. paywayList: [],
  74. paymentText: ''
  75. };
  76. },
  77. onLoad(option) {
  78. this.id = option.id;
  79. this.type = option.type;
  80. this.getPayMent();
  81. //获取当前时间的信息
  82. var date = this.$Date.getDayDate().date;
  83. var nowTime = new Date();
  84. this.$set(this.info, 'operateTime', date + ' ' + nowTime.getHours() + ':' + nowTime.getMinutes());
  85. },
  86. methods: {
  87. getPayMent() {
  88. this.$axios.post('app/dic/paymentCode', {
  89. "parentId": "1001",
  90. "dicType": " paymentCode"
  91. }).then(res => {
  92. console.log(res.data);
  93. for (var i in res.data.list) {
  94. if (res.data.list[i].dicCode != '06') {
  95. this.paywayList.push(res.data.list[i]);
  96. }
  97. }
  98. }).catch(err => {})
  99. },
  100. toPayment() {
  101. var paymentText = '';
  102. for (var i in this.paywayList) {
  103. if (this.paywayList[i].price) {
  104. paymentText += this.paywayList[i].dicName + '、';
  105. }
  106. }
  107. this.paymentText = paymentText.substring(0, paymentText.length - 1);
  108. },
  109. submit() {
  110. this.$refs.info.validate(val => {
  111. console.log(val)
  112. if (val) {
  113. var info = this.info,
  114. confirmMoney = 0;
  115. for (var i in this.paywayList) {
  116. // if (this.paywayList[i].dicCode == '06') {
  117. // info.consumeMoney = this.paywayList[i].price || 0;
  118. // }
  119. if (this.paywayList[i].price)
  120. info.payment.push({
  121. "payMoney": this.paywayList[i].price,
  122. "paymentCode": this.paywayList[i].dicCode,
  123. "paymentName": this.paywayList[i].dicName,
  124. })
  125. confirmMoney += Number(this.paywayList[i].price || 0)
  126. }
  127. this.$set(this.info, 'confirmMoney', confirmMoney);
  128. this.info = info;
  129. if (this.type == 0) {
  130. this.submitData();
  131. } else {
  132. this.submitWedData();
  133. }
  134. } else {
  135. if (this.info.confirmMoney <= 0) {
  136. this.$refs.uToast.error('确认收款金额必须大于0');
  137. } else
  138. this.$refs.uToast.error('表单填写有误');
  139. }
  140. })
  141. },
  142. submitData() {
  143. this.$axios.post('app/orderFinanceConfirm/saveReceivable', {
  144. "confirmMoney": this.info.confirmMoney,
  145. "storeId": uni.getStorageSync('storeId'),
  146. "operateTime": this.info.operateTime, //操作时间
  147. "isSupplement": 0,
  148. "orderId": this.id,
  149. "payment": this.info.payment,
  150. "remark": this.info.remark
  151. }).then(res => {
  152. this.$refs.uToast.success('订单确认收款成功!');
  153. uni.navigateBack({
  154. delta: 1
  155. });
  156. }).catch(err => {
  157. this.$refs.uToast.error(err.msg);
  158. })
  159. },
  160. submitWedData() {
  161. this.$axios.post('app/weddingFinanceConfirm/saveWeddingReceivable', {
  162. "operateTime": this.info.operateTime, //操作时间
  163. "payment": this.info.payment,
  164. "isSupplement": 0,
  165. "weddingOrderId": this.id,
  166. "remark": this.info.remark
  167. }).then(res => {
  168. this.$refs.uToast.success('婚庆订单确认收款成功!');
  169. uni.navigateBack({
  170. delta: 1
  171. });
  172. }).catch(err => {
  173. this.$refs.uToast.error(err.msg);
  174. })
  175. },
  176. choosewantDate() {
  177. this.$refs.operateTime.show();
  178. },
  179. onConfirmWantDate(e) {
  180. this.$set(this.info, 'operateTime', e.value)
  181. },
  182. onCancel() {
  183. console.log(this.$refs.date.value, this.$refs.date.pickVal)
  184. },
  185. },
  186. }
  187. </script>
  188. <style scoped lang="scss">
  189. .textarea {
  190. font-size: 28rpx;
  191. min-height: 180rpx;
  192. padding-bottom: 20rpx;
  193. width: 100%;
  194. }
  195. .common_btn {
  196. margin: 0 auto;
  197. width: 690rpx;
  198. line-height: 88rpx;
  199. background: #2481EE;
  200. border-radius: 6rpx;
  201. margin-top: 50rpx;
  202. color: white;
  203. font-size: 32rpx;
  204. text-align: center;
  205. }
  206. </style>