zhengnaiwen_citu hai 5 meses
pai
achega
a4fc397ab8

+ 16 - 11
src/api/system.js

@@ -155,19 +155,19 @@ export function downloadRosterTemplate () {
 }
 
 // 花名册钻取员工
-export function organizationDrill (params) {
-  return http.post('/digitizationData/employee/organization/tree/subordinates', params)
-}
+// export function organizationDrill (params) {
+//   return http.post('/digitizationData/employee/organization/tree/subordinates', params)
+// }
 
 // 获取机构图
-export function getOrganizationAtlas () {
-  return http.post('/organization/atlas')
-}
+// export function getOrganizationAtlas () {
+//   return http.post('/organization/atlas')
+// }
 
 // 机构图钻取员工图例
-export function getOrganizationAtlasEmployee (params) {
-  return http.post('/organization/employee/atlas', params)
-}
+// export function getOrganizationAtlasEmployee (params) {
+//   return http.post('/organization/employee/atlas', params)
+// }
 
 // 机构人员 树状结构
 export function getOrganizationAndEmployeeTree (params) {
@@ -175,8 +175,13 @@ export function getOrganizationAndEmployeeTree (params) {
 }
 
 // 机构图钻取岗位图例
-export function getOrganizationAtlasPostName (params) {
-  return http.post('/digitizationData/employee/postName/atlas', params)
+// export function getOrganizationAtlasPostName (params) {
+//   return http.post('/digitizationData/employee/postName/atlas', params)
+// }
+
+// 根据机构编码获取职务
+export function getPostNameByOrganizationNo (params) {
+  return http.post('/digitizationData/employee/postnames', params)
 }
 
 // 全机构机构树状

+ 54 - 21
src/views/salary/solution/salarySolution/salarySolutionEdit.vue

@@ -9,6 +9,10 @@ import {
   saveSolution,
   getSolutionDetails
 } from '@/api/salary'
+import {
+  getPostNameByOrganizationNo
+// getOrganizationAtlasPostName
+} from '@/api/system'
 import { mapGetters } from 'vuex'
 export default {
   name: 'salary-solution-edit',
@@ -19,9 +23,10 @@ export default {
         title: null,
         tag: null,
         organizationNo: null,
-        category: null,
+        postNames: [],
         rewriteType: 0
       },
+      postNamesItems: [],
       itemData: {}
     }
   },
@@ -58,23 +63,29 @@ export default {
             options: this.organizationTree,
             showAllLevels: false,
             props: {
+              emitPath: false,
               checkStrictly: true,
               value: 'organizationNo',
               label: 'organizationName',
               children: 'child'
             }
           },
+          handles: {
+            change: this.onchange
+          },
           rules: [
             { required: true, message: '请选择绩效机构', trigger: 'change' }
           ]
         },
         {
           label: '绩效职务',
-          prop: 'category',
+          prop: 'postNames',
           type: 'select',
           options: {
             placeholder: '请选择绩效职务',
-            items: []
+            collapseTags: true,
+            multiple: true,
+            items: this.postNamesItems
           },
           rules: [
             { required: true, message: '请选择绩效职务', trigger: 'change' }
@@ -106,24 +117,46 @@ export default {
   methods: {
     async open (item) {
       this.$refs.dialog.open()
-      if (item) {
-        this.formQuery.title = item.title
-        this.formQuery.tag = item.tag
-        this.loading = true
-        try {
-          const { data } = await getSolutionDetails({
-            performanceSolutionId: item.performanceSolutionId
-          })
-          this.itemData = data
-        } catch (error) {
-          this.$message.error(error)
-        } finally {
-          this.loading = false
-        }
-      } else {
-        this.formQuery.title = null
-        this.formQuery.tag = null
-        this.itemData = {}
+      this.formQuery.title = item?.title ?? null
+      this.formQuery.tag = item?.tag ?? null
+      this.formQuery.organizationNo = item?.organizationNo ?? null
+      this.formQuery.postNames = item?.postNames ?? []
+      this.itemData = {}
+      this.$nextTick(() => {
+        this.$refs.form.clearValidate()
+      })
+      if (!item) {
+        return
+      }
+      this.loading = true
+      try {
+        const { data } = await getSolutionDetails({
+          performanceSolutionId: item.performanceSolutionId
+        })
+        this.itemData = data
+      } catch (error) {
+        this.$message.error(error)
+      } finally {
+        this.loading = false
+      }
+    },
+    async onchange (organizationNo) {
+      this.formQuery.postNames = []
+      if (!organizationNo) {
+        return
+      }
+      try {
+        const { data } = await getPostNameByOrganizationNo({
+          organizationNo
+        })
+        this.postNamesItems = (data && data.map(e => {
+          return {
+            label: e,
+            value: e
+          }
+        })) || []
+      } catch (error) {
+        this.$message.error(error)
       }
     },
     onSure () {

+ 80 - 102
src/views/salary/solution/salarySolution/salarySolutionRules.vue

@@ -5,20 +5,33 @@
         <el-tag color="primary">{{ itemData.title }}</el-tag>
       </el-form-item>
       <el-form-item label="类型">
-        <el-tabs v-model="editableTabsValue" addable type="card" @edit="onTabsEdit">
-          <el-tab-pane
-            v-for="tab in editableTabs"
-            :key="tab.name"
-            :label="tab.label"
-            :name="tab.name"
-            :closable="editableTabs.length > 1"
-          >
-            <div class="text-right mb-3">
-              <m-button size="small" type="orange" >编辑分类名称</m-button>
-            </div>
-            <SalarySolutionRulesEdit></SalarySolutionRulesEdit>
-          </el-tab-pane>
-        </el-tabs>
+        <template v-slot:default>
+          <el-tabs type="card" addable v-model="editableTabsValue" @edit="onTabsEdit">
+            <el-tab-pane
+              v-for="tab in editableTabs"
+              :key="tab.name"
+              :name="tab.name"
+              :closable="editableTabs.length > 1"
+            >
+              <template v-slot:label>
+                {{ tab.title }}
+                <el-popover
+                  placement="top-start"
+                  width="200"
+                  trigger="click"
+                >
+                  <el-input v-model="tab.title" size="small"></el-input>
+                  <span class="ml-3" slot="reference" @click.stop="">
+                    <i class="el-icon-edit"></i>
+                  </span>
+                </el-popover>
+              </template>
+              <template v-slot:default>
+                <SalarySolutionRulesEdit :item="tab" ref="salarySolutionRulesEditRefs"></SalarySolutionRulesEdit>
+              </template>
+            </el-tab-pane>
+          </el-tabs>
+        </template>
       </el-form-item>
     </el-form>
   </m-dialog>
@@ -28,8 +41,6 @@
 import SalarySolutionRulesEdit from './salarySolutionRulesEdit.vue'
 import {
   saveSolution,
-  getConfigPage,
-  getConfigCateGories,
   getSolutionDetails
 } from '@/api/salary'
 
@@ -41,73 +52,54 @@ export default {
   data () {
     return {
       editableTabsValue: '1',
+      editableTabs: [],
       ids: 1,
-      editableTabs: [
-        { label: '分类1', name: '1', content: null }
-      ],
       itemData: {},
-      loading: false,
-      categories: [], // 所有分类
-      allParams: [], // 所有参数
-      paramsCategoryItems: {}, // 整合分类列表层级
-      paramsActive: null, // 已选value
-      paramsSelection: [] // 已选参数
+      loading: false
     }
   },
   methods: {
-    open (item) {
+    async open (item) {
       this.itemData = item
       this.$refs.dialog.open()
       this.loading = true
-      this.$nextTick(async () => {
-        try {
-        // 获取所有分类
-          const { data: categories } = await getConfigCateGories({})
-          this.categories = categories
-          this.paramsActive = categories[0]
-          // 获取完整列表
-          const { data: allParams } = await getConfigPage({
-            size: 9999,
-            current: 1
-          })
-          this.allParams = allParams.records
-          const { data: detail } = await getSolutionDetails({
-            performanceSolutionId: item.performanceSolutionId
-          })
-          // if (!detail.calculateFormulas.length) {
-          //   this.formula = [
-          //     { uuid: '1', content: null, sort: null }
-          //   ]
-          // } else {
-          //   this.formula = detail.calculateFormulas
-          // }
-          this.paramsSelection = detail.calculateConfigurations.map(e => e.name)
-
-          // 根据分类获取参数列表
-          this.paramsCategoryItems = categories.reduce((res, key) => {
-            res[key] = this.allParams.filter(item => item.category === key).map(e => {
-              const _item = detail.calculateConfigurations.find(_f => _f.name === e.name)
-              return {
-                name: e.name,
-                value: _item?.value ?? e?.value ?? 0,
-                category: e.category,
-                status: Boolean(_item)
-              }
-            })
-            return res
-          }, {})
-        } catch (error) {
-          this.$message.error(error)
-        } finally {
-          this.loading = false
+      this.ids = 1
+      this.editableTabsValue = '1'
+      try {
+        const { data } = await getSolutionDetails({
+          performanceSolutionId: item.performanceSolutionId
+        })
+        if (!data.performanceSolutionDetailRespCategoryVos.length) {
+          this.editableTabs = [{
+            title: '类型1',
+            name: '1'
+          }]
+          return
         }
-      })
+        this.editableTabs = data.performanceSolutionDetailRespCategoryVos.map((e, index) => {
+          const key = String(index + 1)
+          return {
+            title: e.category,
+            name: key
+          }
+        })
+        this.ids = this.editableTabs.length
+        this.$nextTick(() => {
+          this.$refs.salarySolutionRulesEditRefs.forEach((e, index) => {
+            e.setValue(data.performanceSolutionDetailRespCategoryVos[index])
+          })
+        })
+      } catch (error) {
+        this.$message.error(error)
+      } finally {
+        this.loading = false
+      }
     },
     onTabsEdit (targetName, action) {
       if (action === 'add') {
         this.ids++
         this.editableTabs.push(
-          { label: '分类' + this.ids, name: String(this.ids), content: null }
+          { title: '类型' + this.ids, name: String(this.ids) }
         )
       }
       if (action === 'remove') {
@@ -127,39 +119,25 @@ export default {
       }
     },
     async onSure () {
-      if (this.paramsSelection.length === 0) {
-        this.$message.error('请选择参数')
-        return
-      }
-
-      const calculateFormulas = removeUuidFromArrayTree(this.formula)
-      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
-        })
-      }
-      try {
-        await saveSolution({
-          entity: {
-            performanceSolutionId: this.itemData.performanceSolutionId
-          },
-          calculateConfigurations: [],
-          calculateFormulas
-        })
-        this.$refs.dialog.close()
-        this.$emit('refresh')
-        this.$message.success('保存成功')
-      } catch (error) {
-        this.$message.error(error)
-      }
+      // 验证
+      Promise.all(this.$refs.salarySolutionRulesEditRefs.map(e => e.valid())).then(async data => {
+        try {
+          await saveSolution({
+            entity: {
+              performanceSolutionId: this.itemData.performanceSolutionId
+            },
+            performanceSolutionDetailRespCategoryVos: data
+          })
+          this.$refs.dialog.close()
+          this.$emit('refresh')
+          this.$message.success('保存成功')
+        } catch (error) {
+          this.$message.error(error)
+        }
+      }).catch(error => {
+        this.editableTabsValue = error.data.name
+        this.$message.error('请填充完整')
+      })
     }
   }
 }

+ 141 - 82
src/views/salary/solution/salarySolution/salarySolutionRulesEdit.vue

@@ -1,95 +1,104 @@
 <template>
   <m-card shadow="never">
-    <el-form-item label="参数配置" class="mb-3">
-      <m-table
-        shadow="naver"
-        clearHeader
-        :items="formQuery.items"
-        :headers="[
-          { label: '参数', prop: 'label' },
-          { label: '数值', prop: 'value' },
-          { label: '操作', prop: 'actions' }
-        ]"
-      >
-        <div class="text-center mt-3">
-          <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="参数名称"
-            ></el-input-number>
-          </el-form-item>
-        </template>
-        <template #actions="scope">
-          <m-button size="small" text type="danger" @click="onDelete(scope)">删除</m-button>
-        </template>
-      </m-table>
-    </el-form-item>
-    <el-form-item label="计算公式">
-      <m-card shadow="never">
-        <el-tree
-          :data="formulaData"
-          node-key="uuid"
-          ref="formulaTreeRefs"
-          default-expand-all
-          :expand-on-click-node="false"
+    <el-form ref="form" :model="formQuery">
+      <el-form-item label="参数配置" class="mb-3">
+        <m-table
+          shadow="naver"
+          clearHeader
+          :items="formQuery.items"
+          :headers="[
+            { label: '参数', prop: 'label' },
+            { label: '数值', prop: 'value' },
+            { label: '操作', prop: 'actions' }
+          ]"
         >
-          <div class="custom-tree-node" slot-scope="{ data, node }">
-            <el-input size="small" v-model="data.content" style="width: 300px" placeholder="描述文字"></el-input>
-            <template v-if="node.level > 6">
-              <el-dropdown @command="e => onCommon(e, data)">
-                <m-button size="small" class="ml-3">
-                  查看更多
-                </m-button>
-                <el-dropdown-menu slot="dropdown">
-                  <el-dropdown-item
-                    v-for="(item, index) in btnList"
-                    :key="item.label"
-                    :command="index"
-                  >{{ item.label }}</el-dropdown-item>
-                </el-dropdown-menu>
-              </el-dropdown>
-            </template>
-            <template v-else>
-              <el-button
-                v-for="item in btnList"
-                :key="item.label"
-                class="ml-3"
-                size="small"
-                @click="item.click(data)">
-                {{ item.label }}
-              </el-button>
-            </template>
+          <div class="text-center mt-3">
+            <m-button icon="el-icon-plus" type="orange" size="small" @click="onAdd">添加一行</m-button>
           </div>
-        </el-tree>
-      </m-card>
-    </el-form-item>
+          <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="参数名称"
+              ></el-input-number>
+            </el-form-item>
+          </template>
+          <template #actions="scope">
+            <m-button size="small" text type="danger" @click="onDelete(scope)">删除</m-button>
+          </template>
+        </m-table>
+      </el-form-item>
+      <el-form-item label="计算公式">
+        <m-card shadow="never">
+          <el-tree
+            :data="formulaData"
+            node-key="uuid"
+            ref="formulaTreeRefs"
+            default-expand-all
+            :expand-on-click-node="false"
+          >
+            <div class="custom-tree-node" slot-scope="{ data, node }">
+              <el-input size="small" v-model="data.content" style="width: 300px" placeholder="描述文字"></el-input>
+              <template v-if="node.level > 6">
+                <el-dropdown @command="e => onCommon(e, data)">
+                  <m-button size="small" class="ml-3">
+                    查看更多
+                  </m-button>
+                  <el-dropdown-menu slot="dropdown">
+                    <el-dropdown-item
+                      v-for="(item, index) in btnList"
+                      :key="item.label"
+                      :command="index"
+                    >{{ item.label }}</el-dropdown-item>
+                  </el-dropdown-menu>
+                </el-dropdown>
+              </template>
+              <template v-else>
+                <el-button
+                  v-for="item in btnList"
+                  :key="item.label"
+                  class="ml-3"
+                  size="small"
+                  @click="item.click(data)">
+                  {{ item.label }}
+                </el-button>
+              </template>
+            </div>
+          </el-tree>
+        </m-card>
+      </el-form-item>
+
+    </el-form>
   </m-card>
 </template>
 
 <script>
 export default {
   name: 'salarySolutionRulesEdit',
+  props: {
+    item: {
+      type: Object,
+      default: () => ({})
+    }
+  },
   data () {
     return {
       formQuery: {
@@ -134,6 +143,56 @@ export default {
     },
     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)
+          }
+        })
+      })
+    },
+    setValue (data) {
+      this.formQuery.items = data.calculateConfigurations.map(e => {
+        return {
+          label: e.name,
+          value: e.value
+        }
+      })
+      this.formulaData = data.calculateFormulas
+    },
+    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 => {
+          return {
+            name: e.label,
+            value: e.value
+          }
+        }),
+        calculateFormulas
+      }
     }
   }
 }

+ 1 - 0
src/views/workOrder/approval/index.vue

@@ -34,6 +34,7 @@ export default {
           status: 1
         })
         this.$message.success('审批通过')
+        this.$refs.indexPageRefs.onInit()
       } catch (error) {
         this.$message.error(error)
       }

+ 3 - 3
src/views/workOrder/components/IndexPage.vue

@@ -10,8 +10,8 @@
       :total="total"
       @page-change="onPageChange"
     >
-      <template #status="scope">
-        <el-tag size="small" :type="statusList[scope.$index].color">{{ statusList[scope.$index].text }}</el-tag>
+      <template #status="{ row }">
+        <el-tag size="small" :type="statusList[row.status].color">{{ statusList[row.status].text }}</el-tag>
       </template>
       <!-- <template #opType="{ row }">
         <el-tag size="small" :type="statusList[row.opType].color">{{ statusList[row.opType].text }}</el-tag>
@@ -45,7 +45,7 @@ export default {
   data () {
     return {
       statusList: [
-        { text: '开始', color: 'default' },
+        { text: '处理中', color: 'default' },
         { text: '审批通过', color: 'success' },
         { text: '审批拒绝', color: 'danger' },
         { text: '异常结束', color: 'warning' }