前端默认展开设备列表

This commit is contained in:
2025-09-09 19:16:13 +08:00
parent d7c2ffb108
commit 52cf8c58ed
4 changed files with 27 additions and 8 deletions

View File

@@ -289,6 +289,8 @@ export default {
if (response.ok && data.code === 0) {
this.devices = data.data.devices
// 默认展开所有节点
this.expandAllNodes()
} else {
console.error('获取设备列表失败:', data.message)
}
@@ -297,6 +299,23 @@ export default {
}
},
// 展开所有节点
expandAllNodes() {
// 清空当前展开的节点
this.expandedNodes.clear()
// 展开所有中继设备节点
this.relayDevices.forEach(relay => {
this.expandedNodes.add(relay.id)
// 展开所有控制器设备节点
const controllers = this.getControllerDevices(relay.id)
controllers.forEach(controller => {
this.expandedNodes.add(controller.id)
})
})
},
// 打开添加设备模态框
openAddDeviceModal() {
this.editingDevice = null