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/selectionDialog.vue |  101 +++++++++++++++++++++++++++++++++++---------------
 1 files changed, 71 insertions(+), 30 deletions(-)

diff --git a/src/views/evaluate/components/selectionDialog.vue b/src/views/evaluate/components/selectionDialog.vue
index 31a9a76..9faae04 100644
--- a/src/views/evaluate/components/selectionDialog.vue
+++ b/src/views/evaluate/components/selectionDialog.vue
@@ -1,17 +1,21 @@
 <template>
-    <el-dialog v-model="params.visible" :title="params.data?.dictValue || '人员选择'" @close="dialogClose">
-        <div class="container">
-            <el-transfer v-model="value" :data="data" filterable filter-placeholder="请输入人员姓名"
-                :titles="['参与投票人员', '不参与投票人员']" />
+    <el-dialog v-model="params.visible" :title="params.data?.dictValue || '人员选择'" destroy-on-close @close="dialogClose"
+        @open="dialogOpen">
+        <div class="container" v-loading="isLoading" element-loading-text="数据加载中,请稍后。。。">
+            <el-transfer v-model="value" :data="userList" :props="{ label: 'realName', key: 'id' }" filterable
+                filter-placeholder="请输入人员姓名" :titles="['参与投票人员', '不参与投票人员']" />
         </div>
         <template #footer>
             <el-button @click="params.visible = false">取消</el-button>
-            <el-button type="primary" @click="submit">确认选择</el-button>
+            <el-button type="primary" @click="submit" :loading="isLoading">确认选择</el-button>
         </template>
     </el-dialog>
 </template>
 
 <script>
+import { getEmployeeLevelList } from '@/api/evaluate/evaluateTask'
+import _ from 'lodash'
+
 export default {
     props: {
         params: {
@@ -19,47 +23,83 @@
             default: () => {
                 return {
                     visible: false,
-                    data: {}
+                    data: {},
+                    values: {}
                 }
             }
         }
     },
     data() {
         return {
+            userList: [],
             value: [],
-            data: [
-                {
-                    label: '张三',
-                    key: '1'
-                },
-                {
-                    label: '李四',
-                    key: '2'
-                },
-                {
-                    label: '王五',
-                    key: '3'
-                },
-                {
-                    label: '赵六',
-                    key: '4'
-                },
-                {
-                    label: '刘七',
-                    key: '5'
-                }
-            ]
+            notParticipateIn: [],
+            participateIn: [],
+            isLoading: true,
+        }
+    },
+    watch: {
+        value: {
+            handler(newVal) {
+                this.notParticipateIn = []
+                newVal.forEach(item => {
+                    const is = this.userList.find(user => user.id === item)
+                    const { id, name, deptId, deptName, postId, postName } = is
+                    this.notParticipateIn.push({ id, name, deptId, deptName, postId, postName })
+                })
+            }
+        },
+        'params.visible': {
+            handler(newVal) {
+                if (!newVal) return
+                const notParticipateIn = _.cloneDeep(this.params.values.notParticipateIn)
+                if (!notParticipateIn) return
+                notParticipateIn.forEach(user => {
+                    this.value.push(user.id)
+                })
+            },
+            deep: true
         }
     },
     methods: {
         dialogClose() {
             this.value = []
         },
+        dialogOpen() {
+            const { dictKey } = this.params.data
+            getEmployeeLevelList(dictKey).then(res => {
+                if (res.data.code !== 200) return this.$message.error('数据加载失败,请关闭窗口后重试!!')
+                this.userList = res.data.data
+                this.isLoading = false
+            })
+        },
         submit() {
-            console.log(this.value, this.data);
+            this.participateIn = []
+            this.userList.forEach(item => {
+                const is = this.notParticipateIn.find(user => user.id === item.id)
+                if (!is) {
+                    const { id, name, deptId, deptName, postId, postName } = item
+                    this.participateIn.push({ id, name, deptId, deptName, postId, postName })
+                }
+            })
+            const params = {
+                employeeType: this.params.data.dictKey,
+                participateIn: this.participateIn,
+                notParticipateIn: this.notParticipateIn
+            }
+            this.$confirm('是否确认选择当前投票人员?', {
+                confirmButtonText: '确定',
+                cancelButtonText: '取消',
+                type: 'warning',
+            }).then(() => {
+                this.$emit('addEvaluateParams', params)
+                this.params.visible = false
+                this.$message.success('设置投票人员成功')
+            })
+
         }
     },
-    
+
 }
 </script>
 
@@ -69,6 +109,7 @@
     justify-content: center;
     align-items: center;
 }
+
 :deep() {
     .el-transfer-panel {
         width: 250px;

--
Gitblit v1.9.3