GuLiMmo
2024-01-15 d06209888a283de13d27a0513237a42b28524785
src/views/evaluate/components/selectionDialog.vue
@@ -1,7 +1,7 @@
<template>
    <el-dialog v-model="params.visible" :title="params.data?.dictValue || '人员选择'" @close="dialogClose">
    <el-dialog v-model="params.visible" :title="params.data?.dictValue || '人员选择'" destroy-on-close @close="dialogClose" @open="dialogOpen">
        <div class="container">
            <el-transfer v-model="value" :data="data" filterable filter-placeholder="请输入人员姓名"
            <el-transfer v-model="value" :data="userList" :props="{ label: 'realName', key: 'id' }" filterable filter-placeholder="请输入人员姓名"
                :titles="['参与投票人员', '不参与投票人员']" />
        </div>
        <template #footer>
@@ -12,6 +12,9 @@
</template>
<script>
import { getEmployeeLevelList } from '@/api/evaluate/evaluateTask'
import _ from 'lodash'
export default {
    props: {
        params: {
@@ -19,44 +22,66 @@
            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: []
        }
    },
    watch: {
        value: {
            handler(newVal) {
                this.notParticipateIn = []
                newVal.forEach(item => {
                    const is = this.userList.find(user => user.id === item)
                    this.notParticipateIn.push(is)
                })
            }
        },
        '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 => {
                this.userList = res.data.data
            })
        },
        submit() {
            console.log(this.value, this.data);
            this.userList.forEach(item => {
                const is = this.notParticipateIn.find(user => user.id === item.id)
                if (!is) {
                    this.participateIn.push(item)
                }
            })
            const params = {
                employeeType: this.params.data.dictKey,
                participateIn: this.participateIn,
                notParticipateIn: this.notParticipateIn
            }
            this.$emit('addEvaluateParams', params)
            this.params.visible = false
        }
    },