255 lines
7.4 KiB
Plaintext
255 lines
7.4 KiB
Plaintext
<template>
|
|
<div class="app-container" style="width: 700px; height: 600px">
|
|
<el-form
|
|
label-width="120px"
|
|
ref="formData"
|
|
:model="formData"
|
|
:rules="rules"
|
|
style="padding-top: 10px; padding-right: 10px"
|
|
>
|
|
<el-row>
|
|
<el-col :span="12">
|
|
<el-form-item label="设备名称" prop="deviceName">
|
|
<el-select v-model="formData.deviceId" @change="selectChange">
|
|
<el-option
|
|
v-for="(item, index) in List"
|
|
:key="index"
|
|
:label="item.name"
|
|
:value="item.id"
|
|
>
|
|
</el-option>
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-col>
|
|
|
|
<el-col :span="12">
|
|
<el-form-item label="设备编号">
|
|
<el-input
|
|
type="text"
|
|
placeholder="请输入设备编号"
|
|
v-model="formData.deviceCode"
|
|
disabled
|
|
></el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
<el-row>
|
|
<el-col :span="12">
|
|
<el-form-item label="规格型号">
|
|
<el-input
|
|
type="text"
|
|
placeholder="请输入规格型号"
|
|
v-model="formData.specification"
|
|
disabled
|
|
></el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :span="12">
|
|
<el-form-item label="保养周期(天)" prop="maintenancePeriod">
|
|
<el-input
|
|
type="text"
|
|
onkeyup="value=value.replace(/[^\d]/g,'')"
|
|
placeholder="请输入保养周期"
|
|
v-model="formData.maintenancePeriod"
|
|
></el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
<el-row>
|
|
<el-col :span="12">
|
|
<el-form-item label="选择模板">
|
|
<el-select
|
|
clearable
|
|
style="width: 100%"
|
|
v-model="formData.templateId"
|
|
placeholder="选择模板"
|
|
>
|
|
<el-option
|
|
v-for="(template, index) in checkedList"
|
|
:label="template.name"
|
|
:value="template.id"
|
|
:key="index"
|
|
></el-option>
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
|
|
<el-col :span="24">
|
|
<el-form-item style="float: right; margin-right: 20px">
|
|
<el-button type="primary" @click="save('formData')">确 定</el-button>
|
|
<el-button @click="goback">取 消</el-button>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-form>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
name: "edit",
|
|
props: {
|
|
layerid: {
|
|
type: String,
|
|
default: "",
|
|
},
|
|
lydata: {
|
|
type: Object,
|
|
default: () => {
|
|
return {};
|
|
},
|
|
},
|
|
},
|
|
data() {
|
|
return {
|
|
checkedList:[],
|
|
AllzlList: [],
|
|
formData: {},
|
|
List: [],
|
|
rules: {
|
|
deviceName: [
|
|
{ required: true, message: "请输入设备名称", trigger: "blur" },
|
|
],
|
|
maintenancePeriod: [
|
|
{ required: true, message: "保养周期不能为空", trigger: "blur" },
|
|
],
|
|
},
|
|
};
|
|
},
|
|
mounted() {
|
|
|
|
},
|
|
created() {
|
|
this.$EquipmentInspectPlan.getAllList().then((resp) => {
|
|
if (resp.data.code == 200) {
|
|
console.log("列表", resp.data.data);
|
|
this.List = resp.data.data;
|
|
}
|
|
});
|
|
if (this.$parent.isAdd == false) {
|
|
this.formData = JSON.parse(JSON.stringify(this.lydata));
|
|
}
|
|
this.getzlAll();
|
|
this.getCheckTemplate()
|
|
},
|
|
methods: {
|
|
getCheckTemplate() {
|
|
let params = {
|
|
templateCategory: 15,
|
|
templateType: 5,
|
|
};
|
|
this.$tempConfig.getList(params).then((data) => {
|
|
if (data.data.code === 200) {
|
|
this.checkedList = data.data.data.data;
|
|
} else {
|
|
this.$message.error("获取模板列表异常");
|
|
}
|
|
});
|
|
},
|
|
getzlAll() {
|
|
this.$zj.getzjList().then((resp) => {
|
|
if (resp.data.code == 200) {
|
|
this.AllzlList = resp.data.data;
|
|
console.log("拿到整体得值", resp.data.data);
|
|
}
|
|
});
|
|
},
|
|
selectChangeDj(event) {
|
|
this.AllzlList.forEach((e) => {
|
|
if (e.id == event) {
|
|
this.formData.maintenanceTemplate = e.name;
|
|
}
|
|
});
|
|
},
|
|
selectChange(event) {
|
|
this.List.forEach((e) => {
|
|
if (e.id == event) {
|
|
this.formData.deviceName = e.name;
|
|
this.formData.specification = e.specificationModel;
|
|
this.formData.deviceId = event;
|
|
this.formData.deviceCode = e.deviceCode;
|
|
}
|
|
});
|
|
},
|
|
goback() {
|
|
this.$layer.close(this.layerid);
|
|
},
|
|
save() {
|
|
if (this.$parent.isAdd) {
|
|
this.$refs["formData"].validate((valid) => {
|
|
if (valid) {
|
|
this.checkedList.forEach((va, index) => {
|
|
if (va.id == this.formData.templateId) {
|
|
this.formData.templateText = va.name;
|
|
}
|
|
});
|
|
let params = {
|
|
deviceCode: this.formData.deviceCode,
|
|
deviceName: this.formData.deviceName.message,
|
|
deviceId: this.formData.deviceId,
|
|
specification: this.formData.specification,
|
|
maintenancePeriod: this.formData.maintenancePeriod,
|
|
maintenanceTemplate: this.formData.maintenanceTemplate,
|
|
templateId: this.formData.templateId,
|
|
templateText:this.formData.templateText
|
|
};
|
|
|
|
this.$EquipmentMaintenance.addEquipmentPlan(params).then((resp) => {
|
|
if (resp.data.code == 200) {
|
|
this.$message.success("添加成功");
|
|
this.$parent.getList();
|
|
this.$layer.close(this.layerid);
|
|
} else {
|
|
this.$message.error(resp.data.message);
|
|
}
|
|
});
|
|
} else {
|
|
return false;
|
|
}
|
|
});
|
|
} else if (this.$parent.isAdd == false) {
|
|
this.$refs["formData"].validate((valid) => {
|
|
if (valid) {
|
|
this.checkedList.forEach((va, index) => {
|
|
if (va.id == this.formData.templateId) {
|
|
this.formData.templateText = va.name;
|
|
}
|
|
});
|
|
let params = {
|
|
maintenancePeriod: this.formData.maintenancePeriod,
|
|
maintenanceEndTime: this.formData.maintenanceEndTime,
|
|
maintenanceStartTime: this.formData.maintenanceStartTime,
|
|
maintenanceTemplate: this.formData.maintenanceTemplate,
|
|
createDt: this.formData.createDt,
|
|
deviceCode: this.formData.deviceCode,
|
|
deviceId: this.formData.deviceId,
|
|
deviceName: this.formData.deviceName,
|
|
id: this.lydata.id,
|
|
specification: this.formData.specification,
|
|
templateId: this.formData.templateId,
|
|
templateText:this.formData.templateText
|
|
};
|
|
this.$EquipmentMaintenance
|
|
.DpdataEquipmentPlan(params)
|
|
.then((resp) => {
|
|
if (resp.data.code == 200) {
|
|
this.$message.success("修改成功");
|
|
this.$parent.getList();
|
|
this.$layer.close(this.layerid);
|
|
} else {
|
|
this.$message.error(resp.data.message);
|
|
}
|
|
});
|
|
} else {
|
|
return false;
|
|
}
|
|
});
|
|
}
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
|
|
<style scoped>
|
|
</style>
|