GuLiMmo
2024-01-15 9fc6db6472b1b8a5e8b78849b9a363d2cb5eb0ee
src/views/evaluate/components/addSectionTask.vue
@@ -13,8 +13,11 @@
                </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-checkbox>
                    </el-checkbox-group>
                </el-form-item>
@@ -35,6 +38,8 @@
            <el-button @click="() => params.visible = false">取消</el-button>
            <el-button type="primary" @click="submit">确定</el-button>
        </template>
        <!-- 人员选择 -->
        <selectionDialog :params="selectionParams" @addEvaluateParams="addEvaluateParams" />
    </el-dialog>
</template>
@@ -42,9 +47,13 @@
import { getDict } from '@/api/dict'
import { update } from '@/api/evaluate/evaluateTask'
import _ from 'lodash';
import selectionDialog from './selectionDialog.vue';
export default {
    inject: ['type'],
    components: {
        selectionDialog
    },
    props: {
        params: {
            type: Object,
@@ -65,6 +74,7 @@
                evaluateAwards: '',
                identificationStandard: '',
                pollingPersons: [],
                votePersonObjInfo: [],
                evaluateCutoffTimeStart: '',
                evaluateCutoffTimeEnd: ''
            },
@@ -122,7 +132,8 @@
                    }
                ]
            },
            employeeDict: []
            employeeDict: [],
            selectionParams: {}
        }
    },
    methods: {
@@ -153,6 +164,58 @@
                }
                this.employeeDict = data
            })
        },
        selectionHandler(row) {
            const obj = this.form.votePersonObjInfo.find(item => item.employeeType === row.dictKey) || {}
            this.selectionParams = {
                visible: true,
                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 participateInList = data.map(item => {
                    const { id, name, deptId, deptName, postId, postName } = item
                    return { id, name, deptId, deptName, postId, postName }
                })
                const params = {
                    employeeType: dictKey,
                    participateIn: participateInList,
                    notParticipateIn: []
                }
                if (index === -1) {
                    this.form.votePersonObjInfo.push(params)
                } else {
                    this.form.votePersonObjInfo[index] = params
                }
            })
        },
        addEvaluateParams(params) {
            const { participateIn, employeeType } = params
            const index = this.form.votePersonObjInfo.findIndex(item => item.employeeType === employeeType)
            const typeIndex = this.form.pollingPersons.findIndex(item => item === employeeType)
            if (index === -1) {
                if (participateIn.length > 0) {
                    this.form.votePersonObjInfo.push(params)
                    this.form.pollingPersons.push(params.employeeType)
                }
            } else {
                if (participateIn.length > 0) {
                    this.form.votePersonObjInfo[index] = params
                } else {
                    this.form.votePersonObjInfo.splice(index, 1)
                    this.form.pollingPersons.splice(typeIndex, 1)
                }
            }
        }
    }
};