区域主控高亮

编辑时展示原有属性
This commit is contained in:
2025-09-20 17:30:45 +08:00
parent e48d5ab2d8
commit 983b929d90
2 changed files with 43 additions and 4 deletions

View File

@@ -275,8 +275,16 @@ export default {
if (newVal && Object.keys(newVal).length > 0) {
// 填充表单数据
Object.keys(formData).forEach(key => {
if (newVal[key] !== undefined) {
formData[key] = newVal[key];
// 处理字段名映射
let dataKey = key;
if (key === 'parentControllerId') {
dataKey = 'parent_id';
} else if (key === 'subType') {
dataKey = 'sub_type';
}
if (newVal[dataKey] !== undefined) {
formData[key] = newVal[dataKey];
}
});
@@ -303,6 +311,14 @@ export default {
}
}, { immediate: true });
// 监听visible属性变化当对话框打开时重新加载区域主控列表
watch(() => props.visible, (newVal) => {
if (newVal) {
// 对话框打开时重新加载区域主控列表
loadAreaControllers();
}
}, { immediate: true });
// 组件挂载时加载区域主控列表
onMounted(() => {
loadAreaControllers();

View File

@@ -35,7 +35,9 @@
table-layout="auto"
row-key="id"
default-expand-all
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }">
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
:row-class-name="tableRowClassName"
highlight-current-row>
<el-table-column width="40"></el-table-column>
<el-table-column prop="id" label="设备ID" min-width="80" />
<el-table-column prop="name" label="设备名称" min-width="120" />
@@ -163,7 +165,20 @@ export default {
},
editDevice(device) {
this.currentDevice = { ...device };
// 处理设备数据,确保正确传递给表单
const processedDevice = { ...device };
// 如果properties是字符串则解析为对象
if (processedDevice.properties && typeof processedDevice.properties === 'string') {
try {
processedDevice.properties = JSON.parse(processedDevice.properties);
} catch (e) {
console.error('解析properties失败:', e);
processedDevice.properties = {};
}
}
this.currentDevice = processedDevice;
this.isEdit = true;
this.dialogVisible = true;
},
@@ -193,6 +208,14 @@ export default {
this.dialogVisible = false;
// 重新加载设备列表
await this.loadDevices();
},
// 为区域主控设备添加高亮
tableRowClassName({ row, rowIndex }) {
if (row.type === 'area_controller') {
return 'current-row';
}
return '';
}
}
};