回显问题修复
This commit is contained in:
parent
f5812a995c
commit
a611990ae6
|
|
@ -59,7 +59,7 @@
|
||||||
<el-tag style="margin-left: 10px" size="mini" type="primary">节点{{ row.level }}</el-tag>
|
<el-tag style="margin-left: 10px" size="mini" type="primary">节点{{ row.level }}</el-tag>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
||||||
<el-table-column label="层级名称">
|
<el-table-column label="层级名称">
|
||||||
<template slot-scope="{ row }">
|
<template slot-scope="{ row }">
|
||||||
<!-- 只在项目级(第一级)显示层级名称 -->
|
<!-- 只在项目级(第一级)显示层级名称 -->
|
||||||
|
|
@ -231,7 +231,7 @@ export default {
|
||||||
proName: undefined,
|
proName: undefined,
|
||||||
unit: undefined,
|
unit: undefined,
|
||||||
chargePerson: undefined,
|
chargePerson: undefined,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
|
@ -265,13 +265,13 @@ export default {
|
||||||
return
|
return
|
||||||
} */
|
} */
|
||||||
/* 新需求 重新做 上面建议不要删除 有需要直接可以查看 */
|
/* 新需求 重新做 上面建议不要删除 有需要直接可以查看 */
|
||||||
openView({ id: row.id }).then(response => {
|
openView({ id: row.id }).then(response => {
|
||||||
this.dxfPreviewUrl = response.data
|
this.dxfPreviewUrl = response.data
|
||||||
this.viewDialogVisible = true
|
this.viewDialogVisible = true
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
console.error("获取项目详情失败:", error);
|
console.error("获取项目详情失败:", error);
|
||||||
});
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// 查询按钮
|
// 查询按钮
|
||||||
|
|
@ -295,12 +295,14 @@ export default {
|
||||||
|
|
||||||
// 新增子节点
|
// 新增子节点
|
||||||
handleAddChild(row) {
|
handleAddChild(row) {
|
||||||
const { id, proName, level, nodeCount, projectId } = row
|
const { id, proName, nodeName, level, nodeCount, projectId } = row;
|
||||||
|
const name = nodeName || proName; // 如果 nodeName 存在就用它,否则用 proName
|
||||||
|
|
||||||
this.addOrEditFormTitle = '新增'
|
this.addOrEditFormTitle = '新增'
|
||||||
this.editForm = null
|
this.editForm = null
|
||||||
this.addOrEditFormVisible = true
|
this.addOrEditFormVisible = true
|
||||||
|
|
||||||
const editForm = { deviceName: proName, id, level, nodeCount, projectId }
|
const editForm = { deviceName: name, id, level, nodeCount, projectId }
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$refs.addOrEditComponentRef.setFormData(editForm)
|
this.$refs.addOrEditComponentRef.setFormData(editForm)
|
||||||
})
|
})
|
||||||
|
|
@ -323,11 +325,11 @@ export default {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
getModelListApi(this.queryParams).then((response) => {
|
getModelListApi(this.queryParams).then((response) => {
|
||||||
const rawList = response.rows || [];
|
const rawList = response.rows || [];
|
||||||
|
|
||||||
// 增强型递归处理
|
// 增强型递归处理
|
||||||
const formatNodes = (nodes, level = 2) => { // 从第二级开始
|
const formatNodes = (nodes, level = 2) => { // 从第二级开始
|
||||||
if (!Array.isArray(nodes)) return [];
|
if (!Array.isArray(nodes)) return [];
|
||||||
|
|
||||||
return nodes
|
return nodes
|
||||||
.filter(item => item && item.nodeId) // 过滤无效节点
|
.filter(item => item && item.nodeId) // 过滤无效节点
|
||||||
.map(item => ({
|
.map(item => ({
|
||||||
|
|
@ -339,11 +341,11 @@ export default {
|
||||||
nodes: formatNodes(item.nodes || item.children || [], level + 1)
|
nodes: formatNodes(item.nodes || item.children || [], level + 1)
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
// 处理项目层数据
|
// 处理项目层数据
|
||||||
const formatted = rawList.map(project => {
|
const formatted = rawList.map(project => {
|
||||||
const children = project.children || [];
|
const children = project.children || [];
|
||||||
|
|
||||||
// 获取层级名称(项目级才需要)
|
// 获取层级名称(项目级才需要)
|
||||||
let levelName = '';
|
let levelName = '';
|
||||||
let nodeCount = '';
|
let nodeCount = '';
|
||||||
|
|
@ -353,7 +355,7 @@ export default {
|
||||||
);
|
);
|
||||||
levelName = levelConfig ? levelConfig.configName : '';
|
levelName = levelConfig ? levelConfig.configName : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...project,
|
...project,
|
||||||
id: project.projectId,
|
id: project.projectId,
|
||||||
|
|
@ -365,11 +367,11 @@ export default {
|
||||||
nodeCount:project.nodeCount
|
nodeCount:project.nodeCount
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
this.modelList = formatted;
|
this.modelList = formatted;
|
||||||
this.total = response.total;
|
this.total = response.total;
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
|
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
console.error("获取模型列表失败:", error);
|
console.error("获取模型列表失败:", error);
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
|
|
@ -437,7 +439,7 @@ export default {
|
||||||
} else {
|
} else {
|
||||||
res = await delModelApi({ id: row.id }); // 使用 delModelApi 删除模型节点
|
res = await delModelApi({ id: row.id }); // 使用 delModelApi 删除模型节点
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
this.$modal.msgSuccess('删除成功')
|
this.$modal.msgSuccess('删除成功')
|
||||||
this.getModelList()
|
this.getModelList()
|
||||||
|
|
@ -540,4 +542,4 @@ export default {
|
||||||
color: #409eff;
|
color: #409eff;
|
||||||
background-color: #f0f7ff;
|
background-color: #f0f7ff;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue