From 4d0faee6a7f372e01ae494e8a4a6a28521e0199f Mon Sep 17 00:00:00 2001
From: GuLiMmo <2820890765@qq.com>
Date: Sat, 20 Jan 2024 16:53:03 +0800
Subject: [PATCH] update

---
 src/views/evaluate/components/editSectionTask.vue |  116 +++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 103 insertions(+), 13 deletions(-)

diff --git a/src/views/evaluate/components/editSectionTask.vue b/src/views/evaluate/components/editSectionTask.vue
index 74027f0..a8405a4 100644
--- a/src/views/evaluate/components/editSectionTask.vue
+++ b/src/views/evaluate/components/editSectionTask.vue
@@ -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