zhengnaiwen_citu hace 5 meses
padre
commit
abc971b21a

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

@@ -93,26 +93,6 @@ export default {
             { required: true, message: '请选择绩效职务', trigger: 'change' }
           ]
         }
-        // {
-        //   label: '下级自定义',
-        //   prop: 'rewriteType',
-        //   type: 'radioGroup',
-        //   options: {
-        //     items: [
-        //       {
-        //         text: '允许',
-        //         label: 0
-        //       },
-        //       {
-        //         text: '不允许',
-        //         label: 1
-        //       }
-        //     ]
-        //   },
-        //   rules: [
-        //     { required: true, message: '请选择下级自定义', trigger: 'change' }
-        //   ]
-        // }
       ]
     }
   },

+ 60 - 97
src/views/salary/solution/salarySolution/salarySolutionRulesEdit.vue

@@ -1,50 +1,46 @@
 <template>
   <m-card shadow="never">
-    <el-form ref="form" :model="formQuery">
+    <el-form ref="form">
       <el-form-item label="参数配置" class="mb-3">
         <m-table
+          ref="tableRefs"
           shadow="naver"
           clearHeader
-          :items="formQuery.items"
+          :items="items"
+          row-key="index"
           :headers="[
+            { type: 'expand', prop: 'expandProp' },
             { label: '参数', prop: 'label' },
-            { label: '数值', prop: 'value' },
+            { label: '参数类型', prop: 'valueCategory' },
             { label: '操作', prop: 'actions' }
           ]"
         >
+          <template #expandProp="{ row }">
+            <el-form label-width="100px">
+              <el-form-item label="参数">
+                <el-input v-model="row.label" size="small"></el-input>
+              </el-form-item>
+              <el-form-item label="参数类型">
+                <el-select v-model="row.valueCategory" size="small">
+                  <el-option
+                    v-for="item in DICT_CATEGORY"
+                    :key="item.value"
+                    :label="item.label"
+                    :value="item.value"
+                  >
+                  </el-option>
+                </el-select>
+              </el-form-item>
+            </el-form>
+          </template>
           <div class="text-center mt-3">
-            <m-button icon="el-icon-plus" type="orange" size="small" @click="onAdd">添加一行</m-button>
+            <m-button icon="el-icon-plus" type="orange" size="small" @click="onAdd">添加参数</m-button>
           </div>
-          <template #label="scope">
-            <el-form-item
-              :prop="`items.${scope.$index}.label`"
-              :rules="{ required: true, message: '请输入参数名称', trigger: 'blur' }"
-            >
-              <el-input
-                size="small"
-                v-model="formQuery.items[scope.$index].label"
-                placeholder="请输入参数"
-                type="textarea"
-                :autosize="{ minRows: 1, maxRows: 4}"
-              ></el-input>
-            </el-form-item>
-          </template>
-          <template #value="scope">
-            <el-form-item
-              :prop="`items.${scope.$index}.value`"
-              :rules="{ required: true, message: '请输入值', trigger: 'blur' }"
-            >
-              <el-input-number
-                size="small"
-                v-model="formQuery.items[scope.$index].value"
-                placeholder="参数名称"
-                :min="0"
-                :step="0.1"
-              ></el-input-number>
-            </el-form-item>
+          <template #valueCategory="{ row }">
+            {{ DICT_CATEGORY.find(item => item.value === row.valueCategory)?.label }}
           </template>
           <template #actions="scope">
-            <m-button size="small" text type="danger" @click="onDelete(scope)">除</m-button>
+            <m-button size="small" text type="danger" @click="onDelete(scope)">移除</m-button>
           </template>
         </m-table>
       </el-form-item>
@@ -65,14 +61,18 @@
         />
         </m-card>
       </el-form-item>
-
     </el-form>
+    <!-- <SalarySolutionRulesEditParam ref="salarySolutionRulesEditParamRefs" @submit="onAddSubmit"></SalarySolutionRulesEditParam> -->
   </m-card>
 </template>
 
 <script>
 import { Editor, Toolbar } from '@wangeditor/editor-for-vue'
 import '@wangeditor/editor/dist/css/style.css'
