From 4d6d23e986f1cc9fed61f3161c46b4f2be069fb7 Mon Sep 17 00:00:00 2001
From: yangfeng <wanwan926_4@163.com>
Date: 星期四, 23 十一月 2023 15:36:25 +0800
Subject: [PATCH] 新建收款计划增加收款期数

---
 src/views/other/payment/collectionPlan/AddCollectionPlan.vue |  175 ++++++++++++++++------------------------------------------
 1 files changed, 49 insertions(+), 126 deletions(-)

diff --git a/src/views/other/payment/collectionPlan/AddCollectionPlan.vue b/src/views/other/payment/collectionPlan/AddCollectionPlan.vue
index c3cd4b1..e1eea7a 100644
--- a/src/views/other/payment/collectionPlan/AddCollectionPlan.vue
+++ b/src/views/other/payment/collectionPlan/AddCollectionPlan.vue
@@ -51,6 +51,7 @@
             :data="tableData.tableInfomation"
             tooltip-effect="dark"
             style="width: 100%"
+            max-height="375"
             :header-cell-style="{ background: '#ECF4FF', color: '#666' }"
           >
             <el-table-column
@@ -73,7 +74,7 @@
                     style="width: 100%; margin-right: 5px"
                     @change="
                       (val) => {
-                        commonInputChange(val, item.prop, scope.row)
+                        commonInputChange(val, item.prop, scope)
                       }
                     "
                   ></el-input-number>
@@ -130,6 +131,9 @@
               <el-option label="1" :value="1"></el-option>
               <el-option label="2" :value="2"></el-option>
               <el-option label="3" :value="3"></el-option>
+              <el-option label="5" :value="5"></el-option>
+              <el-option label="8" :value="8"></el-option>
+              <el-option label="10" :value="10"></el-option>
             </el-select>
             <span> 鏈�, </span>
           </div>
@@ -198,7 +202,8 @@
       planAmount: 0, // 璁″垝閲戦
       firstDate: this.getCurrentDate(1),
       collectionType: 1,
