Bläddra i källkod

feat: 预收/付管理

liujt 1 dag sedan
förälder
incheckning
068ab97804

+ 18 - 0
src/api/financialManage/prepayment/index.js

@@ -53,3 +53,21 @@ export async function withdrawPrepayment(data) {
   }
   return Promise.reject(new Error(res.data.message));
 }
+
+// 完结
+export async function completeInfo(data) {
+  const res = await request.post('/eom/finprepay/complete?id=' + data.id);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+// 收款明细提交
+export async function saveDetailDetail(data) {
+  const res = await request.post('/eom/finprepay/saveDetail', data);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 23 - 8
src/views/financialManage/advanceReceipt/components/addDialog.vue

@@ -218,8 +218,11 @@
         <el-button @click="updateVisible(false)">关闭</el-button>
       </template>
       <template v-else>
-        <el-button type="primary" :loading="loading" @click="save">
-          确定
+        <el-button type="primary" :loading="loading" @click="save(0)">
+          保存
+        </el-button>
+        <el-button type="primary" :loading="loading" @click="save(1)">
+          提交
         </el-button>
         <el-button @click="updateVisible(false)">取消</el-button>
       </template>
@@ -258,7 +261,8 @@
   import {
     addAdvanceReceipt,
     updateAdvanceReceipt,
-    getAdvanceReceiptInfo
+    getAdvanceReceiptInfo,
+    submit
   } from '@/api/financialManage/advanceReceipt';
   import { getTreeByPid } from '@/api/classifyManage';
   import parentList from '@/views/saleManage/contact/components/parentList.vue';
@@ -279,7 +283,7 @@
     data() {
       return {
         activeComp: 'main',
-
+        businessId: '',
         tabOptions: [
           { key: 'main', name: '预收款项' },
           { key: 'bpm', name: '流程详情' }
@@ -419,7 +423,7 @@
         this.isDetail = type === 'detail';
         if ((this.isUpdate || this.isDetail) && row) {
           this.form = await getAdvanceReceiptInfo(row.id);
-
+          this.businessId = row.id;
           this.$nextTick(() => {
             this.$refs.inventoryTableDetailsRef &&
               this.$refs.inventoryTableDetailsRef.putTableValue(
@@ -518,7 +522,7 @@
         };
       },
 
-      save() {
+      save(type) {
         this.$refs.form.validate((valid) => {
           if (!valid) return;
           this.loading = true;
@@ -527,10 +531,12 @@
             ? updateAdvanceReceipt
             : addAdvanceReceipt;
           saveOrUpdate(this.form)
-            .then(() => {
+            .then((res) => {
               this.loading = false;
               this.$message.success(this.isUpdate ? '修改成功' : '新增成功');
-              this.updateVisible(false);
+              if(type === 1) {
+                this.sub(res);
+              }
               this.$emit('done');
             })
             .catch(() => {
@@ -539,6 +545,15 @@
         });
       },
 
+      async sub(res) {
+        const data = await getAdvanceReceiptInfo(
+          this.businessId || res
+        );
+        submit(data.id).then(() => {
+          this.$message.success('提交成功');
+        })
+      },
+
       updateVisible(value) {
         this.visible = value;
         if (!value) {

+ 48 - 42
src/views/financialManage/prepayment/components/payDialog.vue

@@ -13,7 +13,7 @@
       <!-- 付款信息 -->
       <headerTitle title="付款信息" size="16px"></headerTitle>
       <div style="margin: 10px 0; font-size: 14px; color: #606266;">
-        <span>预付金额:{{ row.amount || 0 }} 元</span>
+        <span>预付金额:{{ row.prepayTotalPrice || 0 }} 元</span>
         <span style="margin-left: 20px;">已付金额:{{ paidAmount }} 元</span>
         <span style="margin-left: 20px;">未付金额:{{ unpaidAmount }} 元</span>
       </div>
@@ -38,14 +38,14 @@
         :toolkit="[]"
       >
         <!-- 付款时间 -->
-        <template v-slot:payTime="{ row: r, $index }">
+        <template v-slot:paidDate="{ row: r, $index }">
           <el-form-item
-            :prop="`tableData.${$index}.payTime`"
+            :prop="`tableData.${$index}.paidDate`"
             :rules="{ required: true, message: '请选择付款时间', trigger: 'change' }"
             class="table-form-item"
           >
             <el-date-picker
-              v-model="r.payTime"
+              v-model="r.paidDate"
               type="date"
               placeholder="年/月/日"
               value-format="yyyy-MM-dd"
@@ -55,14 +55,14 @@
           </el-form-item>
         </template>
         <!-- 已付金额 -->
-        <template v-slot:paidAmount="{ row: r, $index }">
+        <template v-slot:paidTotalPrice="{ row: r, $index }">
           <el-form-item
-            :prop="`tableData.${$index}.paidAmount`"
+            :prop="`tableData.${$index}.paidTotalPrice`"
             :rules="{ required: true, message: '请输入已付金额', trigger: 'blur' }"
             class="table-form-item"
           >
             <el-input
-              v-model="r.paidAmount"
+              v-model="r.paidTotalPrice"
               placeholder="请输入"
               size="small"
               @input="calcAmount"
@@ -70,27 +70,23 @@
           </el-form-item>
         </template>
         <!-- 支付类型 -->
-        <template v-slot:payType="{ row: r, $index }">
+        <template v-slot:paymentType="{ row: r, $index }">
           <el-form-item
-            :prop="`tableData.${$index}.payType`"
+            :prop="`tableData.${$index}.paymentType`"
             :rules="{ required: true, message: '请选择支付类型', trigger: 'change' }"
             class="table-form-item"
           >
-            <el-select
-              v-model="r.payType"
+            <DictSelection
+              v-model="r.paymentType"
+              dictName="支付类型"
               placeholder="请选择"
-              size="small"
-              style="width: 100%"
-            >
-              <el-option label="现金" value="现金"></el-option>
-              <el-option label="银票" value="银票"></el-option>
-              <el-option label="商票" value="商票"></el-option>
-            </el-select>
+              class="payment-select"
+            />
           </el-form-item>
         </template>
         <!-- 附件 -->
-        <template v-slot:attachment="{ row: r }">
-          <fileMain v-model="r.attachment" :limit="1"></fileMain>
+        <template v-slot:files="{ row: r }">
+          <fileMain v-model="r.files" :limit="1"></fileMain>
         </template>
         <!-- 备注 -->
         <template v-slot:remark="{ row: r }">
@@ -126,6 +122,10 @@
 <script>
   import headerTitle from '@/components/header-title';
   import fileMain from '@/components/addDoc/index.vue';
+  import {
+      getPrepaymentInfo,
+      saveDetailDetail
+    } from '@/api/financialManage/prepayment';
 
   export default {
     components: {
@@ -149,32 +149,32 @@
             fixed: 'left'
           },
           {
-            prop: 'payTime',
+            prop: 'paidDate',
             label: '付款时间',
             align: 'center',
             minWidth: 160,
-            slot: 'payTime'
+            slot: 'paidDate'
           },
           {
-            prop: 'paidAmount',
+            prop: 'paidTotalPrice',
             label: '已付金额',
             align: 'center',
             minWidth: 140,
-            slot: 'paidAmount'
+            slot: 'paidTotalPrice'
           },
           {
-            prop: 'payType',
+            prop: 'paymentType',
             label: '支付类型',
             align: 'center',
             minWidth: 140,
-            slot: 'payType'
+            slot: 'paymentType'
           },
           {
-            prop: 'attachment',
+            prop: 'files',
             label: '附件',
             align: 'center',
             minWidth: 120,
-            slot: 'attachment'
+            slot: 'files'
           },
           {
             prop: 'remark',
@@ -203,24 +203,24 @@
         }, 0).toFixed(2);
       },
       unpaidAmount() {
-        const total = parseFloat(this.row.amount) || 0;
+        const total = parseFloat(this.row.prepayTotalPrice) || 0;
         const paid = parseFloat(this.paidAmount) || 0;
         return (total - paid).toFixed(2);
       }
     },
     methods: {
-      open(row) {
+      async open(row) {
         this.visible = true;
-        this.row = row || {};
-        this.form.tableData = [];
+        this.info = await getPrepaymentInfo(row.id);
+        this.form.tableData = this.info.detailList || [];
       },
 
       addRow() {
         this.form.tableData.push({
-          payTime: '',
-          paidAmount: '',
-          payType: '',
-          attachment: [],
+          paidDate: '',
+          paidTotalPrice: '',
+          paymentType: '',
+          files: [],
           remark: ''
         });
       },
@@ -246,28 +246,34 @@
         }
         for (let i = 0; i < this.form.tableData.length; i++) {
           const item = this.form.tableData[i];
-          if (!item.payTime) {
+          if (!item.paidDate) {
             this.$message.warning(`第${i + 1}行付款时间不能为空`);
             return;
           }
-          if (!item.paidAmount) {
+          if (!item.paidTotalPrice) {
             this.$message.warning(`第${i + 1}行已付金额不能为空`);
             return;
           }
-          if (!item.payType) {
+          if (!item.paymentType) {
             this.$message.warning(`第${i + 1}行支付类型不能为空`);
             return;
           }
         }
 
         this.loading = true;
-        // TODO: 调用付款保存接口
-        setTimeout(() => {
+        const params = this.form.tableData.map(item => {
+          return {
+            ...item,
+            prepayId: this.row.id,
+            prepayCode: this.row.code,
+          }
+        })
+        saveDetailDetail(params).then(res => {
           this.loading = false;
           this.$message.success('付款成功');
           this.updateVisible(false);
           this.$emit('done');
-        }, 500);
+        });
       },
 
       updateVisible(value) {

+ 5 - 1
src/views/financialManage/prepayment/index.vue

@@ -407,11 +407,15 @@
       },
 
       // 完结
-      handleComplete() {
+      handleComplete(row) {
         this.$confirm('确定要完结该预付款吗?', '提示', { type: 'warning' }).then(() => {
+          completeInfo({
+            id: row.id
+          }).then(() => {
           // TODO: 调用完结接口
           this.$message.success('完结成功');
           this.reload();
+          });
         });
       }
     }