scorpio 2 năm trước cách đây
mục cha
commit
9680ce2805

+ 14 - 0
src/api/params/index.js

@@ -35,6 +35,20 @@ export default {
       current: 1,
       ...params
     })
+  },
+
+  /**
+   * 搜索
+   * @param params
+   * @returns {Promise<unknown>}
+   */
+  paramsList (params) {
+    return fetch('/wutong-parse-file/excel-dict/v1/front-parent-list', {
+      clientId: 'project_web',
+      size: 999,
+      current: 1,
+      ...params
+    })
   }
 
 }

+ 143 - 18
src/views/home/component/form_dialog.vue

@@ -101,8 +101,56 @@
         <div class="flex flex-justify-start flex-center">
           <span class="bold grey ml-5 ">字段选择</span>
           <el-checkbox class='ml-20' @change='allChange'>全 选</el-checkbox>
-        </div>
+          <div class='flex flex-center' v-if='selectIndex === 2'>
+            <div class='bold ml-10 text-right' style='width: 80px'>筛选:</div>
+            <el-select
+                v-model="year"
+                clearable
+                placeholder="选择年份"
+                style="width: 200px"
+            >
+              <el-option
+                  v-for="item in years"
+                  :key="item + `年`"
+                  :label="item + `年`"
+                  :value="item"
+              />
+            </el-select>
+
+            <el-select
+                v-model="season"
+                clearable
+                class='ml-20 mr-20'
+                placeholder="选择季度"
+                style="width: 200px"
+            >
+              <el-option
+                  v-for="item in seasons"
+                  :key="item.value"
+                  :label="item.name"
+                  :value="item.value"
+              />
+            </el-select>
+
+            <el-select
+                v-if='season === "" '
+                v-model="month"
+                clearable
+                placeholder="选择月份"
+                style="width: 200px"
+            >
+              <el-option
+                  v-for="item in 12"
+                  :key="item + `月`"
+                  :label="item + `月`"
+                  :value="item"
+              />
+            </el-select>
 
+            <el-button icon='el-icon-search' class='ml-20' type='primary' @click='search'>搜 索</el-button>
+            <el-button icon='el-icon-delete' class='ml-20' type='primary' plain @click='resetKey'>清 空</el-button>
+          </div>
+        </div>
         <div class="flex flex-wrap" v-if='selectIndex !== -1' style="height: 300px;overflow-x: scroll">
           <div v-for="(item,index) in fieldType[selectIndex].params" :key='item.id'
                class="flex  padding pointer">
@@ -156,6 +204,13 @@ export default {
         }
       },
       immediate: true
+    },
+    season: {
+      handler (val) {
+        if (val.length > 0) {
+          this.month = ''
+        }
+      }
     }
   },
   data () {
@@ -182,11 +237,43 @@ export default {
       page: {
         current: 1,
         size: 10
-      }
+      },
+      years: [],
+      year: '',
+      seasons: [
+        {
+          name: '第一季度',
+          value: 1
+        },
+        {
+          name: '第二季度',
+          value: 2
+        },
+        {
+          name: '第三季度',
+          value: 3
+        },
+        {
+          name: '第四季度',
+          value: 4
+        }
+      ],
+      season: '',
+      month: ''
     }
   },
