collectionDialog.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <template>
  2. <ele-modal
  3. custom-class="ele-dialog-form long-dialog-form"
  4. :centered="true"
  5. :visible.sync="collectionDialogFlag"
  6. :title="title"
  7. :append-to-body="true"
  8. :close-on-click-modal="false"
  9. width="60%"
  10. :before-close="cancel"
  11. :maxable="true"
  12. :resizable="true"
  13. >
  14. <!-- <info-table ref="feeRelatedInfoTable" v-if="form.id" :form.sync="form"></info-table> -->
  15. <collect-table-form
  16. ref="collectTableFormRef"
  17. :form.sync="form"
  18. :total-price="form.planPaymentAmount"
  19. :dialog-type="dialogType"
  20. total-label="应收金额"
  21. ></collect-table-form>
  22. <div slot="footer">
  23. <el-button type="primary" @click="save(0)">保存</el-button>
  24. <el-button @click="cancel">返回</el-button>
  25. </div>
  26. </ele-modal>
  27. </template>
  28. <script>
  29. import infoTable from "@/views/financialManage/receivableManage/components/infoTable.vue";
  30. import {finReceivableSaveAPI, getFinReceivableInfoAPI, finReceivableUpdateAmountAPI} from "@/api/financialManage/receivableManage";
  31. import { receiptPaymentPlanById } from '@/api/financialManage/payAndCollectPlan';
  32. import collectTableForm from '@/BIZComponents/collectTableForm/index.vue';
  33. import { confirmReceiptAPI } from '@/api/financialManage/payAndCollectPlan';
  34. export default {
  35. name: "collectionDialog",
  36. components: {
  37. infoTable,
  38. collectTableForm
  39. },
  40. props: {
  41. collectionDialogFlag: {
  42. type: Boolean,
  43. default: false
  44. },
  45. },
  46. computed: {},
  47. data() {
  48. return {
  49. dialogType: '',
  50. title: '',
  51. form: {
  52. id: '',
  53. },
  54. rules: {}
  55. }
  56. },
  57. created() {
  58. },
  59. methods: {
  60. //初始化
  61. async init(row = {}, type) {
  62. this.title = '收款'
  63. this.dialogType = type
  64. this.currentRow = row
  65. await this.getInfo(row.orderId)
  66. },
  67. //获取详情
  68. async getInfo(id) {
  69. const data = await receiptPaymentPlanById(id)
  70. const detail = data.details.filter(item => item.detailNo === this.currentRow.detailNo)?.[0]
  71. if(detail) {
  72. this.form = {
  73. ...detail,
  74. tableData: detail?.confirmList?.map(item => {
  75. return {
  76. ...item,
  77. receivedDate: item.paymentDate,
  78. receivedTotalPrice: item.paymentTotalPrice,
  79. }
  80. }) || []
  81. }
  82. }
  83. },
  84. save() {
  85. // 先校验公共组件内的表单
  86. this.$refs.collectTableFormRef.validate().then(() => {
  87. // 取整个表单数据
  88. const data = this.$refs.collectTableFormRef.getData();
  89. this.loading = true;
  90. const params = data.tableData.map((item) => {
  91. return {
  92. ...item,
  93. paymentDate: item.receivedDate,
  94. paymentTotalPrice: item.receivedTotalPrice,
  95. receiptPaymentId: this.currentRow.id,
  96. receiptPaymentCode: this.currentRow.code
  97. };
  98. });
  99. confirmReceiptAPI(params)
  100. .then(() => {
  101. this.loading = false;
  102. this.$message.success('收款成功');
  103. this.cancel()
  104. this.done()
  105. })
  106. .catch(() => {
  107. this.loading = false;
  108. });
  109. }).catch(() => {});
  110. },
  111. //
  112. async handleSave() {
  113. let data = await this.$refs.feeRelatedInfoTable.getTableValidate()
  114. console.log('data~~~', data)
  115. let detailList = data[0]
  116. // let receivableTotalPrice = data[1]
  117. // await finReceivableUpdateAmountAPI(this.form.id, {
  118. // receivableTotalPrice: receivableTotalPrice
  119. // })
  120. await confirmReceiptAPI(detailList)
  121. this.$message.success('操作成功')
  122. this.done()
  123. this.cancel()
  124. },
  125. //刷新主列表数据
  126. done() {
  127. this.$emit('reload')
  128. },
  129. //关闭弹窗
  130. cancel() {
  131. this.$emit('update:collectionDialogFlag', false)
  132. }
  133. }
  134. }
  135. </script>
  136. <style scoped lang="scss">
  137. </style>