From 9fc6db6472b1b8a5e8b78849b9a363d2cb5eb0ee Mon Sep 17 00:00:00 2001
From: GuLiMmo <2820890765@qq.com>
Date: Mon, 15 Jan 2024 16:09:02 +0800
Subject: [PATCH] 更新

---
 src/views/evaluate/components/editSectionTask.vue |   81 ++++++++++++++++++++++++++++++++++++----
 1 files changed, 73 insertions(+), 8 deletions(-)

diff --git a/src/views/evaluate/components/editSectionTask.vue b/src/views/evaluate/components/editSectionTask.vue
index 74027f0..b1ed574 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,6 +39,8 @@
             <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>
 
@@ -43,9 +48,13 @@
 import { getDict } from '@/api/dict'
 import { update } 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,8 @@
                     }
                 ]
             },
-            employeeDict: []
+            employeeDict: [],
+            selectionParams: {}
         }
     },
     methods: {
@@ -131,16 +142,18 @@
         },
         openDialog() {
             this.initDict()
-            const { id, taskName, evaluateAwards, identificationStandard, pollingPersons, evaluateCutoffTimeStart, evaluateCutoffTimeEnd } = this.params.data
+            const { id, taskName, evaluateAwards, identificationStandard, pollingPersons, votePersonObjInfo, evaluateCutoffTimeStart, evaluateCutoffTimeEnd } = this.params.data
             this.form = {
                 id,
-                taskName, 
-                evaluateAwards, 
-                identificationStandard, 
-                pollingPersons: pollingPersons.split(','), 
-                evaluateCutoffTimeStart, 
+                taskName,
+                evaluateAwards,
+                identificationStandard,
+                pollingPersons: pollingPersons.split(',') || [],
+                votePersonObjInfo: JSON.parse(votePersonObjInfo) || [],
+                evaluateCutoffTimeStart,
                 evaluateCutoffTimeEnd
             }
+            console.log(this.form);
         },
         submit() {
             this.$refs.formRef.validate(vaild => {
@@ -164,6 +177,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