From d13cebe7fbadd396e91a989af331df8a8e7b40f8 Mon Sep 17 00:00:00 2001
From: xieb <vip_xiaobin810@163.com>
Date: Tue, 21 Jan 2025 11:40:42 +0800
Subject: [PATCH] 考核结果查看详情

---
 src/views/evaluate/components/editSectionTask.vue |  118 ++++++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 104 insertions(+), 14 deletions(-)

diff --git a/src/views/evaluate/components/editSectionTask.vue b/src/views/evaluate/components/editSectionTask.vue
index 74027f0..0273835 100644
--- a/src/views/evaluate/components/editSectionTask.vue
+++ b/src/views/evaluate/components/editSectionTask.vue
@@ -1,6 +1,6 @@
 <template>
     <el-dialog v-model="params.visible" :title="params.title || '编辑部门评优任务'" width="50%" @open="openDialog"
-        @close="dialogClose">
+        @close="dialogClose" destroy-on-close>
         <div class="content">
             <el-form :model="form" ref="formRef" :rules="rules" label-width="130px">
                 <el-form-item label="任务名称" prop="taskName">
@@ -14,8 +14,11 @@
                 </el-form-item>
                 <el-form-item label="投票人员" prop="pollingPersons">
                     <el-checkbox-group v-model="form.pollingPersons">
-                        <el-checkbox v-for="item in employeeDict" :key="item.id" :label="item.dictKey">
+                        <el-checkbox v-for="item in employeeDict" :key="item.id" :label="item.dictKey"
+                            @change="checkBoxChange($event, item)">
                             {{ item.dictValue }}
+                            <el-button type="primary" icon="el-icon-edit" text
+                                @click="selectionHandler(item)">设置人员</el-button>
                         </el-checkbox>
                     </el-checkbox-group>
                 </el-form-item>
@@ -36,16 +39,22 @@
             <el-button @click="() => params.visible = false">取消</el-button>
             <el-button type="primary" @click="submit">确定</el-button>
         </template>
+        <!-- 人员选择 -->
+        <selectionDialog :params="selectionParams" @addEvaluateParams="addEvaluateParams" />
     </el-dialog>
 </template>
 
 <script>
 import { getDict } from '@/api/dict'
-import { update } from '@/api/evaluate/evaluateTask'
+import { update, getEmployeeLevelList } from '@/api/evaluate/evaluateTask'
 import _ from 'lodash';
+import selectionDialog from './selectionDialog.vue';
 
 export default {
     inject: ['type'],
+    components: {
+        selectionDialog
+    },
     props: {
         params: {
             type: Object,
@@ -66,6 +75,7 @@
                 evaluateAwards: '',
                 identificationStandard: '',
                 pollingPersons: [],
+                votePersonObjInfo: [],
                 evaluateCutoffTimeStart: '',
                 evaluateCutoffTimeEnd: ''
             },
@@ -122,7 +132,26 @@
                     }
                 ]
             },
-            employeeDict: []
+            employeeDict: [],
+            selectionParams: {}
+        }
+    },
+    watch: {
+        'params.visible': {
+            handler(val) {
+                if (!val) return
+                const { id, taskName, evaluateAwards, identificationStandard, pollingPersons, votePersonObjInfo, evaluateCutoffTimeStart, evaluateCutoffTimeEnd } = this.params.data
+                this.form.id = id
+                this.form.taskName = taskName
+                this.form.evaluateAwards = evaluateAwards
+                this.form.identificationStandard = identificationStandard
+                this.form.pollingPersons = pollingPersons.split(',') || []
+                this.form.votePersonObjInfo = JSON.parse(votePersonObjInfo) || []
+                this.form.evaluateCutoffTimeStart = evaluateCutoffTimeStart
+                this.form.evaluateCutoffTimeEnd = evaluateCutoffTimeEnd
+                console.log('编辑回显');
+            },
+            deep: true
         }
     },
     methods: {
@@ -131,16 +160,25 @@
         },
         openDialog() {
             this.initDict()
-            const { id, taskName, evaluateAwards, identificationStandard, pollingPersons, evaluateCutoffTimeStart, evaluateCutoffTimeEnd } = this.params.data
-            this.form = {
-                id,
-                taskName, 
-                evaluateAwards, 
-                identificationStandard, 
-                pollingPersons: pollingPersons.split(','), 
-                evaluateCutoffTimeStart, 
-                evaluateCutoffTimeEnd
-            }
+            // const { id, taskName, evaluateAwards, identificationStandard, pollingPersons, votePersonObjInfo, evaluateCutoffTimeStart, evaluateCutoffTimeEnd } = this.params.data
+            // this.form.id = id
+            // this.form.taskName = taskName
+            // this.form.evaluateAwards = evaluateAwards
+            // this.form.identificationStandard = identificationStandard
+            // this.form.pollingPersons = pollingPersons.split(',') || []
+            // this.form.votePersonObjInfo = JSON.parse(votePersonObjInfo) || []
+            // this.form.evaluateCutoffTimeStart = evaluateCutoffTimeStart
+            // this.form.evaluateCutoffTimeEnd = evaluateCutoffTimeEnd
+            // this.form = {
+            //     id,
+            //     taskName,
+            //     evaluateAwards,
+            //     identificationStandard,
+            //     pollingPersons: pollingPersons.split(',') || [],
+            //     votePersonObjInfo: JSON.parse(votePersonObjInfo) || [],
+            //     evaluateCutoffTimeStart,
+            //     evaluateCutoffTimeEnd
+            // }
         },
         submit() {
             this.$refs.formRef.validate(vaild => {
@@ -164,6 +202,58 @@
                 }
                 this.employeeDict = data
             })
+        },
+        selectionHandler(row) {
+            const obj = this.form.votePersonObjInfo.find(item => item.employeeType === row.dictKey) || {}
+            this.selectionParams = {
+                visible: true,
+                data: row,
+                values: obj
+            }
+        },
+        checkBoxChange(e, { dictKey }) {
+            const index = this.form.votePersonObjInfo.findIndex(item => item.employeeType === dictKey)
+            if (!e) {
+                this.form.votePersonObjInfo.splice(index, 1)
+                return
+            }
+            getEmployeeLevelList(dictKey).then((res) => {
+                const { code, data } = res.data
+                if (code !== 200) return this.$message.error('当前级别人员加载失败,请重试!!')
+                const participateInList = data.map(item => {
+                    const { id, name, deptId, deptName, postId, postName } = item
+                    return { id, name, deptId, deptName, postId, postName }
+                })
+                const params = {
+                    employeeType: dictKey,
+                    participateIn: participateInList,
+                    notParticipateIn: []
+                }
+                if (index === -1) {
+                    this.form.votePersonObjInfo.push(params)
+                } else {
+                    this.form.votePersonObjInfo[index] = params
+                }
+            })
+        },
+        addEvaluateParams(params) {
+            const { participateIn, employeeType } = params
+            const index = this.form.votePersonObjInfo.findIndex(item => item.employeeType === employeeType)
+            const typeIndex = this.form.pollingPersons.findIndex(item => item === employeeType)
+
+            if (index === -1) {
+                if (participateIn.length > 0) {
+                    this.form.votePersonObjInfo.push(params)
+                    this.form.pollingPersons.push(params.employeeType)
+                }
+            } else {
+                if (participateIn.length > 0) {
+                    this.form.votePersonObjInfo[index] = params
+                } else {
+                    this.form.votePersonObjInfo.splice(index, 1)
+                    this.form.pollingPersons.splice(typeIndex, 1)
+                }
+            }
         }
     }
 };

--
Gitblit v1.9.3