3 changed files with 228 additions and 55 deletions
@ -0,0 +1,187 @@ |
|||||
|
<template> |
||||
|
<el-dialog |
||||
|
:visible.sync="visible" |
||||
|
:title="!dataForm.id ? $t('add') : $t('update')" |
||||
|
:close-on-click-modal="false" |
||||
|
:close-on-press-escape="false" |
||||
|
> |
||||
|
<el-form |
||||
|
:model="dataForm" |
||||
|
:rules="dataRule" |
||||
|
ref="dataForm" |
||||
|
@keyup.enter.native="dataFormSubmitHandle()" |
||||
|
:label-width="$i18n.locale === 'en-US' ? '120px' : '120px'" |
||||
|
> |
||||
|
<el-form-item label="考核规则名称" prop="ruleName"> |
||||
|
<el-input |
||||
|
v-model="dataForm.ruleName" |
||||
|
placeholder="考核规则名称" |
||||
|
clearable |
||||
|
></el-input> |
||||
|
</el-form-item> |
||||
|
<el-form-item label="考核规则编码" prop="ruleCode"> |
||||
|
<el-input |
||||
|
v-model="dataForm.ruleCode" |
||||
|
placeholder="考核规则编码" |
||||
|
clearable |
||||
|
></el-input> |
||||
|
</el-form-item> |
||||
|
<el-form-item label="关联的手动打分" prop="referenceId"> |
||||
|
<el-select v-model="dataForm.referenceId" clearable placeholder="关联的手动打分" @change="handlereference(dataForm.referenceId)"> |
||||
|
<el-option |
||||
|
v-for="item in kpiManualScoreList" |
||||
|
:key="item.id" |
||||
|
:label="item.scoreName" |
||||
|
:value="item.id" |
||||
|
> |
||||
|
</el-option> |
||||
|
</el-select> |
||||
|
</el-form-item> |
||||
|
</el-form> |
||||
|
<template slot="footer"> |
||||
|
<el-button @click="visible = false">{{ $t("cancel") }}</el-button> |
||||
|
<el-button type="primary" @click="dataFormSubmitHandle()">{{ |
||||
|
$t("confirm") |
||||
|
}}</el-button> |
||||
|
</template> |
||||
|
</el-dialog> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
import debounce from 'lodash/debounce' |
||||
|
export default { |
||||
|
data () { |
||||
|
return { |
||||
|
visible: false, |
||||
|
kpiFormulaList: [], |
||||
|
metaDataCodeList: [], |
||||
|
paramAmount: 100, // 公式参数数量 |
||||
|
kpiManualScoreList: [], // 手动打分下拉框 |
||||
|
dataForm: { |
||||
|
id: '', |
||||
|
ruleName: '', |
||||
|
ruleCode: '', |
||||
|
ruleMode: '1', // 规则生成方式(0-元公式,1-手工打分,2-投票) |
||||
|
referenceId: '', // 关联的手动打分项 |
||||
|
kpiCycle: '', // 考核周期来源于选择的手动打分项 |
||||
|
deptTypeKey: '' // 考核部门类别来源于选择的手动打分项 |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
computed: { |
||||
|
dataRule () { |
||||
|
return { |
||||
|
ruleName: [ |
||||
|
{ |
||||
|
required: true, |
||||
|
message: this.$t('validate.required'), |
||||
|
trigger: 'blur' |
||||
|
} |
||||
|
], |
||||
|
ruleCode: [ |
||||
|
{ |
||||
|
required: true, |
||||
|
message: this.$t('validate.required'), |
||||
|
trigger: 'blur' |
||||
|
} |
||||
|
], |
||||
|
referenceId: [ |
||||
|
{ |
||||
|
required: true, |
||||
|
message: this.$t('validate.required'), |
||||
|
trigger: 'blur' |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
created () { |
||||
|
this.getKpiManualScoreList() |
||||
|
}, |
||||
|
methods: { |
||||
|
init () { |
||||
|
this.visible = true |
||||
|
this.$nextTick(() => { |
||||
|
this.$refs['dataForm'].resetFields() |
||||
|
if (this.dataForm.id) { |
||||
|
this.getInfo() |
||||
|
} |
||||
|
}) |
||||
|
}, |
||||
|
// 获取信息 |
||||
|
getInfo () { |
||||
|
this.$http |
||||
|
.get(`/kpi/kpirule/${this.dataForm.id}`) |
||||
|
.then(({ data: res }) => { |
||||
|
if (res.code !== 0) { |
||||
|
return this.$message.error(res.msg) |
||||
|
} |
||||
|
this.dataForm = { |
||||
|
...this.dataForm, |
||||
|
...res.data |
||||
|
} |
||||
|
}) |
||||
|
.catch(() => {}) |
||||
|
}, |
||||
|
// 表单提交 |
||||
|
dataFormSubmitHandle: debounce( |
||||
|
function () { |
||||
|
this.$refs['dataForm'].validate(valid => { |
||||
|
if (!valid) { |
||||
|
return false |
||||
|
} |
||||
|
this.$http[!this.dataForm.id ? 'post' : 'put']( |
||||
|
'/kpi/kpirule/saveOrUpdate/', |
||||
|
this.dataForm |
||||
|
) |
||||
|
.then(({ data: res }) => { |
||||
|
if (res.code !== 0) { |
||||
|
return this.$message.error(res.msg) |
||||
|
} |
||||
|
this.$message({ |
||||
|
message: this.$t('prompt.success'), |
||||
|
type: 'success', |
||||
|
duration: 500, |
||||
|
onClose: () => { |
||||
|
this.visible = false |
||||
|
this.$emit('refreshDataList') |
||||
|
} |
||||
|
}) |
||||
|
}) |
||||
|
.catch(() => {}) |
||||
|
}) |
||||
|
}, |
||||
|
1000, |
||||
|
{ leading: true, trailing: false } |
||||
|
), |
||||
|
// 查询手动打分下拉框 |
||||
|
getKpiManualScoreList () { |
||||
|
this.$http |
||||
|
.get(`/kpi/kpimanualscore/getKpiManualScoreList`) |
||||
|
.then(({ data: res }) => { |
||||
|
if (res.code !== 0) { |
||||
|
return this.$message.error(res.msg) |
||||
|
} |
||||
|
this.kpiManualScoreList = res.data |
||||
|
}) |
||||
|
.catch(() => {}) |
||||
|
}, |
||||
|
// 关联的手动打分改变 |
||||
|
handlereference (referenceId) { |
||||
|
console.log('当前选中的手动打分项id=' + referenceId) |
||||
|
if (referenceId) { |
||||
|
let kpiManualScoreArray = this.kpiManualScoreList |
||||
|
for (var i = 0; i < kpiManualScoreArray.length; i++) { |
||||
|
if (kpiManualScoreArray[i].id === referenceId) { |
||||
|
this.dataForm.kpiCycle = kpiManualScoreArray[i].scoreCycle |
||||
|
this.dataForm.deptTypeKey = kpiManualScoreArray[i].deptTypeKey |
||||
|
} |
||||
|
} |
||||
|
} else { |
||||
|
this.kpiCycle = '' |
||||
|
this.deptTypeKey = '' |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
</script> |
||||
Loading…
Reference in new issue