scorpio 2 rokov pred
rodič
commit
caaed81186
1 zmenil súbory, kde vykonal 47 pridanie a 11 odobranie
  1. 47 11
      src/views/home/component/params/params3.vue

+ 47 - 11
src/views/home/component/params/params3.vue

@@ -25,7 +25,7 @@
                     form.month_plan_complete_amount[index] ? form.month_plan_complete_amount[index].year : ''
                   }}年度计划投资(万元)</span>
                 <div class='disable-input' @change='change(item)'>
-                  {{ form.month_plan_complete_amount[index] ? form.month_plan_complete_amount[index].sum : '2' }}
+                  {{ form.month_plan_complete_amount[index] ? form.month_plan_complete_amount[index].sum : '' }}
                 </div>
               </div>
               <div style='width: 20px'></div>
@@ -34,7 +34,7 @@
                     form.month_plan_complete_amount[index] ? form.month_plan_complete_amount[index].year : ''
                   }}年度累计投资(万元)</span>
                 <div class='disable-input' @change='change(item)'>
-                  {{ form.month_complete_amount[index] ? form.month_complete_amount[index].sum : '2' }}
+                  {{ form.month_complete_amount[index] ? form.month_complete_amount[index].sum : '' }}
                 </div>
                 <div class='btnSub pointer' @click='showMonth(form.month_complete_amount[index].year ,1,index)'>月填报
                 </div>
@@ -60,12 +60,14 @@
             <div class='flex flex-center  flex-justify-between  full-width'>
               <div class='flex-child-average full-width  flex flex-center'>
                 <span style='width: 400px'>{{ form.month_plan_investment[index].year }}年度计划纳统投资(万元)</span>
-                <el-input v-model='form.month_plan_investment[index].sum' @change='change(item)'></el-input>
+                <div class='disable-input' @change='change(item)'>
+                  {{ form.month_plan_investment[index] ? form.month_plan_investment[index].sum : '' }}
+                </div>
               </div>
               <div style='width: 20px'></div>
               <div class='flex-child-average full-width  flex flex-center'>
                 <span style='width: 440px'>{{ form.month_plan_investment[index].year }}年度累计纳统投资(万元)</span>
-                <div class='disable-input' @change='change(item)'>{{ form.month_investment_amount.sum }}</div>
+                <div class='disable-input' @change='change(item)'>{{ form.month_investment_amount[index].sum }}</div>
                 <div class='btnSub pointer' @click='showMonth(form.month_plan_investment[index].year,2,index)'>月填报
                 </div>
               </div>
@@ -166,14 +168,27 @@ export default {
     addYear (type) {
       this.disabled = false
       if (type === 1) {
-        this.form.month_complete_amount.splice(0, 0, this.nextYear(Number.parseInt(this.form.month_complete_amount[0].year)))
-        this.form.month_plan_complete_amount.splice(0, 0, this.nextYear(Number.parseInt(this.form.month_plan_complete_amount[0].year)))
+        if (this.form.month_complete_amount.length === 0) {
+          const nowYear = new Date().getFullYear() - 1
+          this.form.month_complete_amount.push(this.nextYear(nowYear))
+          this.form.month_plan_complete_amount.push(this.nextYear(nowYear))
+        } else {
+          this.form.month_complete_amount.splice(0, 0, this.nextYear(Number.parseInt(this.form.month_complete_amount[0].year)))
+          this.form.month_plan_complete_amount.splice(0, 0, this.nextYear(Number.parseInt(this.form.month_plan_complete_amount[0].year)))
+        }
         this.completeCount = this.completeCount + 1
       } else if (type === 2) {
-        this.form.month_investment_amount.splice(0, 0, this.nextYear(Number.parseInt(this.form.month_investment_amount[0].year)))
-        this.form.month_plan_investment.splice(0, 0, this.nextYear(Number.parseInt(this.form.month_plan_investment[0].year)))
+        if (this.form.month_investment_amount.length === 0) {
+          const nowYear = new Date().getFullYear() - 1
+          this.form.month_investment_amount.push(this.nextYear(nowYear))
+          this.form.month_plan_investment.push(this.nextYear(nowYear))
+        } else {
+          this.form.month_investment_amount.splice(0, 0, this.nextYear(Number.parseInt(this.form.month_investment_amount[0].year)))
+          this.form.month_plan_investment.splice(0, 0, this.nextYear(Number.parseInt(this.form.month_plan_investment[0].year)))
+        }
         this.investmentCount = this.investmentCount + 1
       }
+      console.log(this.form)
     },
     nextYear (year) {
       const tmp2 = {}
@@ -187,6 +202,18 @@ export default {
       return tmp2
     },
     init (res) {
+      if (!Object.keys(res).includes('month_plan_investment')) {
+        res.month_plan_investment = []
+      }
+      if (!Object.keys(res).includes('month_investment_amount')) {
+        res.month_investment_amount = []
+      }
+      if (!Object.keys(res).includes('month_complete_amount')) {
+        res.month_complete_amount = []
+      }
+      if (!Object.keys(res).includes('month_plan_complete_amount')) {
+        res.month_plan_complete_amount = []
+      }
       this.investmentCount = Math.max(res.month_plan_investment.length, res.month_investment_amount.length)
       // 求出差集
       const dd = res.month_plan_investment.filter((sub) => {
@@ -243,6 +270,18 @@ export default {
     update (show = Boolean) {
       this.$nextTick(() => {
         this.form.projectId = this.form.id
+        if (this.form.month_plan_complete_amount.length > 0) {
+          this.form.month_plan_complete_amount[this.current.index].sum = this.getSum(this.form.month_plan_complete_amount[this.current.index].monthlyData)
+        }
+        if (this.form.month_complete_amount.length > 0) {
+          this.form.month_complete_amount[this.current.index].sum = this.getSum(this.form.month_complete_amount[this.current.index].monthlyData)
+        }
+        if (this.form.month_plan_investment.length > 0) {
+          this.form.month_plan_investment[this.current.index].sum = this.getSum(this.form.month_plan_investment[this.current.index].monthlyData)
+        }
+        if (this.form.month_investment_amount.length > 0) {
+          this.form.month_investment_amount[this.current.index].sum = this.getSum(this.form.month_investment_amount[this.current.index].monthlyData)
+        }
         delete this.form._id
         this.$api.project.proUpdate(this.detail).then(res => {
           if (res.code === 200) {
@@ -295,7 +334,6 @@ export default {
      */
     changeMonth (res, type, index) {
       setTimeout(() => {
-        console.log(res)
         if (this.current.editType === 1) {
           if (type === 1) {
             this.form.month_plan_complete_amount[this.current.index].monthlyData[index] = res
@@ -303,14 +341,12 @@ export default {
             this.form.month_complete_amount[this.current.index].monthlyData[index] = res
           }
         } else if (this.current.editType === 2) {
-          console.log(this.current)
           if (type === 1) {
             this.form.month_plan_investment[this.current.index].monthlyData[index] = res
           } else {
             this.form.month_investment_amount[this.current.index].monthlyData[index] = res
           }
         }
-        console.log(this.form.month_plan_complete_amount)
       }, 1000)
     },
     getSum (list) {