181 lines
5.4 KiB
Vue
181 lines
5.4 KiB
Vue
|
<!--
|
||
|
* @Author: zwq
|
||
|
* @Date: 2021-11-18 14:16:25
|
||
|
* @LastEditors: zwq
|
||
|
* @LastEditTime: 2022-09-21 09:22:30
|
||
|
* @Description:
|
||
|
-->
|
||
|
<template>
|
||
|
<el-dialog
|
||
|
:title="!dataForm.id ? '新增' : '修改'"
|
||
|
:close-on-click-modal="false"
|
||
|
:visible.sync="visible"
|
||
|
>
|
||
|
<el-row :gutter="5">
|
||
|
<el-form
|
||
|
:model="dataForm"
|
||
|
:rules="dataRule"
|
||
|
ref="dataForm"
|
||
|
@keyup.enter.native="dataFormSubmit()"
|
||
|
label-width="80px"
|
||
|
>
|
||
|
<el-col :span="12">
|
||
|
<el-form-item label="编码" prop="code">
|
||
|
<el-input
|
||
|
v-model="dataForm.code"
|
||
|
oninput="value=value.replace(/[^\d]/g,'')"
|
||
|
placeholder="编码"
|
||
|
></el-input>
|
||
|
</el-form-item>
|
||
|
</el-col>
|
||
|
<el-col :span="12">
|
||
|
<el-form-item label="名称" prop="name">
|
||
|
<el-input v-model="dataForm.name" placeholder="名称"></el-input>
|
||
|
</el-form-item>
|
||
|
</el-col>
|
||
|
<el-col :span="24">
|
||
|
<el-divider content-position="left">监控图形一</el-divider>
|
||
|
<el-checkbox-group v-model="checkList">
|
||
|
<el-checkbox
|
||
|
style="width:100%;font-size:20px;margin:8px 5px"
|
||
|
v-for="item in ruleArr"
|
||
|
:key="item.id"
|
||
|
:label="item.id"
|
||
|
>{{ item.ruleKey.split("x")[0] }}
|
||
|
<el-input
|
||
|
v-show="item.ruleKey.split('x').length >= 2"
|
||
|
v-model="item.ruleValue1"
|
||
|
@blur="changeRule(item)"
|
||
|
style="width:60px"
|
||
|
></el-input>
|
||
|
{{ item.ruleKey.split("x")[1] }}
|
||
|
<el-input
|
||
|
v-show="item.ruleKey.split('x').length >= 3"
|
||
|
v-model="item.ruleValue2"
|
||
|
@blur="changeRule(item)"
|
||
|
style="width:60px"
|
||
|
></el-input>
|
||
|
{{ item.ruleKey.split("x")[2] }}
|
||
|
</el-checkbox>
|
||
|
</el-checkbox-group>
|
||
|
</el-col>
|
||
|
</el-form>
|
||
|
</el-row>
|
||
|
<span slot="footer" class="dialog-footer">
|
||
|
<el-button @click="visible = false">取消</el-button>
|
||
|
<el-button type="primary" @click="dataFormSubmit()">确定</el-button>
|
||
|
</span>
|
||
|
</el-dialog>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
|
export default {
|
||
|
data() {
|
||
|
return {
|
||
|
urlOptions: {
|
||
|
submitURL: "/qualityPlanning/myInterpretationScheme/",
|
||
|
infoURL: "/qualityPlanning/myInterpretationScheme",
|
||
|
},
|
||
|
visible: false,
|
||
|
dataForm: {
|
||
|
id: "",
|
||
|
code: "",
|
||
|
name: "",
|
||
|
interpretationSchemeIds: "",
|
||
|
},
|
||
|
ruleArr: [],
|
||
|
checkList: [],
|
||
|
dataRule: {
|
||
|
code: [{ required: true, message: "编码不能为空", trigger: "blur" }],
|
||
|
name: [{ required: true, message: "名称不能为空", trigger: "blur" }],
|
||
|
type: [{ required: true, message: "单位分类不能为空", trigger: "change" }],
|
||
|
},
|
||
|
};
|
||
|
},
|
||
|
methods: {
|
||
|
init(id) {
|
||
|
this.dataForm.id = id || "";
|
||
|
this.checkList = [];
|
||
|
this.ruleArr = [];
|
||
|
this.visible = true;
|
||
|
this.$nextTick(() => {
|
||
|
this.$refs["dataForm"].resetFields();
|
||
|
if (this.dataForm.id) {
|
||
|
this.$http
|
||
|
.get(`${this.urlOptions.infoURL}/${this.dataForm.id}`)
|
||
|
.then(({ data: res }) => {
|
||
|
if (res.code !== 0) {
|
||
|
return this.$message.error(res.msg);
|
||
|
}
|
||
|
this.dataForm = res.data;
|
||
|
})
|
||
|
.catch(() => {});
|
||
|
this.$http
|
||
|
.post(
|
||
|
`/qualityPlanning/interpretationScheme/listByMyInterpretationSchemeId?myInterpretationSchemeId=${this.dataForm.id}`
|
||
|
)
|
||
|
.then(({ data: res }) => {
|
||
|
this.ruleArr = res;
|
||
|
res.forEach((item) => {
|
||
|
if (item.flag === 1) {
|
||
|
this.checkList.push(item.id);
|
||
|
}
|
||
|
});
|
||
|
})
|
||
|
.catch(() => {});
|
||
|
}
|
||
|
});
|
||
|
},
|
||
|
changeRule(item) {
|
||
|
this.$http
|
||
|
.put("/qualityPlanning/interpretationScheme", item)
|
||
|
.then(({ data: res }) => {
|
||
|
if (res.code !== 0) {
|
||
|
return this.$message.error(res.msg);
|
||
|
}
|
||
|
})
|
||
|
.catch(() => {});
|
||
|
},
|
||
|
// 表单提交
|
||
|
dataFormSubmit() {
|
||
|
this.$refs["dataForm"].validate((valid) => {
|
||
|
if (!valid) {
|
||
|
return false;
|
||
|
}
|
||
|
this.ruleArr.forEach((item) => {
|
||
|
if (this.checkList.findIndex((item1)=>item1===item.id) !== -1) {
|
||
|
item.flag = 1;
|
||
|
} else {
|
||
|
item.flag = 0;
|
||
|
}
|
||
|
});
|
||
|
this.$http
|
||
|
.put("/qualityPlanning/interpretationScheme/batchUpdate", this.ruleArr)
|
||
|
.then(({ data: res }) => {
|
||
|
if (res.code !== 0) {
|
||
|
return this.$message.error(res.msg);
|
||
|
}
|
||
|
})
|
||
|
.catch(() => {});
|
||
|
this.$http[!this.dataForm.id ? "post" : "put"](this.urlOptions.submitURL, 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(() => {});
|
||
|
});
|
||
|
},
|
||
|
},
|
||
|
};
|
||
|
</script>
|