<template>
|
<!-- 添加或修改IQC检验项目对话框 -->
|
<el-dialog
|
:title="title"
|
:visible.sync="open"
|
width="750px"
|
custom-class="madelClass"
|
:destroyOnClose="true"
|
>
|
<div class="contbox">
|
<el-form
|
ref="form"
|
v-if="open"
|
:model="form"
|
:rules="rules"
|
:disabled="isCheck"
|
>
|
<el-form-item
|
v-for="(item, index) in formItem"
|
:key="index"
|
:label="item.label"
|
:prop="item.prop"
|
label-width="120px"
|
:class="item.component == 'inputNumber' ? 'itemFixed' : ''"
|
>
|
<template v-if="item.component == 'input'">
|
<el-input
|
v-model="form[item.prop]"
|
:readonly="item.readonly"
|
:placeholder="
|
item.prop == 'checkItemNo' ? '自动生成' : '请输入' + item.label
|
"
|
/>
|
</template>
|
<template v-if="item.component == 'inputNumber'">
|
<el-input-number
|
v-model="form[item.prop]"
|
:label="'请输入' + item.label"
|
></el-input-number>
|
</template>
|
<template v-if="item.component == 'textarea'">
|
<el-input
|
type="textarea"
|
:rows="2"
|
:placeholder="'请输入' + item.label"
|
v-model="form[item.prop]"
|
>
|
</el-input>
|
</template>
|
<template v-if="item.component == 'select'">
|
<template v-if="item.prop == 'checkType'">
|
<el-select
|
v-model="form[item.prop]"
|
:placeholder="'请选择' + item.label"
|
v-if="item.prop == 'checkType'"
|
style="width: 100%"
|
>
|
<el-option
|
v-for="dict in dict.type.check_type"
|
:key="dict.value"
|
:label="dict.label"
|
:value="dict.value"
|
>
|
</el-option>
|
</el-select>
|
</template>
|
|
<template v-if="item.prop == 'locationGroupNo'">
|
<el-select
|
v-model="form[item.prop]"
|
:placeholder="'请选择' + item.label"
|
v-if="item.prop == 'locationGroupNo'"
|
style="width: 100%"
|
>
|
<el-option
|
v-for="dict in dict.type.check_type"
|
:key="dict.value"
|
:label="dict.label"
|
:value="dict.value"
|
>
|
</el-option>
|
</el-select>
|
</template>
|
|
<template v-if="item.prop == 'isAutoCheck'">
|
<el-select
|
v-model="form[item.prop]"
|
:placeholder="'请选择' + item.label"
|
|
style="width: 100%"
|
>
|
<el-option
|
v-for="dict in dict.type.is_auto_check"
|
:key="dict.value"
|
:label="dict.label"
|
:value="dict.value"
|
>
|
</el-option>
|
</el-select>
|
</template>
|
<template v-if="item.prop == 'isRequired'">
|
<el-select
|
v-model="form[item.prop]"
|
:placeholder="'请选择' + item.label"
|
style="width: 100%"
|
>
|
<el-option
|
v-for="dict in dict.type.is_required"
|
:key="dict.value"
|
:label="dict.label"
|
:value="dict.value"
|
>
|
</el-option>
|
</el-select>
|
</template>
|
<template v-if="item.prop == 'isToSpc'">
|
<el-select
|
v-model="form[item.prop]"
|
:placeholder="'请选择' + item.label"
|
style="width: 100%"
|
>
|
<el-option
|
v-for="dict in dict.type.is_to_spc"
|
:key="dict.value"
|
:label="dict.label"
|
:value="dict.value"
|
>
|
</el-option>
|
</el-select>
|
</template>
|
<template v-if="item.prop == 'status'">
|
<el-select
|
v-model="form[item.prop]"
|
:placeholder="'请选择' + item.label"
|
style="width: 100%"
|
>
|
<el-option
|
v-for="dict in dict.type.status"
|
:key="dict.value"
|
:label="dict.label"
|
:value="dict.value"
|
>
|
</el-option>
|
</el-select>
|
</template>
|
</template>
|
</el-form-item>
|
</el-form>
|
</div>
|
|
<div slot="footer" class="dialog-footer">
|
<el-button
|
v-if="!isCheck"
|
:loading="buttonLoading"
|
type="primary"
|
@click="submitForm"
|
>确 定</el-button
|
>
|
<el-button @click="cancel">取 消</el-button>
|
</div>
|
</el-dialog>
|
</template>
|
|
<script>
|
import { formatData, formrRquired, formatDataItem } from "./info.data";
|
import { getLocation, addLocation, updateLocation } from "@/api/basicData/location";
|
|
export default {
|
name: "checkItemAdd",
|
components: {},
|
dicts: ["check_type", "is_auto_check", "is_required", "is_to_spc", "status"],
|
data() {
|
return {
|
form: JSON.parse(JSON.stringify(formatData)),
|
rules: formrRquired,
|
open: false,
|
title: "",
|
buttonLoading: false,
|
isCheck: false,
|
};
|
},
|
|
computed: {
|
formItem() {
|
return formatDataItem;
|
},
|
},
|
watch:{
|
open(val){
|
if(!val){
|
this.$refs["form"].resetFields();
|
|
}
|
|
}
|
},
|
mounted() {},
|
methods: {
|
/** 提交按钮 */
|
submitForm() {
|
this.$refs["form"].validate((valid) => {
|
if (valid) {
|
this.buttonLoading = true;
|
if (this.form.checkItemId != null) {
|
updateLocation(this.form)
|
.then((response) => {
|
this.$modal.msgSuccess("修改成功");
|
this.open = false;
|
this.$emit("getList");
|
})
|
.finally(() => {
|
this.buttonLoading = false;
|
});
|
} else {
|
addLocation(this.form)
|
.then((response) => {
|
this.$modal.msgSuccess("新增成功");
|
this.open = false;
|
this.$emit("getList");
|
})
|
.finally(() => {
|
this.buttonLoading = false;
|
});
|
}
|
}
|
});
|
},
|
// 取消按钮
|
cancel() {
|
this.reset();
|
},
|
reset() {
|
this.$refs["form"].resetFields();
|
this.open = false;
|
this.isCheck = false;
|
},
|
elDialogShow(type, info = "") {
|
this.open = true;
|
if (type == 1) {
|
this.title = "检测项目添加";
|
this.isCheck = false;
|
} else if (type == 2) {
|
this.isCheck = false;
|
this.getDetailse(info);
|
this.title = "检测项目编辑";
|
} else {
|
this.title = "检测项目查看";
|
this.isCheck = true;
|
this.getDetailse(info);
|
}
|
this.$nextTick(()=>{
|
|
})
|
},
|
getDetailse(id) {
|
getLocation(id).then((res) => {
|
if (res.code === 200) {
|
this.form = res.data;
|
}
|
});
|
},
|
},
|
};
|
</script>
|
|
<style lang="less" scoped>
|
.contbox {
|
max-height: 60vh !important;
|
overflow: auto;
|
box-sizing: border-box;
|
padding: 0 20px;
|
}
|
.itemFixed {
|
display: inline-block !important;
|
}
|
.itemFixed:first-child {
|
display: block !important;
|
}
|
::v-deep .is-disabled .el-input__inner {
|
color: #606266 !important;
|
}
|
// ::v-deep .el-input.is-disabled .el-input__inner
|
</style>
|