|
|
|
@ -1,31 +1,55 @@ |
|
|
|
|
<template> |
|
|
|
|
<Dialog :title="title" v-model="show" width="800px"> |
|
|
|
|
<el-form v-loading="formLoading" :model="form" ref="formRef" :rules="rules" label-width="80px"> |
|
|
|
|
<el-row :gutter="20"> |
|
|
|
|
<el-col :span="12" :offset="0"> |
|
|
|
|
<el-form-item label="考核指标" prop="examineTarget"> |
|
|
|
|
<el-input v-model="form.examineTarget" placeholder="请输入" /> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-col> |
|
|
|
|
<el-col :span="12" :offset="0"> |
|
|
|
|
<el-form-item label="生效日期" prop="effectiveDate"> |
|
|
|
|
<el-date-picker |
|
|
|
|
v-model="form.effectiveDate" |
|
|
|
|
type="date" |
|
|
|
|
format="YYYY-MM-DD" |
|
|
|
|
value-format="YYYY-MM-DD" |
|
|
|
|
placeholder="选择日期时间" |
|
|
|
|
/> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-col> |
|
|
|
|
</el-row> |
|
|
|
|
<el-row :gutter="20"> |
|
|
|
|
<el-col :span="24" :offset="0"> |
|
|
|
|
<el-form-item label="考核指标" prop="name"> |
|
|
|
|
<el-input v-model="form.name" placeholder="请输入" /> |
|
|
|
|
<el-form-item label="模式" prop="type"> |
|
|
|
|
<el-radio-group v-model="form.type"> |
|
|
|
|
<el-radio :label="1"> 加总分 </el-radio> |
|
|
|
|
<el-radio :label="2"> 加权重分 </el-radio> |
|
|
|
|
<el-radio :label="3"> 减总分 </el-radio> |
|
|
|
|
<el-radio :label="4"> 减权重分 </el-radio> |
|
|
|
|
</el-radio-group> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-col> |
|
|
|
|
</el-row> |
|
|
|
|
|
|
|
|
|
<el-row :gutter="20"> |
|
|
|
|
<el-col :span="12" :offset="0"> |
|
|
|
|
<el-form-item label="权重" prop="rate"> |
|
|
|
|
<el-input-number v-model="form.rate" :min="0" :step="1" :controls="false" /> |
|
|
|
|
<el-form-item label="权重" prop="weight"> |
|
|
|
|
<el-input-number v-model="form.weight" :min="0" :step="1" :controls="false" /> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-col> |
|
|
|
|
<el-col :span="12" :offset="0"> |
|
|
|
|
<el-form-item label="评分上限" prop="maxScore"> |
|
|
|
|
<el-input-number v-model="form.maxScore" :min="0" :step="1" :controls="false" /> |
|
|
|
|
<el-form-item label="评分上限" prop="examineScore"> |
|
|
|
|
<el-input-number v-model="form.examineScore" :min="0" :step="1" :controls="false" /> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-col> |
|
|
|
|
</el-row> |
|
|
|
|
|
|
|
|
|
<el-row :gutter="20"> |
|
|
|
|
<el-col :span="24" :offset="0"> |
|
|
|
|
<el-form-item label="考核内容" prop="kaoheneirong"> |
|
|
|
|
<el-form-item label="考核内容" prop="examineContent"> |
|
|
|
|
<Editor |
|
|
|
|
v-model:modelValue="form.kaoheneirong" |
|
|
|
|
v-model:modelValue="form.examineContent" |
|
|
|
|
height="150px" |
|
|
|
|
:toolbarConfig="{ |
|
|
|
|
toolbarKeys: [] |
|
|
|
@ -37,9 +61,9 @@ |
|
|
|
|
</el-row> |
|
|
|
|
<el-row :gutter="20"> |
|
|
|
|
<el-col :span="24" :offset="0"> |
|
|
|
|
<el-form-item label="考核规则" prop="kaoheguize"> |
|
|
|
|
<el-form-item label="考核规则" prop="examineRule"> |
|
|
|
|
<Editor |
|
|
|
|
v-model:modelValue="form.kaoheguize" |
|
|
|
|
v-model:modelValue="form.examineRule" |
|
|
|
|
height="150px" |
|
|
|
|
:toolbarConfig="{ toolbarKeys: [] }" |
|
|
|
|
style="width: 100%" |
|
|
|
@ -49,7 +73,7 @@ |
|
|
|
|
</el-row> |
|
|
|
|
<el-row :gutter="20"> |
|
|
|
|
<el-col :span="24" :offset="0"> |
|
|
|
|
<el-form-item label="考核员工" prop="checkEmployees"> |
|
|
|
|
<el-form-item label="考核员工" prop="examinedUserIdList"> |
|
|
|
|
<div> |
|
|
|
|
<el-checkbox |
|
|
|
|
v-model="checkAll" |
|
|
|
@ -58,10 +82,11 @@ |
|
|
|
|
> |
|
|
|
|
全选 |
|
|
|
|
</el-checkbox> |
|
|
|
|
<el-checkbox-group v-model="form.checkEmployees" @change="handleCheckedChange"> |
|
|
|
|
<el-checkbox-group v-model="form.examinedUserIdList" @change="handleCheckedChange"> |
|
|
|
|
<el-checkbox |
|
|
|
|
v-for="item in employeeOptions" |
|
|
|
|
:key="item.id" |
|
|
|
|
:disabled="item.status == 1" |
|
|
|
|
:label="item.id" |
|
|
|
|
:value="item.id" |
|
|
|
|
> |
|
|
|
@ -83,7 +108,7 @@ |
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
<script setup name="DialogAppraise"> |
|
|
|
|
// import * as ResourceApi from '@/api/system/library/resource' |
|
|
|
|
import * as KpiApi from '@/api/kpi/index.js' |
|
|
|
|
|
|
|
|
|
const { t } = useI18n() // 国际化 |
|
|
|
|
const message = useMessage() // 消息弹窗 |
|
|
|
@ -95,9 +120,10 @@ const formType = ref('create') |
|
|
|
|
const form = ref({}) |
|
|
|
|
const formLoading = ref(false) |
|
|
|
|
const rules = ref({ |
|
|
|
|
name: { required: true, message: '标题不可为空', trigger: 'blur' }, |
|
|
|
|
kaoheneirong: { required: true, message: '标题不可为空', trigger: 'blur' }, |
|
|
|
|
kaoheguize: { required: true, message: '标题不可为空', trigger: 'blur' } |
|
|
|
|
examineTarget: { required: true, message: '标题不可为空', trigger: 'blur' }, |
|
|
|
|
effectiveDate: { required: true, message: '生效日期不可为空', trigger: 'blur,change' }, |
|
|
|
|
examineContent: { required: true, message: '标题不可为空', trigger: 'blur' }, |
|
|
|
|
examineRule: { required: true, message: '标题不可为空', trigger: 'blur' } |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
async function open(type, val) { |
|
|
|
@ -105,28 +131,36 @@ async function open(type, val) { |
|
|
|
|
title.value = type == 'update' ? '修改考核项' : '新增考核项' |
|
|
|
|
formType.value = type |
|
|
|
|
resetForm() |
|
|
|
|
if (val?.id) { |
|
|
|
|
if (val) { |
|
|
|
|
formLoading.value = true |
|
|
|
|
try { |
|
|
|
|
// form.value = await ResourceApi.getResource(id) |
|
|
|
|
form.value = await KpiApi.getKpiDetail(val) |
|
|
|
|
} finally { |
|
|
|
|
formLoading.value = false |
|
|
|
|
} |
|
|
|
|
} else if (val.name) { |
|
|
|
|
form.value = { ...val } |
|
|
|
|
} |
|
|
|
|
const checkedCount = form.value.checkEmployees?.length || 0 |
|
|
|
|
getOptions() |
|
|
|
|
const checkedCount = form.value.examinedUserIdList?.length || 0 |
|
|
|
|
isIndeterminate.value = checkedCount > 0 && checkedCount < employeeOptions.value.length |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function getOptions() { |
|
|
|
|
KpiApi.getKpiEmployees().then((data) => { |
|
|
|
|
employeeOptions.value = data |
|
|
|
|
handleCheckAllChange(true) |
|
|
|
|
checkAll.value = true |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function resetForm() { |
|
|
|
|
form.value = { |
|
|
|
|
name: '', |
|
|
|
|
rate: 0, |
|
|
|
|
kaoheneirong: ``, |
|
|
|
|
kaoheguize: ``, |
|
|
|
|
maxScore: 5, |
|
|
|
|
checkEmployees: [] |
|
|
|
|
examineTarget: '', |
|
|
|
|
type: 4, |
|
|
|
|
weight: 0, |
|
|
|
|
examineContent: ``, |
|
|
|
|
examineRule: ``, |
|
|
|
|
examineScore: 5, |
|
|
|
|
examinedUserIdList: [] |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -145,15 +179,15 @@ async function handleSave() { |
|
|
|
|
formLoading.value = true |
|
|
|
|
try { |
|
|
|
|
if (formType.value === 'create') { |
|
|
|
|
// await ResourceApi.createResource(form.value) |
|
|
|
|
await KpiApi.createKpi(form.value) |
|
|
|
|
message.success(t('common.createSuccess')) |
|
|
|
|
} else { |
|
|
|
|
// await ResourceApi.updateResource(form.value) |
|
|
|
|
await KpiApi.updateKpi(form.value) |
|
|
|
|
message.success(t('common.updateSuccess')) |
|
|
|
|
} |
|
|
|
|
show.value = false |
|
|
|
|
// 发送操作成功的事件 |
|
|
|
|
emit('success', form.value) |
|
|
|
|
emit('success') |
|
|
|
|
} finally { |
|
|
|
|
formLoading.value = false |
|
|
|
|
} |
|
|
|
@ -161,15 +195,10 @@ async function handleSave() { |
|
|
|
|
|
|
|
|
|
const checkAll = ref(false) |
|
|
|
|
const isIndeterminate = ref(false) |
|
|
|
|
const employeeOptions = ref([ |
|
|
|
|
{ id: 1, name: '武大郎' }, |
|
|
|
|
{ id: 2, name: '李二郎' }, |
|
|
|
|
{ id: 3, name: '拼命三郎' }, |
|
|
|
|
{ id: 4, name: '杨四郎' } |
|
|
|
|
]) |
|
|
|
|
const employeeOptions = ref([]) |
|
|
|
|
|
|
|
|
|
function handleCheckAllChange(val) { |
|
|
|
|
form.value.checkEmployees = val ? employeeOptions.value.map((it) => it.id) : [] |
|
|
|
|
form.value.examinedUserIdList = val ? employeeOptions.value.map((it) => it.id) : [] |
|
|
|
|
isIndeterminate.value = false |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|