/**
* @description: 添加tree_id
*/
treeData(data) {
for (let i = 0; i < data.length; i++) {
data[i].tree_id = `${data[i].id}_${data[i].name}`; // 给每一个节点加上唯一键值
if (data[i].children && data[i].children.length > 0) {
this.treeData(data[i].children);
}
}
return data;
},
/**
* @description: 深度遍历以寻找第一个配电室
*/
depthTree(data) {
let vm = this;
for (let i = 0; i < data.length; i++) {
if (data[i].modelLabel === "room") {
vm.firstNode.push(data[i]); // 用firstNode存储找到的配电室节点
}
if (data[i].children && data[i].children.length > 0) {
this.depthTree(data[i].children);
}
}
return;
},