GuLiMmo
2024-01-15 d06209888a283de13d27a0513237a42b28524785
级别人员设置
4 files modified
159 ■■■■ changed files
src/api/evaluate/evaluateTask.js 11 ●●●●● patch | view | raw | blame | history
src/views/evaluate/components/IndividualTaskPublic.vue 70 ●●●● patch | view | raw | blame | history
src/views/evaluate/components/selectionDialog.vue 77 ●●●●● patch | view | raw | blame | history
src/views/evaluate/components/votingDetails.vue 1 ●●●● patch | view | raw | blame | history
src/api/evaluate/evaluateTask.js
@@ -194,4 +194,15 @@
      ids
    }
  })
}
// 获取当前级别人员
export const getEmployeeLevelList = (employeeType) => {
  return request({
    url: `/evaluate/evaluateTask/userListBy`,
    method: 'get',
    params: {
      employeeType
    }
  })
}
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">
    <el-dialog v-model="params.visible" :title="`发布评优任务(${params.data?.taskName || ''})`" width="65%" @open="openDialog"
        @close="dialogClose">
        <div class="content">
            <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,16 +29,19 @@
                            <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>
@@ -62,14 +67,14 @@
        <!-- 添加评优种类候选人 -->
        <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';
@@ -97,6 +102,7 @@
            form: {
                categoryEntities: [],
                pollingPersons: [],
                votePersonObjInfo: [],
                evaluateCutoffTimeStart: '',
                evaluateCutoffTimeEnd: ''
            },
@@ -122,6 +128,18 @@
            addEcCandidateParams: {},
            candidateResultParams: {},
            selectionParams: {}
        }
    },
    watch: {
        'params.visible': {
            handler(value) {
                if (!value) return
                this.form.pollingPersons = this.params.data.pollingPersons.split(',') || []
                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: {
@@ -159,8 +177,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 +195,41 @@
            }
        },
        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 params = {
                    employeeType: dictKey,
                    participateIn: data,
                    notParticipateIn: []
                }
                if (index === -1) {
                    this.form.votePersonObjInfo.push(params)
                } else {
                    this.form.votePersonObjInfo[index] = params
                }
            })
        },
        addEvaluateParams(params) {
            const index = this.form.votePersonObjInfo.findIndex(item => item.employeeType === params.employeeType)
            if (index === -1) {
                this.form.votePersonObjInfo.push(params)
                this.form.pollingPersons.push(params.employeeType)
            } else {
                this.form.votePersonObjInfo[index] = params
            }
        }
    }
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
        }
    },
    
src/views/evaluate/components/votingDetails.vue
@@ -209,6 +209,7 @@
        selectedChange(value) {
            this.onLoad(this.page);
        },
        dialogOpen() {}
    },
    watch: {
        'params.visible': {