xieb
2025-01-21 d13cebe7fbadd396e91a989af331df8a8e7b40f8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<template>
    <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" :loading="isLoading">确认选择</el-button>
        </template>
    </el-dialog>
</template>
 
<script>
import { getEmployeeLevelList } from '@/api/evaluate/evaluateTask'
import _ from 'lodash'
 
export default {
    props: {
        params: {
            type: Object,
            default: () => {
                return {
                    visible: false,
                    data: {},
                    values: {}
                }
            }
        }
    },
    data() {
        return {
            userList: [],
            value: [],
            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() {
            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>
 
<style lang="scss" scoped>
.container {
    display: flex;
    justify-content: center;
    align-items: center;
}
 
:deep() {
    .el-transfer-panel {
        width: 250px;
    }
}
</style>