+// import SalarySolutionRulesEditParam from './salarySolutionRulesEditParam.vue'
+import {
+  DICT_CATEGORY
+} from '../utils/Dict'
 export default {
   name: 'salarySolutionRulesEdit',
   components: { Editor, Toolbar },
@@ -84,6 +84,7 @@ export default {
   },
   data () {
     return {
+      DICT_CATEGORY,
       editor: null,
       formulaData: '',
       toolbarConfig: {
@@ -91,25 +92,13 @@ export default {
           'headerSelect',
           // 分割线
           '|',
-          // 菜单 key
           'bold',
           'italic'
         ]
       },
       editorConfig: { placeholder: '请输入内容...' },
       mode: 'default', // or 'simple'
-      formQuery: {
-        items: []
-      }
-      // formulaData: [{
-      //   uuid: '1',
-      //   content: null
-      // }],
-      // btnList: [
-      //   { label: '同级追加', click: this.onInsertAfter },
-      //   { label: '插入下一级', click: this.onAppend },
-      //   { label: '删除', click: this.onRemove }
-      // ]
+      items: []
     }
   },
   beforeDestroy () {
@@ -122,53 +111,41 @@ export default {
       this.editor = Object.seal(editor) // 一定要用 Object.seal() ,否则会报错
     },
     onAdd () {
-      this.formQuery.items.push({ label: null, value: 0 })
+      const item = {
+        index: this.items.length,
+        label: '未命名',
+        valueCategory: 0
+      }
+      this.items.push(item)
+      const ref = this.$refs.tableRefs.getRefs()
+      ref.toggleRowExpansion(item)
     },
     onDelete (scope) {
-      this.$confirm('确定要删除吗?', '提示').then(e => {
-        this.formQuery.items.splice(scope.$index, 1)
+      this.$confirm('确定要移除改组参数吗?', '提示').then(e => {
+        this.items.splice(scope.$index, 1)
       }).catch(_ => {})
     },
-    // onRemove (data) {
-    //   this.$confirm('确定要删除吗?', '提示').then(e => {
-    //     this.$refs.formulaTreeRefs.remove(data)
-    //   }).catch(_ => {})
-    // },
-    // onInsertAfter (data) {
-    //   this.$refs.formulaTreeRefs.insertAfter({
-    //     uuid: Date.now(),
-    //     content: null
-    //   }, data)
-    // },
-    // onAppend (data) {
-    //   this.$refs.formulaTreeRefs.append({
-    //     uuid: Date.now(),
-    //     content: null
-    //   }, data)
-    // },
-    // onCommon (index, data) {
-    //   this.btnList[index].click(data)
-    // },
     valid () {
       return new Promise((resolve, reject) => {
-        this.$refs.form.validate(valid => {
-          if (valid) {
-            resolve(this.getValue())
-          } else {
-            const obj = {
-              data: this.item,
-              $refs: this.$refs.form
-            }
-            reject(obj)
-          }
-        })
+        resolve(this.getValue())
+        // this.$refs.form.validate(valid => {
+        //   if (valid) {
+        //     resolve(this.getValue())
+        //   } else {
+        //     const obj = {
+        //       data: this.item,
+        //       $refs: this.$refs.form
+        //     }
+        //     reject(obj)
+        //   }
+        // })
       })
     },
     setValue (data) {
-      this.formQuery.items = data.calculateConfigurations.map(e => {
+      this.items = data.calculateConfigurations.map(e => {
         return {
           label: e.name,
-          value: e.value
+          valueCategory: e.valueCategory
         }
       })
       this.$nextTick(() => {
@@ -176,23 +153,9 @@ export default {
       })
     },
     getValue () {
-      // const calculateFormulas = removeUuidFromArrayTree(this.formulaData)
-      // function removeUuidFromArrayTree (treeArray) {
-      //   return treeArray.map(node => {
-      //   // 删除当前节点的uuid
-      //     const { uuid, children, ...rest } = node
-
-      //     // 如果有子节点,递归处理
-      //     const cleanedNode = { ...rest }
-      //     if (children && Array.isArray(children) && children.length > 0) {
-      //       cleanedNode.children = removeUuidFromArrayTree(children)
-      //     }
-      //     return cleanedNode
-      //   })
-      // }
       return {
         category: this.item.title,
-        calculateConfigurations: this.formQuery.items.map(e => {
+        calculateConfigurations: this.items.map(e => {
           return {
             name: e.label,
             value: e.value

+ 72 - 0
src/views/salary/solution/salarySolution/salarySolutionRulesEditParam.vue

@@ -0,0 +1,72 @@
+<template>
+  <m-dialog ref="dialog" title="添加参数" append-to-body @sure="onSure">
+    <m-form ref="form" :items="formItems" v-model="formValues"></m-form>
+  </m-dialog>
+</template>
+
+<script>
+import {
+  DICT_CATEGORY
+} from '../utils/Dict'
+export default {
+  name: 'salarySolutionRulesEditParam',
+  data () {
+    return {
+      formValues: {
+        label: null,
+        valueCategory: 0
+      }
+    }
+  },
+  computed: {
+    formItems () {
+      return [
+        {
+          label: '参数名称',
+          prop: 'label',
+          type: 'input',
+          options: {
+            placeholder: '请输入参数名称'
+          },
+          rules: [
+            { required: true, message: '请输入参数名称', trigger: 'blur' }
+          ]
+        },
+        {
+          label: '参数类型',
+          prop: 'valueCategory',
+          type: 'select',
+          options: {
+            placeholder: '请选择参数类型',
+            items: DICT_CATEGORY
+          },
+          rules: [
+            { required: true, message: '请选择参数类型', trigger: 'change' }
+          ]
+        }
+      ]
+    }
+  },
+  methods: {
+    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>
+
+<style lang="scss" scoped>
+
+</style>

+ 16 - 0
src/views/salary/solution/utils/Dict.js

@@ -0,0 +1,16 @@
+
+// 参数类型字典
+export const DICT_CATEGORY = [
+  {
+    label: '数值',
+    value: 0
+  },
+  {
+    label: '字典',
+    value: 1
+  },
+  {
+    label: '表格',
+    value: 2
+  }
+]