You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

480 lines
13 KiB

3 years ago
<template>
<div>
<xy-dialog
2 years ago
:z-index="zIndex"
3 years ago
ref="dialog"
:is-show.sync="isShow"
type="form"
:title="type === 'add' ? '新增绩效指标' : '编辑绩效指标'"
:form="form"
:rules="rules"
@submit="submit"
>
1 year ago
<template v-slot:year>
<div class="xy-table-item">
<div class="xy-table-item-label">
<span style="color: red; font-weight: 600; padding-right: 4px"
>*</span
>
年份
</div>
<div class="xy-table-item-content">
<el-date-picker
v-model="form.year"
type="year"
disabled
style="width: 300px"
placeholder="选择年">
</el-date-picker>
</div>
</div>
</template>
3 years ago
<template v-slot:target_type_id>
<div class="xy-table-item">
<div class="xy-table-item-label">
<span style="color: red; font-weight: 600; padding-right: 4px"
>*</span
>
一级指标
</div>
<div class="xy-table-item-content">
<el-select
2 years ago
:popper-append-to-body="false"
3 years ago
value-key="id"
:value="typeFormat"
clearable
placeholder="请选择一级指标"
style="width: 300px"
@change="e => {
form.target_type_id = e.id;
target_type2s = e.children;
}"
>
<el-option
v-for="item in target_types"
:key="item.id"
:label="item.name"
:value="item"
></el-option>
</el-select>
</div>
</div>
</template>
<template v-slot:target_type2_id>
<div class="xy-table-item">
<div class="xy-table-item-label">
<span style="color: red; font-weight: 600; padding-right: 4px"
>*</span
>
二级指标
</div>
<div class="xy-table-item-content">
<el-select
2 years ago
:popper-append-to-body="false"
3 years ago
v-model="form.target_type2_id"
clearable
placeholder="请选择二级指标"
style="width: 300px"
>
<el-option
v-for="item in target_type2s"
:key="item.id"
:label="item.name"
:value="item.id"
></el-option>
</el-select>
</div>
</div>
</template>
1 year ago
3 years ago
<template v-slot:name>
<div class="xy-table-item">
<div class="xy-table-item-label">
<span style="color: red; font-weight: 600; padding-right: 4px"
>*</span
>
名称
</div>
<div class="xy-table-item-content">
<el-input
v-model="form.name"
clearable
placeholder="请输入名称"
style="width: 300px"
></el-input>
</div>
</div>
</template>
<template v-slot:unit_id>
<div class="xy-table-item">
<div class="xy-table-item-label">
<span style="color: red; font-weight: 600; padding-right: 4px"
>*</span
>
单位
</div>
<div class="xy-table-item-content">
<el-select
2 years ago
:popper-append-to-body="false"
3 years ago
v-model="form.unit_id"
clearable
placeholder="请选择单位"
style="width: 300px"
>
<el-option
v-for="item in unit_ids"
:key="item.id"
:label="item.value"
:value="item.id"
></el-option>
</el-select>
</div>
</div>
</template>
<template v-slot:symbol_id>
<div class="xy-table-item">
<div class="xy-table-item-label">
<span style="color: red; font-weight: 600; padding-right: 4px"
>*</span
>
计算符号
</div>
<div class="xy-table-item-content">
<el-select
2 years ago
:popper-append-to-body="false"
3 years ago
ref="symbolSelect"
3 years ago
v-model="form.symbol_id"
clearable
placeholder="请选择计算符号"
style="width: 300px"
>
<el-option
v-for="item in symbol_ids"
:key="item.id"
:label="item.value"
:value="item.id"
></el-option>
</el-select>
</div>
</div>
</template>
2 years ago
<template #is_fixed>
<div class="xy-table-item">
<div class="xy-table-item-label">
是否固定指标项目
</div>
<div class="xy-table-item-content">
<el-switch style="width: 300px" v-model="form.is_fixed" :active-value="1" :inactive-value="0"></el-switch>
</div>
</div>
</template>
<template #evaluation_way>
<div class="xy-table-item">
<div class="xy-table-item-label">
2 years ago
建议上传佐证材料
2 years ago
</div>
<div class="xy-table-item-content">
<el-input style="width: 300px" v-model="form.evaluation_way" type="textarea" :autosize="{ minRows: 2 }"></el-input>
</div>
</div>
</template>
1 year ago
<!-- <template #score>
2 years ago
<div class="xy-table-item">
<div class="xy-table-item-label">
<span style="color: red; font-weight: 600; padding-right: 4px"
>*</span
>
分值
</div>
<div class="xy-table-item-content">
<el-input-number :precision="2" style="width: 300px" v-model="form.score" :controls="false"></el-input-number>
</div>
</div>
1 year ago
</template> -->
3 years ago
<template v-slot:half_target>
<div class="xy-table-item">
<div class="xy-table-item-label">
<span style="color: red; font-weight: 600; padding-right: 4px"
>*</span
>
半年指标值
</div>
<div class="xy-table-item-content">
3 years ago
<template v-if="isDingxing">
<el-input
v-model="form.half_target"
clearable
placeholder="请输入半年(程)指标值"
style="width: 300px"
></el-input>
</template>
<template v-else>
<el-input-number
v-model="form.half_target"
clearable
placeholder="请输入半年(程)指标值"
style="width: 300px"
:controls="false"
:precision="2"
></el-input-number>
</template>
3 years ago
</div>
</div>
</template>
<template v-slot:year_target>
<div class="xy-table-item">
<div class="xy-table-item-label">
<span style="color: red; font-weight: 600; padding-right: 4px"
>*</span
>
全年指标值
</div>
<div class="xy-table-item-content">
3 years ago
<template v-if="isDingxing">
<el-input
v-model="form.year_target"
clearable
placeholder="请输入全年(程)指标值"
style="width: 300px"
></el-input>
</template>
<template v-else>
<el-input-number
v-model="form.year_target"
clearable
placeholder="请输入全年(程)指标值"
style="width: 300px"
:controls="false"
:precision="2"
></el-input-number>
</template>
3 years ago
</div>
</div>
</template>
</xy-dialog>
</div>
</template>
<script>
2 years ago
import { save as planTargetSave } from "@/api/budget/planTarget";
3 years ago
import { show, save } from "@/api/achievements/points";
2 years ago
import { PopupManager } from "element-ui/src/utils/popup"
3 years ago
export default {
props: {
target_types: {
type: Array,
default: () => [],
},
unit_ids: {
type: Array,
default: () => [],
},
symbol_ids: {
type: Array,
default: () => [],
},
},
data() {
return {
2 years ago
zIndex: PopupManager.nextZIndex(),
3 years ago
isDingxing: false,
3 years ago
isShow: false,
id: "",
type: "",
target_type2s: [],
form: {
target_type_id: "",
target_type2_id: "",
1 year ago
year:'',
3 years ago
name: "",
2 years ago
symbol_id: "",
3 years ago
unit_id: "",
2 years ago
score: 0.00,
3 years ago
half_target: "",
year_target: "",
2 years ago
is_fixed: 1,
evaluation_way: "",
3 years ago
},
rules: {
target_type_id: [
{
required: true,
message: "请填写一级指标",
},
],
target_type2_id: [
{
required: true,
message: "请填写二级指标",
},
],
1 year ago
year: [
{
required: true,
message: "请填写年份",
},
],
3 years ago
name: [
{
required: true,
message: "请填写名称",
},
],
unit_id: [
{
required: true,
message: "请填写单位",
},
],
symbol_id: [
{
required: true,
message: "请填写计算符号",
},
],
half_target: [
{
required: true,
message: "请填写半年(程)指标值",
},
],
year_target: [
{
required: true,
message: "请填写全年(程)指标值",
},
],
1 year ago
// score: [
// {
// required: true,
// message: "请填写分值",
// },
// ]
3 years ago
},
};
},
methods: {
1 year ago
setYear(year){
this.form.year = year
},
2 years ago
setId (id) {
this.id = id
},
setType (type) {
this.type = type
},
3 years ago
show() {
this.isShow = true;
},
hidden() {
this.isShow = false;
},
init() {
this.form = {
target_type_id: "",
target_type2_id: "",
1 year ago
year:'',
3 years ago
name: "",
2 years ago
symbol_id: "",
3 years ago
unit_id: "",
2 years ago
score: 0.00,
3 years ago
half_target: "",
year_target: "",
2 years ago
is_fixed: 1,
evaluation_way: "",
3 years ago
};
},
setForm(key = [], value = []) {
if (key instanceof Array) {
key.forEach((key, index) => {
this.form[key] = value[index] ?? "";
});
}
if (typeof key === "string") {
this.form[key] = value;
}
if (!key) {
this.init();
}
},
async getDetail() {
const res = await show({ id: this.id });
this.$integrateData(this.form, res);
3 years ago
this.target_type2s = this.target_types?.filter(i => i.id === this.form.target_type_id)[0]?.children
1 year ago
this.form.year = res.year?res.year+'':''
3 years ago
},
submit() {
if (this.type === "add") {
if (this.form.hasOwnProperty("id")) {
delete this.form.id;
}
}
if (this.type === "editor") {
Object.defineProperty(this.form, "id", {
value: this.id,
enumerable: true,
configurable: true,
writable: true,
});
}
save(this.form).then((res) => {
2 years ago
if (/\/budgetList/g.test(this.$route.path) && this.type === 'add') {
this.$emit('savePlanTarget',res)
}
3 years ago
this.$message({
type: "success",
message:
this.type === "add" ? "新增绩效指标" : "编辑绩效指标" + "成功",
});
this.isShow = false;
this.$emit("refresh");
});
},
},
computed:{
typeFormat() {
return this.target_types.filter(item => item.id === this.form.target_type_id)[0]?.name || "";
3 years ago
},
3 years ago
},
watch: {
isShow(val) {
if (val) {
2 years ago
this.zIndex = PopupManager.nextZIndex()
3 years ago
if (this.type === "editor") {
this.getDetail();
}
} else {
this.id = "";
this.type = "";
this.init();
this.$refs["dialog"].clearValidate();
delete this.form.id;
}
},
3 years ago
"form.symbol_id": {
handler:function(val) {
this.$nextTick(() => {
2 years ago
this.isDingxing = this.$refs['symbolSelect']?.selectedLabel === '定性';
3 years ago
})
},
immediate: true
}
3 years ago
},
};
</script>
<style scoped lang="scss">
::v-deep .el-input__inner {
text-align: left;
}
.xy-table-item-label{
width: 200px;
}
</style>