| | |
| | | </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> |
| | | <el-form-item label="投票时间" required> |
| | | <el-form-item class="time-box" prop="candidateCutoffTimeStart"> |
| | | <el-date-picker v-model="form.candidateCutoffTimeStart" type="datetime" placeholder="请选择任务开始时间" |
| | | <el-form-item class="time-box" prop="evaluateCutoffTimeStart"> |
| | | <el-date-picker v-model="form.evaluateCutoffTimeStart" type="datetime" placeholder="请选择任务开始时间" |
| | | value-format="YYYY-MM-DD HH:mm:ss" style="width: 100%;" /> |
| | | </el-form-item> |
| | | <span class="time-span">至</span> |
| | | <el-form-item class="time-box" prop="candidateCutoffTimeEnd"> |
| | | <el-date-picker v-model="form.candidateCutoffTimeEnd" type="datetime" placeholder="请选择任务结束时间" |
| | | <el-form-item class="time-box" prop="evaluateCutoffTimeEnd"> |
| | | <el-date-picker v-model="form.evaluateCutoffTimeEnd" type="datetime" placeholder="请选择任务结束时间" |
| | | value-format="YYYY-MM-DD HH:mm:ss" style="width: 100%;" /> |
| | | </el-form-item> |
| | | </el-form-item> |
| | |
| | | <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> |
| | | |
| | | <script> |
| | | import { getDict } from '@/api/dict' |
| | | import { add } from '@/api/evaluate/evaluateTask' |
| | | import { update, getEmployeeLevelList } from '@/api/evaluate/evaluateTask' |
| | | import _ from 'lodash'; |
| | | import selectionDialog from './selectionDialog.vue'; |
| | | |
| | | export default { |
| | | inject: ['type'], |
| | | components: { |
| | | selectionDialog |
| | | }, |
| | | props: { |
| | | params: { |
| | | type: Object, |
| | |
| | | evaluateAwards: '', |
| | | identificationStandard: '', |
| | | pollingPersons: [], |
| | | candidateCutoffTimeStart: '', |
| | | candidateCutoffTimeEnd: '' |
| | | votePersonObjInfo: [], |
| | | evaluateCutoffTimeStart: '', |
| | | evaluateCutoffTimeEnd: '' |
| | | }, |
| | | rules: { |
| | | taskName: [ |
| | |
| | | pollingPersons: [ |
| | | { required: true, message: '请选择评定人员', trigger: 'click' }, |
| | | ], |
| | | candidateCutoffTimeStart: [ |
| | | evaluateCutoffTimeStart: [ |
| | | { required: true, message: '请选择任务开始时间', trigger: 'click' }, |
| | | { |
| | | validator: (rule, value, callback) => { |
| | |
| | | const startTime = new Date(value).getTime() |
| | | const endTime = new Date(this.form.candidateCutoffTimeEnd).getTime() |
| | | const nowTime = new Date().getTime() |
| | | if (nowTime > startTime) { |
| | | callback(new Error('开始时间不能早于当前时间')) |
| | | } else if (startTime >= endTime) { |
| | | // if (nowTime > startTime) { |
| | | // callback(new Error('开始时间不能早于当前时间')) |
| | | // } else |
| | | if (startTime >= endTime) { |
| | | callback(new Error('结束时间不能早于等于开始时间')) |
| | | } else { |
| | | callback() |
| | |
| | | }, trigger: 'click' |
| | | } |
| | | ], |
| | | candidateCutoffTimeEnd: [ |
| | | evaluateCutoffTimeEnd: [ |
| | | { required: true, message: '请选择任务开始时间', trigger: 'click' }, |
| | | { |
| | | validator: (rule, value, callback) => { |
| | |
| | | const startTime = new Date(this.form.candidateCutoffTimeStart).getTime() |
| | | const endTime = new Date(value).getTime() |
| | | const nowTime = new Date().getTime() |
| | | if (nowTime > endTime) { |
| | | callback(new Error('结束时间不能早于等于当前时间')) |
| | | } else if (startTime >= endTime) { |
| | | // if (nowTime > endTime) { |
| | | // callback(new Error('结束时间不能早于等于当前时间')) |
| | | // } else |
| | | if (startTime >= endTime) { |
| | | callback(new Error('结束时间不能早于等于开始时间')) |
| | | } else { |
| | | callback() |
| | |
| | | } |
| | | ] |
| | | }, |
| | | employeeDict: [] |
| | | employeeDict: [], |
| | | selectionParams: {} |
| | | } |
| | | }, |
| | | methods: { |
| | |
| | | if (!vaild) return |
| | | const data = _.cloneDeep(this.form) |
| | | data.pollingPersons = data.pollingPersons.join(',') |
| | | add(data).then(res => { |
| | | data.type = this.type() |
| | | update(data).then(res => { |
| | | if (res.data.code !== 200) return |
| | | this.params.visible = false |
| | | this.$emit('refreshTable', { currentPage: 1, pageSize: 10 }) |
| | |
| | | } |
| | | 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) |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }; |