解决物模型修改枚举和数组界面不更新问题

This commit is contained in:
kerwincui
2022-06-08 14:18:21 +08:00
parent 952c2e09c0
commit f2af26998a
2 changed files with 65 additions and 45 deletions

View File

@@ -127,7 +127,7 @@
<div v-if="form.datatype == 'enum'">
<el-form-item label="枚举项" prop="">
<el-row v-for="(item,index) in form.specs.enumList" :key="index" style="margin-bottom:10px;">
<el-row v-for="(item,index) in form.specs.enumList" :key="'enum'+index" style="margin-bottom:10px;">
<el-col :span="8">
<el-input v-model="item.value" placeholder="参数值例如0" type="number" />
</el-col>
@@ -314,15 +314,15 @@ export default {
// 表单重置
reset() {
this.form = {
modelId: null,
modelName: null,
productId: null,
productName: null,
templateId: null,
templateName: null,
userId: null,
userName: null,
tenantId: null,
tenantName: null,
identifier: null,
type: null,
datatype: null,
type: 1,
datatype: "integer",
isSys: null,
isTop: null,
isMonitor: null,
@@ -332,7 +332,13 @@ export default {
updateBy: null,
updateTime: null,
remark: null,
specs: null,
specs: {
enumList: [{
value: "",
text: ""
}],
arrayType: "int"
},
};
this.resetForm("form");
},
@@ -351,23 +357,27 @@ export default {
this.reset();
this.open = true;
this.title = "添加物模型";
this.form.type = 1;
this.form.datatype = "integer"
this.form.specs = {
enumList: [],
arrayType: "int"
};
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const modelId = row.modelId;
const modelId = row.modelId;;
getModel(modelId).then((response) => {
this.form = response.data;
let tempForm = response.data;
this.open = true;
this.title = "修改物模型";
// Json转对象
this.form.specs = JSON.parse(this.form.specs);
tempForm.specs = JSON.parse(tempForm.specs);
if (!tempForm.specs.enumList) {
tempForm.specs.enumList = [{
value: "",
text: ""
}];
}
if (!tempForm.specs.arrayType) {
tempForm.specs.arrayType = "int";
}
this.form=tempForm;
});
},
/**查看物模型 */
@@ -539,19 +549,19 @@ export default {
},
/** 切换为枚举项 */
dataTypeChange(val) {
if (val == "enum") {
this.form.specs.enumList = [{
value: "",
text: ""
}];
}
// if (val == "enum") {
// this.form.specs.enumList = [{
// value: "",
// text: ""
// }];
// }
},
/** 添加枚举项 */
addEnumItem() {
this.form.specs.enumList.push({
value: "",
text: ""
})
});
},
/** 删除枚举项 */
removeEnumItem(index) {

View File

@@ -1,6 +1,6 @@
<template>
<div style="padding:6px;">
<el-card v-show="showSearch" style="margin-bottom:6px;">
<el-card v-show="showSearch" style="margin-bottom:5px;">
<el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px" style="margin-bottom:-20px;">
<el-form-item label="名称" prop="templateName">
<el-input v-model="queryParams.templateName" placeholder="请输入物模型名称" clearable size="small" @keyup.enter.native="handleQuery" />
@@ -142,7 +142,7 @@
</div>
<div v-if="form.datatype == 'enum'">
<el-form-item label="枚举项" prop="">
<el-row v-for="(item,index) in form.specs.enumList" :key="index" style="margin-bottom:10px;">
<el-row v-for="(item,index) in form.specs.enumList" :key="'enum'+index" style="margin-bottom:10px;">
<el-col :span="8">
<el-input v-model="item.value" placeholder="参数值例如0" type="number" />
</el-col>
@@ -292,8 +292,8 @@ export default {
tenantId: null,
tenantName: null,
identifier: null,
type: null,
datatype: null,
type: 1,
datatype: "integer",
isSys: null,
isTop: null,
isMonitor: null,
@@ -303,7 +303,13 @@ export default {
updateBy: null,
updateTime: null,
remark: null,
specs: null,
specs: {
enumList: [{
value: "",
text: ""
}],
arrayType: "int"
},
};
this.resetForm("form");
},
@@ -328,23 +334,27 @@ export default {
this.reset();
this.open = true;
this.title = "添加通用物模型";
this.form.type = 1;
this.form.datatype = "integer"
this.form.specs = {
enumList: [],
arrayType: "int"
};
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const templateId = row.templateId || this.ids;
getTemplate(templateId).then((response) => {
this.form = response.data;
let tempForm = response.data;
this.open = true;
this.title = "修改通用物模型";
// Json转对象
this.form.specs = JSON.parse(this.form.specs);
tempForm.specs = JSON.parse(tempForm.specs);
if (!tempForm.specs.enumList) {
tempForm.specs.enumList = [{
value: "",
text: ""
}];
}
if (!tempForm.specs.arrayType) {
tempForm.specs.arrayType = "int";
}
this.form=tempForm;
});
},
/** 提交按钮 */
@@ -445,19 +455,19 @@ export default {
},
/** 切换为枚举项 */
dataTypeChange(val) {
if (val == "enum") {
this.form.specs.enumList = [{
value: "",
text: ""
}];
}
// if (val == "enum") {
// this.form.specs.enumList = [{
// value: "",
// text: ""
// }];
// }
},
/** 添加枚举项 */
addEnumItem() {
this.form.specs.enumList.push({
value: "",
text: ""
})
});
},
/** 删除枚举项 */
removeEnumItem(index) {