-
+  created () {
+    this.init()
+  },
   methods: {
+    init () {
+      const tmp = new Date().getFullYear()
+      this.year = tmp
+      for (let i = 0; i < tmp - 2018; i++) {
+        const res = Number.parseInt(tmp) - i
+        this.years.push(res)
+      }
+    },
     /**
      * 获取督查情况
      */
@@ -236,26 +323,47 @@ export default {
     switchTab (item, index) {
       this.fieldType[index].isSelect = !this.fieldType[index].isSelect
       this.selectIndex = index
+      if (index === 2) {
+        this.$api.params.paramsList({
+          type: this.fieldType[this.selectIndex].dictKey,
+          year: this.year,
+          season: this.season,
+          month: this.month
+        }).then(res => {
+          if (res.code === 200) {
+            this.parseList(res.data.records, index)
+          }
+        })
+        return
+      }
       this.$api.params.getListByKey({ type: this.fieldType[index].dictKey, export: 1 }).then(res => {
         if (res.code === 200) {
-          const tmps = res.data.records.map(e => {
-            e.checked = this.fieldType[index].params === undefined ? false : this.fieldType[index].params.findIndex(sub => sub.id === e.id) > -1
-            return e
-          }).filter(sub => sub.code !== 'name')
-          if (this.fieldType[index].params !== undefined) {
-            const d = tmps.filter(ele => {
-              return this.fieldType[index].params.findIndex(sub => sub.id === ele.id) === -1
-            })
-            for (let i = 0; i < d.length; i++) {
-              this.fieldType[index].params.push(d[i])
-            }
-          } else {
-            this.fieldType[index].params = tmps
-          }
-          this.fieldType[index].count = this.fieldType[index].params.filter(e => e.checked).length
+          this.parseList(res.data.records, index)
         }
       })
     },
+    /**
+     * 组装数据
+     * @param list
+     * @param index
+     */
+    parseList (list, index, reset = Boolean) {
+      const tmps = list.map(e => {
+        e.checked = reset ? false : this.fieldType[index].params === undefined ? false : this.fieldType[index].params.findIndex(sub => sub.id === e.id) > -1
+        return e
+      }).filter(sub => sub.code !== 'name')
+      if (this.fieldType[index].params !== undefined && reset === false) {
+        const d = tmps.filter(ele => {
+          return this.fieldType[index].params.findIndex(sub => sub.id === ele.id) === -1
+        })
+        for (let i = 0; i < d.length; i++) {
+          this.fieldType[index].params.push(d[i])
+        }
+      } else {
+        this.fieldType[index].params = tmps
+      }
+      this.fieldType[index].count = this.fieldType[index].params.filter(e => e.checked).length
+    },
     importExcel () {
       if (this.attaches && this.attaches.length === 0) {
         this.$message.error('请选择要上传的文件')
@@ -371,6 +479,23 @@ export default {
         this.$message.success(item.dictValue + '已勾选成功')
         this.fieldType[index].params.count = this.fieldType[index].params.filter(sub => sub.checked).length
       }
+    },
+    resetKey () {
+      this.year = ''
+      this.season = ''
+      this.month = ''
+    },
+    search () {
+      this.$api.params.paramsList({
+        type: this.fieldType[this.selectIndex].dictKey,
+        year: this.year,
+        season: this.season,
+        month: this.month
+      }).then(res => {
+        if (res.code === 200) {
+          this.parseList(res.data.records, this.selectIndex, true)
+        }
+      })
     }
   }
 }

+ 123 - 83
src/views/home/component/params/params3.vue

@@ -17,18 +17,27 @@
           label-position="left"
           class='form-content flex flex-col'
       >
-        <el-form-item v-for='item in list1' :key='item' label-width='0'>
+        <el-form-item v-for='(item,index) in completeCount' :key='item' label-width='0'>
           <div class='flex flex-col flex-center full-width'>
             <div class='flex flex-center  flex-justify-between  full-width'>
               <div class='flex-child-average full-width  flex flex-center'>
-                <span style='width: 320px'>{{ item.year }}年度计划投资(万元)</span>
-                <el-input v-model='item.value' @change='change(item)'></el-input>
+                <span style='width: 320px'>{{
+                    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 : '' }}
+                </div>
               </div>
               <div style='width: 20px'></div>
               <div class='flex-child-average full-width  flex flex-center'>
-                <span style='width: 380px'>{{ item.year }}年度累计投资(万元)</span>
-                <div class='disable-input' @change='change(item)'>{{ item.value2 }}</div>
-                <div class='btnSub pointer' @click='showMonth(item,2)'>月填报</div>
+                <span style='width: 380px'>{{
+                    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 : '' }}
+                </div>
+                <div class='btnSub pointer' @click='showMonth(form.month_plan_complete_amount[index].year ,1,index)'>月填报
+                </div>
               </div>
             </div>
           </div>
@@ -46,18 +55,19 @@
           label-position="left"
           class='form-content flex flex-col'
       >
-        <el-form-item v-for='item in list2' :key='item' label-width='0'>
+        <el-form-item v-for='(item,index) in investmentCount' :key='item' label-width='0'>
           <div class='flex flex-col flex-center full-width'>
             <div class='flex flex-center  flex-justify-between  full-width'>
               <div class='flex-child-average full-width  flex flex-center'>
-                <span style='width: 400px'>{{ item.year }}年度计划纳统投资(万元)</span>
-                <el-input v-model='item.value' @change='change(item)'></el-input>
+                <span style='width: 400px'>{{ form.month_plan_investment[index].year }}年度计划纳统投资(万元)</span>
+                <el-input v-model='form.month_plan_investment[index].data' @change='change(item)'></el-input>
               </div>
               <div style='width: 20px'></div>
               <div class='flex-child-average full-width  flex flex-center'>
-                <span style='width: 440px'>{{ item.year }}年度累计纳统投资(万元)</span>
-                <div class='disable-input' @change='change(item)'>{{ item.value2 }}</div>
-                <div class='btnSub pointer' @click='showMonth(item)'>月填报</div>
+                <span style='width: 440px'>{{ form.month_plan_investment[index].year }}年度累计纳统投资(万元)</span>
+                <div class='disable-input' @change='change(item)'>{{ form.month_investment_amount.data }}</div>
+                <div class='btnSub pointer' @click='showMonth(form.month_plan_investment[index].year,2,index)'>月填报
+                </div>
               </div>
             </div>
           </div>
@@ -65,7 +75,7 @@
       </el-form>
     </div>
 
-    <el-dialog v-model='show' :title='current ? current.year + "年度" : ""' width='1260px'>
+    <el-dialog v-model='show' :title='current ? current.year + "年度" + current.index : ""' width='1260px'>
       <div class='flex flex-center flex-align-start'>
         <div>
           <div class='padding-top'></div>
@@ -74,19 +84,19 @@
         </div>
         <div>
           <div class='mr-5  flex flex-center '>
-            <div v-for='item in current.months' :key='item.name' class='title'>
-              {{ item.name }}月
+            <div v-for='item in 12' :key='item' class='title'>
+              {{ item }}月
             </div>
           </div>
           <div class='mr-5  flex flex-center'>
-            <div v-for='item in current.planMonths' :key='item.name'>
-              <input class='input' v-model="item.value" @change='changeMonth(item,1)'>
+            <div v-for='(item,index) in current.planMonths' :key='item'>
+              <input class='input' v-model="item.data" @change='changeMonth(item,1,index)'>
             </div>
           </div>
 
           <div class='mr-5  flex flex-center'>
             <div v-for='item in current.months' :key='item.name'>
-              <input class='input' v-model="item.value" @change='changeMonth(item,2)'>
+              <input class='input' v-model="item.data" @change='changeMonth(item,2)'>
             </div>
           </div>
         </div>
@@ -115,8 +125,7 @@ export default {
   watch: {
     detail: {
       handler (val) {
-        if (val) {
-          this.form = this.detail
+        if (Object.keys(val).length > 1) {
           this.init(val)
         }
       },
@@ -127,6 +136,8 @@ export default {
     return {
       show: false,
       disabled: true,
+      investmentCount: 0,
+      completeCount: 0,
       list1: [],
       list2: [],
       form: {},
@@ -183,55 +194,46 @@ export default {
         this.list2.push(item)
       }
     },
-    init () {
-      const keys = Object.keys(this.detail).filter(sub => sub.indexOf('_plan_complete_amount') > -1)
-      if (keys.length > 0) {
-        keys.forEach(sub => {
-          const tmp = Number.parseInt(sub.substring(0, 4))
-          const months = []
-          const planMonths = []
-          for (let i = 1; i <= 12; i++) {
-            months.push({ index: i, name: i, value: this.form[tmp + '_' + i + '_month_complete_amount'] })
-            planMonths.push({ index: i, name: i, value: this.form[tmp + '_' + i + '_plan_month_complete_amount'] })
-          }
+    init (res) {
+      console.log('fuck' + new Date().getTime())
+      this.investmentCount = Math.max(res.month_plan_investment.length, res.month_investment_amount.length)
+      // const dd = res.month_plan_investment.filter((sub) => {
+      //   return res.month_investment_amount.findIndex(ele => sub.year === ele.year) === -1
+      // }).map(sub => { // data -》 ''
+      //   sub.monthlyData.map(ele => {
+      //     ele.data = ''
+      //     return ele
+      //   })
+      // })
+      // // 复制差集
+      // if (res.month_plan_investment.length === this.completeCount) {
+      //   res.month_investment_amount.push(dd)
+      // } else {
+      //   res.month_plan_investment.push(dd)
+      // }
 
-          const item = {
-            type: 1,
-            code: sub,
-            code2: tmp + '_total_complete_amount',
-            year: tmp,
-            value: this.detail[tmp + '_plan_complete_amount'],
-            value2: this.detail[tmp + '_total_complete_amount'],
-            planMonths,
-            months
-          }
-          this.list1.push(item)
+      this.completeCount = Math.max(res.month_complete_amount.length, res.month_plan_complete_amount.length)
+      // 求出差集
+      const d = res.month_complete_amount.filter((sub) => {
+        return res.month_plan_complete_amount.findIndex(ele => sub.year !== ele.year) !== -1
+      }).map(sub => { // data -》 ''
+        sub.monthlyData.map(ele => {
+          ele.data = ele.data ? ele.data : ''
+          return ele
         })
-      }
-
-      const keysInvestment = Object.keys(this.detail).filter(sub => sub.indexOf('_plan_investment_amount') > -1)
-      if (keysInvestment.length > 0) {
-        keysInvestment.forEach(sub => {
-          const tmp = Number.parseInt(sub.substring(0, 4))
-          const months = []
-          const planMonths = []
-          for (let i = 1; i <= 12; i++) {
-            months.push({ index: i, name: i, value: this.form[tmp + '_' + i + '_month_investment_amount'] })
-            planMonths.push({ index: i, name: i, value: this.form[tmp + '_' + i + '_plan_month_investment_amount'] })
-          }
-          const item = {
-            type: 2,
-            code: sub,
-            code2: tmp + '_total_investment_amount',
-            year: tmp,
-            value: this.detail[tmp + '_plan_investment_amount'],
-            value2: this.detail[tmp + '_total_investment_amount'],
-            planMonths,
-            months
-          }
-          this.list2.push(item)
+        return sub
+      })
+      // 复制差集
+      if (res.month_complete_amount.length === this.completeCount) {
+        d.forEach(sub => {
+          res.month_plan_complete_amount.push(sub)
+        })
+      } else {
+        d.forEach(sub => {
+          res.month_complete_amount.push(sub)
         })
       }
+      this.form = res
     },
     change (item) {
       this.form[item.code] = item.value
@@ -251,35 +253,73 @@ export default {
         }
       })
     },
-    showMonth (item) {
-      this.current = item
+    /**
+     *
+     * @param year
+     * @param type 1 年度投资 2 纳统投资
+     * @param index 索引
+     */
+    showMonth (year, type, index) {
+      const item = { editType: type, year, index }
+      if (type === 1) {
+        item.planMonths = this.form.month_plan_complete_amount.find(sub => sub.year === year).monthlyData
+        item.months = this.form.month_complete_amount.find(sub => sub.year === year).monthlyData
+      } else if (type === 2) {
+        item.planMonths = this.form.month_plan_investment.find(sub => sub.year === year).monthlyData
+        item.months = this.form.month_investment_amount.find(sub => sub.year === year).monthlyData
+      }
+      this.current = Object.assign({}, item)
+      for (let i = 1; i <= 12; i++) {
+        const index = this.current.months.findIndex(sub => sub.month === i.toString())
+        if (index === -1 && this.current.months.length < 12) {
+          const item = { month: i.toString(), data: '', year: '' }
+          this.current.months.push(item)
+        }
+        const planIndex = this.current.planMonths.findIndex(sub => sub.month === i.toString())
+        if (planIndex === -1 && this.current.planMonths.length < 12) {
+          const item = { month: i.toString(), data: '', year: '' }
+          this.current.planMonths.push(item)
+        }
+      }
       this.show = !this.show
     },
     /**
      *
      * @param res
      * @param type 1 计划 2 累计
+     * current 1 年度投资 2 纳统投资
      */
-    changeMonth (res, type) {
+    changeMonth (res, type, index) {
       setTimeout(() => {
-        let code = this.current.year + '_' + res.name + (this.current.type === 1 ? '_month_complete_amount' : '_month_investment_amount')
-        if (type === 1) {
-          code = this.current.year + '_' + res.name + (this.current.type === 1 ? '_plan_month_complete_amount' : '_plan_month_investment_amount')
-        }
-        this.form[code] = res.value
-        const tmp = this.current.months.map(sub => Number.parseInt(sub.value))
-        const sum = tmp.reduce((accumulator, value) => {
-          return accumulator + (value || 0)
-        }, 0)
-        let codeParent = this.current.year + (this.current.type === 1 ? '_total_complete_amount' : '_total_investment_amount')
-        if (type === 1) {
-          codeParent = this.current.year + (this.current.type === 1 ? '_plan_total_complete_amount' : '_plan_total_investment_amount')
+        if (this.current.editType === 1) {
+          if (type === 1) {
+            this.form.month_plan_complete_amount[this.current.index].monthlyData[index] = res
+            this.form.month_plan_complete_amount[this.current.index].sum = this.getSum(this.form.month_plan_complete_amount[this.current.index].monthlyData)
+          } else {
+            this.form.month_complete_amount[this.current.index].monthlyData[index] = res
+            this.form.month_complete_amount[this.current.index].sum = this.getSum(this.form.month_complete_amount[this.current.index].monthlyData)
+          }
+        } else if (this.current.editType === 2) {
+          if (type === 1) {
+            this.form.month_plan_investment[this.current.index].monthlyData[index] = res
+            this.form.month_plan_investment[this.current.index].sum = this.getSum(this.form.month_plan_investment[this.current.index].monthlyData)
+          } else {
+            this.form.month_investment_amount[this.current.index].monthlyData[index] = res
+            this.form.month_investment_amount[this.current.index].sum = this.getSum(this.form.month_investment_amount[this.current.index].monthlyData)
+          }
         }
-        this.form[codeParent] = sum
-        this.current.value2 = sum
         console.log(this.form)
-        this.update(false)
+        // this.update(false)
       }, 500)
+    },
+    getSum (list) {
+      let sum = 0
+      list.forEach(sub => {
+        if (sub.data.length > 0) {
+          sum = sum + Number.parseInt(sub.data)
+        }
+      })
+      return sum
     }
   }
 }

+ 2 - 2
vite.config.js

@@ -39,9 +39,9 @@ export default defineConfig({
     proxy: {
       '/api': {
         // 正式环境地址
-        // target: 'https://dev.wutongresearch.club/api',
+        target: 'https://dev.wutongresearch.club/api',
         // target: 'https://prod.wutongshucloud.com/api',
-        target: 'http://192.168.31.181:8110',
+        // target: 'http://192.168.31.181:8110',
         changeOrigin: true,
         rewrite: (path) => path.replace(/^\/api/, '')
       }