Переглянути джерело

2023-08-28 计算到位资金合计

wrc 2 роки тому
батько
коміт
553623df67
2 змінених файлів з 77 додано та 14 видалено
  1. 9 0
      src/api/project/index.js
  2. 68 14
      src/views/project/componens/info6.vue

+ 9 - 0
src/api/project/index.js

@@ -380,6 +380,15 @@ export default {
       'json'
     )
   },
+  // 新增或修改年度投资
+  batchSubmitAnnualInvestment(params) {
+    return fetch(
+      '/blade-project-manage-v2/project-dispatch/v2/batch-submit-annual-investment',
+      params,
+      'post',
+      'json'
+    )
+  },
   // 项目前期文件列表
   preliminaryFiles(params) {
     return fetch(

+ 68 - 14
src/views/project/componens/info6.vue

@@ -26,6 +26,7 @@
             <th v-for="item in month">
               {{ item.month != '合计' ? item.month + '月' : '合计' }}
             </th>
+            <th>合计</th>
           </tr>
         </thead>
         <tbody>
@@ -35,10 +36,11 @@
               <el-input
                 class="th-input"
                 v-model="item.planInvestment"
-                @input="saveOrUpdate(item)"
+                @input="AddUpdateItem(item)"
               >
               </el-input>
             </th>
+            <th>{{ allPlanInvestment }}</th>
           </tr>
           <tr>
             <th>累计投资</th>
@@ -46,10 +48,11 @@
               <el-input
                 class="th-input"
                 v-model="item.totalInvestment"
-                @input="saveOrUpdate(item)"
+                @input="AddUpdateItem(item)"
               >
               </el-input>
             </th>
+            <th>{{ allTotalInvestment }}</th>
           </tr>
           <tr>
             <th>计划纳统投资</th>
@@ -57,10 +60,11 @@
               <el-input
                 class="th-input"
                 v-model="item.planNtInvestment"
-                @input="saveOrUpdate(item)"
+                @input="AddUpdateItem(item)"
               >
               </el-input>
             </th>
+            <th>{{ allPlanNtInvestment }}</th>
           </tr>
           <tr>
             <th>累计纳统投资</th>
@@ -68,10 +72,11 @@
               <el-input
                 class="th-input"
                 v-model="item.totalNtInvestment"
-                @input="saveOrUpdate(item)"
+                @input="AddUpdateItem(item)"
               >
               </el-input>
             </th>
+            <th>{{ allTotalNtInvestment }}</th>
           </tr>
         </tbody>
       </table>
@@ -106,7 +111,12 @@ export default {
   },
   data() {
     return {
-      updateItem: {},
+      allPlanInvestment: 0,
+      allTotalInvestment: 0,
+      allPlanNtInvestment: 0,
+      allTotalNtInvestment: 0,
+      updateItem: [],
+      data: [],
       month: [
         { month: '1-2' },
         { month: '3' },
@@ -118,8 +128,7 @@ export default {
         { month: '9' },
         { month: '10' },
         { month: '11' },
-        { month: '12' },
-        { month: '合计' }
+        { month: '12' }
       ],
       years: [],
       years2: [],
@@ -129,6 +138,10 @@ export default {
   },
   methods: {
     changeYear(res) {
+      this.allPlanInvestment = 0
+      this.allTotalInvestment = 0
+      this.allPlanNtInvestment = 0
+      this.allTotalNtInvestment = 0
       this.getList()
     },
     getList() {
@@ -139,6 +152,7 @@ export default {
         })
         .then(res => {
           if (res.code === 200) {
+            this.data = res.data
             this.month.map(monthItem => {
               const sub = res.data.find(ele => ele.month === monthItem.month)
               if (sub) {
@@ -156,6 +170,15 @@ export default {
                 monthItem.updateTime = sub.updateTime
                 monthItem.updateUser = sub.updateUser
                 monthItem.year = sub.year
+
+                this.allTotalNtInvestment =
+                  this.allTotalNtInvestment + (sub.totalNtInvestment - 0)
+                this.allPlanInvestment =
+                  this.allPlanInvestment + (sub.planInvestment - 0)
+                this.allTotalInvestment =
+                  this.allTotalInvestment + (sub.totalInvestment - 0)
+                this.allPlanNtInvestment =
+                  this.allPlanNtInvestment + (sub.planNtInvestment - 0)
               } else {
                 monthItem.planInvestment = 0
                 monthItem.planNtInvestment = 0
@@ -177,14 +200,45 @@ export default {
       }
       this.years.reverse()
     },
-    saveOrUpdate(item) {
-      this.$api.project.submitAnnualInvestment(item).then(res => {
-        if (res.code === 200) {
-          this.$message.success(res.msg)
-        } else {
-          this.$message.error(res.msg)
-        }
+    AddUpdateItem(item) {
+      const sub = this.updateItem.find(ele => ele.month === item.month)
+      if (sub) {
+        console.log('这个已经在更新列表中!')
+      } else {
+        this.updateItem.push(item)
+      }
+
+      const index = this.data.findIndex(ele => ele.month === item.month)
+      if (index != -1) {
+        this.data.splice(this.data.indexOf(index), 1)
+      }
+      this.data.push(item)
+      //重新计算合计
+      this.allPlanInvestment = 0
+      this.allTotalInvestment = 0
+      this.allPlanNtInvestment = 0
+      this.allTotalNtInvestment = 0
+      this.data.forEach(ele => {
+        this.allTotalNtInvestment =
+          this.allTotalNtInvestment + (ele.totalNtInvestment - 0)
+        this.allPlanInvestment =
+          this.allPlanInvestment + (ele.planInvestment - 0)
+        this.allTotalInvestment =
+          this.allTotalInvestment + (ele.totalInvestment - 0)
+        this.allPlanNtInvestment =
+          this.allPlanNtInvestment + (ele.planNtInvestment - 0)
       })
+    },
+    saveOrUpdate() {
+      this.$api.project
+        .batchSubmitAnnualInvestment(this.updateItem)
+        .then(res => {
+          if (res.code === 200) {
+            this.$message.success(res.msg)
+          } else {
+            this.$message.error(res.msg)
+          }
+        })
     }
   }
 }