weirenchun 2 tahun lalu
induk
melakukan
1943fea6e1
1 mengubah file dengan 66 tambahan dan 14 penghapusan
  1. 66 14
      src/views/project/componens/info6.vue

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

@@ -6,9 +6,9 @@
     @edit="change"
     @save="save"
   >
-    <el-form>
-      <div class="ml-10 text-left">
-        <span class="title full-width">年份:</span>
+    <el-form class="mt-20" :disabled="disabled">
+      <div style="width: 1300px; text-align: left" class="mt-20 ml-10">
+        <span class="title">年份:</span>
         <el-select v-model="selectYear" @change="changeYear">
           <el-option
             v-for="item in years"
@@ -43,7 +43,7 @@
             <th>{{ allPlanInvestment }}</th>
           </tr>
           <tr>
-            <th style="width: 100px">累计投资</th>
+            <th>累计投资</th>
             <th v-for="item in month">
               <el-input
                 class="th-input"
@@ -111,7 +111,12 @@ export default {
   },
   data() {
     return {
-      updateItem: {},
+      allPlanInvestment: 0,
+      allTotalInvestment: 0,
+      allPlanNtInvestment: 0,
+      allTotalNtInvestment: 0,
+      updateItem: [],
+      data: [],
       month: [
         { month: '1-2' },
         { month: '3' },
@@ -123,8 +128,7 @@ export default {
         { month: '9' },
         { month: '10' },
         { month: '11' },
-        { month: '12' },
-        { month: '合计' }
+        { month: '12' }
       ],
       years: [],
       years2: [],
@@ -134,6 +138,10 @@ export default {
   },
   methods: {
     changeYear(res) {
+      this.allPlanInvestment = 0
+      this.allTotalInvestment = 0
+      this.allPlanNtInvestment = 0
+      this.allTotalNtInvestment = 0
       this.getList()
     },
     getList() {
@@ -144,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) {
@@ -161,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
@@ -182,14 +200,48 @@ 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)
       })
+    },
+    change(res) {
+      this.disabled = res
+    },
+    save() {
+      this.$api.project
+        .batchSubmitAnnualInvestment(this.updateItem)
+        .then(res => {
+          if (res.code === 200) {
+            this.$message.success(res.msg)
+          } else {
+            this.$message.error(res.msg)
+          }
+        })
     }
   }
 }