collectionDialog.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. <collect-table-form
  15. ref="collectTableFormRef"
  16. :form.sync="form"
  17. :total-price="form.receivableTotalPrice"
  18. :dialog-type="dialogType"
  19. total-label="应收金额"
  20. ></collect-table-form>
  21. <div slot="footer">
  22. <el-button type="primary" @click="save(0)">保存</el-button>
  23. <el-button @click="cancel">返回</el-button>
  24. </div>
  25. </ele-modal>
  26. </template>
  27. <script>
  28. import infoTable from "./infoTable.vue";
  29. import collectTableForm from '@/BIZComponents/collectTableForm/index.vue';
  30. import {finReceivableSaveAPI, getFinReceivableInfoAPI, finReceivableUpdateAmountAPI} from "@/api/financialManage/receivableManage";
  31. export default {
  32. name: "collectionDialog",
  33. components: {
  34. infoTable,
  35. collectTableForm
  36. },
  37. props: {
  38. collectionDialogFlag: {
  39. type: Boolean,
  40. default: false
  41. },
  42. },
  43. computed: {},
  44. data() {
  45. return {
  46. row: {},
  47. dialogType: '',
  48. title: '',
  49. loading: false,
  50. info: {},
  51. form: {
  52. id: '',
  53. tableData: []
  54. },
  55. rules: {}
  56. }
  57. },
  58. created() {
  59. },
  60. methods: {
  61. //初始化
  62. async open(row, type) {
  63. this.row = row || {};
  64. this.dialogType = type || 'update';
  65. this.title = this.dialogType === 'view' ? '收款详情' : '收款';
  66. this.info = await getFinReceivableInfoAPI(row.id);
  67. // 直接替换整个 form,保证 tableData 等字段响应式更新
  68. this.form = {
  69. ...this.info,
  70. tableData: this.info.detailList || []
  71. };
  72. },
  73. //获取详情
  74. async getInfo(id) {
  75. this.form = await getFinReceivableInfoAPI(id)
  76. },
  77. save() {
  78. // 先校验公共组件内的表单
  79. this.$refs.collectTableFormRef.validate().then(() => {
  80. // 取整个表单数据
  81. const data = this.$refs.collectTableFormRef.getData();
  82. this.loading = true;
  83. const params = data.tableData.map((item) => {
  84. return {
  85. ...item,
  86. receivableId: this.row.id,
  87. receivableCode: this.row.code
  88. };
  89. });
  90. finReceivableSaveAPI(params)
  91. .then(() => {
  92. this.loading = false;
  93. this.$message.success('收款成功');
  94. this.cancel()
  95. this.done()
  96. })
  97. .catch(() => {
  98. this.loading = false;
  99. });
  100. }).catch(() => {});
  101. },
  102. updateVisible(value) {
  103. this.collectionDialogFlag = value;
  104. if (!value) {
  105. this.row = {};
  106. this.form.tableData = [];
  107. }
  108. },
  109. //
  110. async handleSave() {
  111. let data = await this.$refs.feeRelatedInfoTable.getTableValidate()
  112. console.log('data~~~', data)
  113. let detailList = data[0]
  114. let receivableTotalPrice = data[1]
  115. // await finReceivableUpdateAmountAPI(this.form.id, {
  116. // receivableTotalPrice: receivableTotalPrice
  117. // })
  118. await finReceivableSaveAPI(detailList)
  119. this.$message.success('操作成功')
  120. this.done()
  121. this.cancel()
  122. },
  123. //刷新主列表数据
  124. done() {
  125. this.$emit('reload')
  126. },
  127. //关闭弹窗
  128. cancel() {
  129. this.$emit('update:collectionDialogFlag', false)
  130. }
  131. }
  132. }
  133. </script>
  134. <style scoped lang="scss">
  135. </style>