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/IndividualTaskPublic.vue |  106 +++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 94 insertions(+), 12 deletions(-)

diff --git a/src/views/evaluate/components/IndividualTaskPublic.vue b/src/views/evaluate/components/IndividualTaskPublic.vue
index ca9bdf3..d773b87 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">
-        <div class="content">
+    <el-dialog v-model="params.visible" :title="`发布评优任务(${params.data?.taskName || ''})`" width="65%" @open="openDialog"
+        @close="dialogClose" destroy-on-close>
+        <div class="content" v-loading="isLoading" element-loading-text="数据加载中,请稍后。。。">
             <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,18 +29,27 @@
 
                             <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>
+                <el-form-item label="是否可以投选本部门成员" prop="isSelfDept">
+                    <el-radio-group v-model="form.isSelfDept">
+                        <el-radio :label="1" border>是</el-radio>
+                        <el-radio :label="0" border>否</el-radio>
+                    </el-radio-group>
                 </el-form-item>
                 <el-form-item label="第二轮任务结束时间" required>
                     <el-form-item class="time-box" prop="evaluateCutoffTimeStart">
@@ -55,21 +66,21 @@
         </div>
         <template #footer>
             <el-button @click="() => params.visible = false">取消</el-button>
-            <el-button type="primary" @click="taskPublic">确认发布</el-button>
+            <el-button type="primary" @click="taskPublic" :loading="isLoading">确认发布</el-button>
         </template>
         <!-- 查看第一轮候选结果 -->
         <candidateResult :params="candidateResultParams" />
         <!-- 添加评优种类候选人 -->
         <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';
@@ -93,10 +104,13 @@
     },
     data() {
         return {
+            isLoading: true,
             employeeDict: [],
             form: {
                 categoryEntities: [],
                 pollingPersons: [],
+                isSelfDept: 1,
+                votePersonObjInfo: [],
                 evaluateCutoffTimeStart: '',
                 evaluateCutoffTimeEnd: ''
             },
@@ -106,6 +120,9 @@
                 ],
                 pollingPersons: [
                     { required: true, message: '请选择评定人员', trigger: 'click' },
+                ],
+                isSelfDept: [
+                    { required: true, message: '请选择是否可以自选', trigger: 'click' },
                 ],
                 evaluateCutoffTimeStart: [
                     { required: true, message: '请选择任务开始时间', trigger: 'click' },
@@ -124,6 +141,24 @@
             selectionParams: {}
         }
     },
+    watch: {
+        'params.visible': {
+            handler(value) {
+                if (!value) return
+                console.log(this.params.data.pollingPersons);
+                const pollingPersons = this.params.data.pollingPersons
+                this.form.pollingPersons = pollingPersons !== "0" ? pollingPersons.split(',') : []
+                if (typeof this.params.data.votePersonObjInfo === 'object') {
+                    this.form.votePersonObjInfo = []
+                } else {
+                    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: {
         dialogClose() {
             this.$refs.formRef.resetFields()
@@ -136,6 +171,7 @@
                 const { code, data: { records } } = ecResult.data
                 if (code !== 200) return this.$message.error('评优类别加载失败')
                 this.form.categoryEntities = records
+                this.isLoading = false
             })
         },
         initDict() {
@@ -159,8 +195,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 +213,55 @@
             }
         },
         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 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