zhengnaiwen_citu 4 mēneši atpakaļ
vecāks
revīzija
488d28709d

+ 3 - 0
src/views/salary/solution/salarySolution/salarySolutionEdit.vue

@@ -153,6 +153,7 @@ export default {
             },
             performanceSolutionDetailRespCategoryVos: this.itemData.performanceSolutionDetailRespCategoryVos
           }
+          this.loading = true
           try {
             await saveSolution(query)
             this.$refs.dialog.close()
@@ -160,6 +161,8 @@ export default {
             this.$message.success('保存成功')
           } catch (error) {
             this.$message.error(error)
+          } finally {
+            this.loading = false
           }
         }
       })

+ 24 - 11
src/views/salary/solution/salarySolution/salarySolutionRulesEdit.vue

@@ -16,9 +16,10 @@
               { label: '参数类型', prop: 'valueCategory' },
               { label: '操作', prop: 'actions' }
             ]"
+            @expand-change="onExpandChange"
           >
-            <template #expandProp="{ row }">
-              <SalarySolutionRulesEditParam ref="salarySolutionRulesEditParamRefs" @assign="onAssign(row, $event)"></SalarySolutionRulesEditParam>
+            <template #expandProp="{ row, $index }">
+              <SalarySolutionRulesEditParam :ref="`salarySolutionRulesEditParamRefs${$index}`" @assign="onAssign(row, $event)"></SalarySolutionRulesEditParam>
             </template>
             <div class="text-center mt-3">
               <m-button icon="el-icon-plus" type="orange" size="small" @click="onAdd">添加参数</m-button>
