From d06209888a283de13d27a0513237a42b28524785 Mon Sep 17 00:00:00 2001
From: GuLiMmo <2820890765@qq.com>
Date: Mon, 15 Jan 2024 11:21:19 +0800
Subject: [PATCH] 级别人员设置

---
 src/views/evaluate/components/IndividualTaskPublic.vue |   70 ++++++++++++++++++++++++++++++-----
 1 files changed, 60 insertions(+), 10 deletions(-)

diff --git a/src/views/evaluate/components/IndividualTaskPublic.vue b/src/views/evaluate/components/IndividualTaskPublic.vue
index ca9bdf3..9be1cfb 100644
--- a/src/views/evaluate/components/IndividualTaskPublic.vue
+++ b/src/views/evaluate/components/IndividualTaskPublic.vue
@@ -1,11 +1,13 @@
 <template>
-    <el-dialog v-model="params.visible" :title="`发布评优任务(${params.data?.taskName || ''})`" width="65%" @open="openDialog" @close="dialogClose">
+    <el-dialog v-model="params.visible" :title="`发布评优任务(${params.data?.taskName || ''})`" width="65%" @open="openDialog"
+        @close="dialogClose">
         <div class="content">
             <el-form :model="form" ref="formRef" :rules="rules" label-position="top">
                 <el-form-item prop="categoryEntities">
                     <template #label>
                         评优奖项
-                        <el-button type="primary" icon="el-icon-view" text @click="viewCandidateResult">查看第一轮候选结果</el-button>
+                        <el-button type="primary" icon="el-icon-view" text
+                            @click="viewCandidateResult">查看第一轮候选结果</el-button>
                     </template>
                     <ul class="type-list">
                         <li class="type-item">
@@ -27,16 +29,19 @@
 
                             <div class="number">{{ item.peopleNum }}</div>
                             <div class="tool">
-                               <el-button type="primary" icon="el-icon-plus" text @click="addEcCandidateHandler(item)">添加候选人</el-button>
+                                <el-button type="primary" icon="el-icon-plus" text
+                                    @click="addEcCandidateHandler(item)">添加候选人</el-button>
                             </div>
                         </li>
                     </ul>
                 </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-button type="primary" icon="el-icon-edit" text
+                                @click="selectionHandler(item)">设置人员</el-button>
                         </el-checkbox>
                     </el-checkbox-group>
                 </el-form-item>
@@ -62,14 +67,14 @@
         <!-- 添加评优种类候选人 -->
         <addEcCandidate :params="addEcCandidateParams" />
         <!-- 人员选择 -->
-        <selectionDialog :params="selectionParams"  />
+        <selectionDialog :params="selectionParams" @addEvaluateParams="addEvaluateParams" />
     </el-dialog>
 </template>
 
 <script>
 import _ from 'lodash';
 import { getDict } from '@/api/dict'
-import { update, getEcList } from '@/api/evaluate/evaluateTask'
+import { update, getEcList, getEmployeeLevelList } from '@/api/evaluate/evaluateTask'
 import addEcCandidate from './addEcCandidate.vue';
 import candidateResult from './candidateResult.vue';
 import selectionDialog from './selectionDialog.vue';
@@ -97,6 +102,7 @@
             form: {
                 categoryEntities: [],
                 pollingPersons: [],
+                votePersonObjInfo: [],
                 evaluateCutoffTimeStart: '',
                 evaluateCutoffTimeEnd: ''
             },
@@ -122,6 +128,18 @@
             addEcCandidateParams: {},
             candidateResultParams: {},
             selectionParams: {}
+        }
+    },
+    watch: {
+        'params.visible': {
+            handler(value) {
+                if (!value) return
+                this.form.pollingPersons = this.params.data.pollingPersons.split(',') || []
+                this.form.votePersonObjInfo = JSON.parse(this.params.data.votePersonObjInfo) || []
+                this.form.evaluateCutoffTimeStart = this.params.data.evaluateCutoffTimeStart || ''
+                this.form.evaluateCutoffTimeEnd = this.params.data.evaluateCutoffTimeEnd || ''
+            },
+            deep: true
         }
     },
     methods: {
@@ -159,8 +177,8 @@
                 delete data.categoryEntities
                 update(data).then(res => {
                     if (res.data.code !== 200) return
-                    this.params.visible = false 
-                    this.$emit('refreshTable', { currentPage:1, pageSize: 10 })
+                    this.params.visible = false
+                    this.$emit('refreshTable', { currentPage: 1, pageSize: 10 })
                 })
             })
         },
@@ -177,9 +195,41 @@
             }
         },
         selectionHandler(row) {
+            const obj = this.form.votePersonObjInfo.find(item => item.employeeType === row.dictKey) || {}
             this.selectionParams = {
                 visible: true,
-                data: row
+                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 params = {
+                    employeeType: dictKey,
+                    participateIn: data,
+                    notParticipateIn: []
+                }
+                if (index === -1) {
+                    this.form.votePersonObjInfo.push(params)
+                } else {
+                    this.form.votePersonObjInfo[index] = params
+                }
+            })
+        },
+        addEvaluateParams(params) {
+            const index = this.form.votePersonObjInfo.findIndex(item => item.employeeType === params.employeeType)
+            if (index === -1) {
+                this.form.votePersonObjInfo.push(params)
+                this.form.pollingPersons.push(params.employeeType)
+            } else {
+                this.form.votePersonObjInfo[index] = params
             }
         }
     }

--
Gitblit v1.9.3