-      tableInfomation: []
+      tableInfomation: [],
+      allPercent: 0
     }
   },
   created() {
@@ -243,6 +248,8 @@
           this.$message.error("鏀舵閲戦涓嶈兘涓�0")
         } else if (this.amount !== this.planAmount) {
           this.$message.error("鏀舵璁″垝鍜屾湭璁″垝閲戦涓嶄竴鑷达紝璇烽噸绠�")
+        } else if (this.allPercent > 100) {
+          this.$message.error("鏀舵姣斾緥(%)鎬诲拰澶т簬100锛岃閲嶆柊杈撳叆")
         } else {
           const params = this.saveParams()
           addCollectionPlan(params).then((res) => {
@@ -280,7 +287,7 @@
       this.$parent.getData()
     },
     setTableForm() {
-      this.setTableInfomation(this.firstDate)
+      this.setTableInfomation(this.allTerms, this.firstDate)
       this.tableData = {
         tableInfomation: this.tableInfomation,
         tableColumn: [
@@ -293,134 +300,44 @@
         ]
       }
     },
-    setTableInfomation(date) {
-      console.log(this.sourceId)
-      this.tableInfomation = [
-        {
-          amount: this.amount,
-          amountReceivable: this.amount * 0.3,
-          amountReceived: 0,
-          amountTotal: this.amount,
-          collectionDate: this.setDate(date, 0),
-          collectionType: this.editConfig.infomation.collectionType,
-          fileId: 0,
-          id: 0,
-          moneyType: "浜烘皯甯�",
-          percent: 30,
-          principalId: this.principalId,
-          remark: "",
-          sourceId: this.sourceId,
-          sourceType: this.sourceType,
-          status: 1,
-          term: 1
-        },
-        {
-          amount: this.amount,
-          amountReceivable: this.amount * 0.5,
-          amountReceived: 0,
-          amountTotal: this.amount,
-          collectionDate: this.setDate(date, 1),
-          collectionType: this.editConfig.infomation.collectionType,
-          fileId: 0,
-          id: 0,
-          moneyType: "浜烘皯甯�",
-          percent: 50,
-          principalId: this.principalId,
-          remark: "",
-          sourceId: this.sourceId,
-          sourceType: this.sourceType,
-          status: 1,
-          term: 2
-        },
-        {
-          amount: this.amount,
-          amountReceivable: this.amount * 0.2,
-          amountReceived: 0,
-          amountTotal: this.amount,
-          collectionDate: this.setDate(date, 2),
-          collectionType: this.editConfig.infomation.collectionType,
-          fileId: 0,
-          id: 0,
-          moneyType: "浜烘皯甯�",
-          percent: 20,
-          principalId: this.principalId,
-          remark: "",
-          sourceId: this.sourceId,
-          sourceType: this.sourceType,
-          status: 1,
-          term: 3
+    // 鏀舵璁″垝鍒楄〃鍐呭璁$畻
+    setTableInfomation(allTerms, date) {
+      let arr = []
+      for (let i = 0; i < allTerms; i++) {
+        let ratio = 1
+        if (allTerms == 3) {
+          ratio = i == 0 ? 30 : i == 1 ? 50 : 20
+        } else {
+          ratio = 100 / allTerms
         }
-      ]
+        let data = {
+          amount: this.amount,
+          amountReceivable: (this.amount * ratio) / 100,
+          amountReceived: 0,
+          amountTotal: this.amount,
+          collectionDate: this.setDate(date, i),
+          collectionType: this.editConfig.infomation.collectionType,
+          fileId: 0,
+          id: 0,
+          moneyType: "浜烘皯甯�",
+          percent: ratio,
+          principalId: this.principalId,
+          remark: "",
+          sourceId: this.sourceId,
+          sourceType: this.sourceType,
+          status: 1,
+          term: i + 1
+        }
+        arr.push(data)
+      }
+      this.tableInfomation = [...arr]
     },
     // 閲嶇畻
     recalculateClick() {
       console.log(this.allTerms)
       this.tableData.tableInfomation = []
-      if (this.allTerms === 1) {
-        console.log("aaa")
-        this.tableData.tableInfomation = [
-          {
-            amount: this.amount,
-            amountReceivable: this.amount,
-            amountReceived: 0,
-            amountTotal: this.amount,
-            collectionDate: this.setDate(this.firstDate, 0),
-            collectionType: this.editConfig.infomation.collectionType,
-            fileId: 0,
-            id: 0,
-            moneyType: "浜烘皯甯�",
-            percent: 100,
-            principalId: this.principalId,
-            remark: "",
-            sourceId: this.sourceId,
-            sourceType: this.sourceType,
-            status: 1,
-            term: 1
-          }
-        ]
-      } else if (this.allTerms === 2) {
-        this.tableData.tableInfomation = [
-          {
-            amount: this.amount,
-            amountReceivable: this.amount * 0.5,
-            amountReceived: 0,
-            amountTotal: this.amount,
-            collectionDate: this.setDate(this.firstDate, 0),
-            collectionType: this.editConfig.infomation.collectionType,
-            fileId: 0,
-            id: 0,
-            moneyType: "浜烘皯甯�",
-            percent: 50,
-            principalId: this.principalId,
-            remark: "",
-            sourceId: this.sourceId,
-            sourceType: this.sourceType,
-            status: 1,
-            term: 1
-          },
-          {
-            amount: this.amount,
-            amountReceivable: this.amount * 0.5,
-            amountReceived: 0,
-            amountTotal: this.amount,
-            collectionDate: this.setDate(this.firstDate, 1),
-            collectionType: this.editConfig.infomation.collectionType,
-            fileId: 0,
-            id: 0,
-            moneyType: "浜烘皯甯�",
-            percent: 50,
-            principalId: this.principalId,
-            remark: "",
-            sourceId: this.sourceId,
-            sourceType: this.sourceType,
-            status: 1,
-            term: 2
-          }
-        ]
-      } else if (this.allTerms === 3) {
-        this.setTableInfomation(this.firstDate)
-        this.tableData.tableInfomation = this.tableInfomation
-      }
+      this.setTableInfomation(this.allTerms, this.firstDate)
+      this.tableData.tableInfomation = this.tableInfomation
     },
     delClick(row) {
       console.log(row)
@@ -432,6 +349,11 @@
     commonInputChange(val, prop, row) {
       console.log(val, prop)
       console.log(row)
+      const array = this.tableData.tableInfomation
+      array.map((item) => {
+        this.allPercent += item.percent
+      })
+      console.log(this.allPercent)
     },
     // 鑾峰彇褰撳墠鏃ユ湡
     getCurrentDate(monthNumber) {
@@ -443,6 +365,7 @@
     },
     // 鏃ユ湡澶勭悊
     setDate(str, monthNumber) {
+      console.log(str)
       console.log(str.split("-"))
       let dateArr = str.split("-")
       // 鏈堜唤鍜�
@@ -458,7 +381,7 @@
     },
     principalClick(val) {
       this.principalId = val
-      this.setTableInfomation(this.firstDate)
+      this.setTableInfomation(this.allTerms, this.firstDate)
       this.tableData.tableInfomation = this.tableInfomation
     }
   }

--
Gitblit v1.8.0