@@ -106,7 +107,7 @@ export default {
     onAdd () {
       const item = {
         index: this.items.length,
-        name: '未命名',
+        name: null,
         valueCategory: 0
       }
       this.items.push(item)
@@ -119,23 +120,32 @@ export default {
       }).catch(_ => {})
     },
     valid () {
-      console.log('this.$refs.salarySolutionRulesEditParamRefs', this.$refs)
       return new Promise((resolve, reject) => {
-        const check = this.$refs.salarySolutionRulesEditParamRefs.some(e => {
-          return !e.valid()
+        const check = this.items.every(e => {
+          console.log(111, this.$refs[`salarySolutionRulesEditParamRefs${e.index}`].valid())
+          return this.$refs[`salarySolutionRulesEditParamRefs${e.index}`].valid()
         })
-        if (check) {
+        if (!check) {
           reject(this.item)
         } else {
           resolve(this.getValue())
         }
       })
     },
+    onExpandChange (row, expandedRows) {
+      const open = expandedRows.find(e => e.index === row.index)
+      if (!open) {
+        return
+      }
+      this.$nextTick(() => {
+        this.$refs[`salarySolutionRulesEditParamRefs${row.index}`].setValue(row)
+      })
+    },
     setValue (data) {
-      this.items = data.calculateConfigurations.map(e => {
+      this.items = data.calculateConfigurations.map((e, index) => {
         return {
-          name: e.name,
-          valueCategory: e.valueCategory
+          index,
+          ...e
         }
       })
       this.$nextTick(() => {
@@ -143,9 +153,12 @@ export default {
       })
     },
     getValue () {
+      const calculateConfigurations = this.items.map(e => {
+        return this.$refs[`salarySolutionRulesEditParamRefs${e.index}`].getValue()
+      })
       return {
         category: this.item.title,
-        calculateConfigurations: this.items,
+        calculateConfigurations,
         calculateFormulas: [
           {
             category: this.item.title,

+ 69 - 51
src/views/salary/solution/salarySolution/salarySolutionRulesEditParam.vue

@@ -43,36 +43,12 @@ export default {
       formValues: {
         name: null,
         valueCategory: 0,
-        miniValue: 0,
-        maxValue: 0,
-        value: 0
+        miniValue: null,
+        maxValue: null,
+        value: null
       }
     }
   },
-  watch: {
-    formValues: {
-      handler (val) {
-        if (val.valueCategory === 0) {
-          this.$emit('assign', val)
-          return
-        }
-        if (val.valueCategory === 1) {
-          this.$emit('assign', {
-            name: val.name,
-            valueCategory: val.valueCategory,
-            value: this.items
-          })
-          return
-        }
-        const { value, ...obj } = val
-        this.$emit('assign', {
-          ...obj,
-          value: this.items
-        })
-      },
-      deep: true
-    }
-  },
   computed: {
     formItems () {
       const style = 'margin-bottom: 12px'
@@ -165,6 +141,28 @@ export default {
     }
   },
   methods: {
+    setValue (item) {
+      const {
+        valueCategory,
+        value,
+        ...obj
+      } = item
+      this.formValues = {
+        ...obj,
+        valueCategory,
+        value: valueCategory === 0 ? value : JSON.parse(value)
+      }
+      if (valueCategory !== 0) {
+        this.id = 0
+        this.items = JSON.parse(value).map(e => {
+          return {
+            name: e.name,
+            value: e.value,
+            index: this.id++
+          }
+        })
+      }
+    },
     onAdd () {
       this.items.push({
         name: null,
@@ -176,34 +174,54 @@ export default {
       this.items.splice(index, 1)
     },
     valid () {
-      this.$refs.form.validate(valid => {
-        if (!valid) {
-          this.$message.error('请填写完整参数配置')
-          return
+      if (!this.formValues.name) {
+        return
+      }
+      if (this.formValues.valueCategory !== 0) {
+        return this.items.every(e => {
+          return (e.name === null && e.value === null) || (e.name !== null && e.value !== null)
+        })
+      }
+      return true
+    },
+    getValue () {
+      const {
+        name,
+        valueCategory,
+        miniValue,
+        maxValue,
+        value
+      } = this.formValues
+      if (valueCategory === 0) {
+        return {
+          name,
+          valueCategory,
+          miniValue,
+          maxValue,
+          value
         }
-        if (this.formValues.valueCategory !== 0) {
-          return this.items.every(e => {
-            return (e.name === null && e.value === null) || (e.name !== null && e.value !== null)
-          })
+      }
+      const items = this.items.map(e => {
+        return {
+          name: e.name,
+          value: e.value
         }
-        return true
       })
+      if (valueCategory === 1) {
+        return {
+          name,
+          valueCategory,
+          value: JSON.stringify(items)
+        }
+      }
+      return {
+        name,
+        valueCategory,
+        miniValue,
+        maxValue,
+        value: JSON.stringify(items)
+      }
     }
-    // open () {
-    //   this.formValues = {
-    //     label: null,
-    //     valueCategory: 0
-    //   }
-    //   this.$refs.dialog.open()
-    // },
-    // onSure () {
-    //   this.$refs.form.validate(valid => {
-    //     if (valid) {
-    //       this.$emit('submit', this.formValues)
-    //       this.$refs.dialog.close()
-    //     }
-    //   })
-    // }
   }
 }
 </script>

+ 41 - 52
src/views/salary/upload/index.vue

@@ -45,7 +45,7 @@
 
 <script>
 import {
-  // getSalaryCalculateTemplate,
+  getSalaryCalculateTemplate,
   uploadSalaryCalculateFiles,
   getSalaryCalculateFiles
 } from '@/api/salary'
@@ -55,18 +55,15 @@ export default {
   data () {
     return {
       searchValues: {
-        month: dateFormat('YYYY-mm', new Date()),
-        category: null
+        month: dateFormat('YYYY-mm', new Date())
       },
       queryValues: {},
       filesValues: {},
-      // categoryItems: [],
-      items: [],
+      categoryItems: [],
       historyItems: [],
       formItems: [],
       headers: [
         { label: '月份', prop: 'month', width: 100 },
-        // { label: '绩效方案', prop: 'category' },
         { label: '文件类型', prop: 'fileName' },
         { label: '已上传文件', prop: 'history' },
         { label: '待上传文件', prop: 'file' },
@@ -74,22 +71,25 @@ export default {
       ],
       loading: false,
       submitLoading: false,
-      runLoading: false
+      runLoading: false,
+      categoryType: null
     }
   },
   computed: {
-    // items () {
-    //   const items = this.categoryItems.find(e => e.category === this.queryValues.category)?.files
-    //   if (!items) {
-    //     return []
-    //   }
-    //   return items.map(e => {
-    //     return {
-    //       ...e,
-    //       history: this.historyItems.find(h => h.fileType === e.fileType)?.fileOriginalFilename
-    //     }
-    //   })
-    // },
+    items () {
+      const items = this.categoryItems.reduce((res, v) => {
+        return res.concat(v.files)
+      }, [])
+      if (!items) {
+        return []
+      }
+      return items.map(e => {
+        return {
+          ...e,
+          history: this.historyItems.find(h => h.fileType === e.fileType)?.fileOriginalFilename
+        }
+      })
+    },
     searchItems () {
       return [
         {
@@ -104,21 +104,6 @@ export default {
             placeholder: '选择更新月份'
           }
         }
-        // {
-        //   label: '绩效方案',
-        //   prop: 'category',
-        //   type: 'select',
-        //   options: {
-        //     clearable: false,
-        //     placeholder: '选择业务线',
-        //     items: this.categoryItems.map(e => {
-        //       return {
-        //         label: e.category,
-        //         value: e.category
-        //       }
-        //     })
-        //   }
-        // }
       ]
     }
   },
@@ -127,6 +112,26 @@ export default {
   },
   methods: {
     async onInit () {
+      try {
+        const { data } = await getSalaryCalculateTemplate()
+        this.categoryItems = data
+        if (!data.length) {
+          return
+        }
+        this.categoryType = data[0].category
+        this.queryValues = { ...this.searchValues }
+        this.filesValues = {
+          ...this.items.reduce((res, v) => {
+            res[v.fileType] = null
+            return res
+          }, {})
+        }
+        this.onGetHistory()
+      } catch (error) {
+        this.$message.error(error)
+      }
+    },
+    async onGetHistory () {
       try {
         this.loading = true
         const { data } = await getSalaryCalculateFiles(this.queryValues)
@@ -138,25 +143,9 @@ export default {
       }
     },
     onSearch (query) {
-      // if (!query.category) {
-      //   this.searchValues.category = this.categoryItems[0]?.category ?? null
-      // }
       this.queryValues = { ...this.searchValues }
       this.onInit()
     },
-    // onChange () {
-    //   const items = this.categoryItems.find(e => e.category === this.queryValues.category)?.files ?? []
-    //   if (!items.length) {
-    //     this.filesValues = {}
-    //     return
-    //   }
-    //   this.filesValues = {
-    //     ...items.reduce((res, v) => {
-    //       res[v.fileType] = null
-    //       return res
-    //     }, {})
-    //   }
-    // },
     onExceed (files, fileList, key) {
       this.filesValues[key] = files[0]
     },
@@ -179,7 +168,6 @@ export default {
       this.$confirm(h('div', [
         h('p', undefined, '确定要更新文件吗?'),
         h('p', undefined, `更新月份:${this.queryValues.month}`),
-        h('p', undefined, `更新物业线:${this.queryValues.category}`),
         h('p', { style: 'color: red' }, '上传文件后,将覆盖之前的文件,请谨慎操作!')
       ]), '提示').then(async () => {
         this.submitLoading = true
@@ -191,9 +179,10 @@ export default {
             }
             formData.append('files', this.filesValues[key])
             formData.append('fileTypes', key)
+            // this.items.find()
           })
           formData.append('month', this.queryValues.month)
-          formData.append('category', this.queryValues.category)
+          formData.append('category', this.categoryType)
           await uploadSalaryCalculateFiles(formData)
           this.$message.success('保存成功')
           this.onInit()