xieb
2025-01-21 d13cebe7fbadd396e91a989af331df8a8e7b40f8
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;