diff --git a/src/views/commonPage/tree.vue b/src/views/commonPage/tree.vue index cbdd14a..b61eace 100644 --- a/src/views/commonPage/tree.vue +++ b/src/views/commonPage/tree.vue @@ -115,8 +115,7 @@ const loadNode = async (node: any, resolve: any) => { console.log(node, node.level, "4------"); // 利用设备中的信息调用接口 // --------- - //点中第4层 为台区时 去返回id到父组件 并让父组件获取可调资源的相关信息和表格 - emits("update-node-key", node.key); //获取id,用于二级接口服务返回接口给可调资源列表 + // --------- //懒加载 let res = await treeSecond({ @@ -126,7 +125,8 @@ const loadNode = async (node: any, resolve: any) => { if ( res.data.photoVoltaicUnit.length || res.data.energySupplyStation.length || - res.data.batteryUnit.length + res.data.batteryUnit.length || + res.data.dwellerPile.length ) { let datanames = []; if (res.data.photoVoltaicUnit.length) { @@ -146,15 +146,12 @@ const loadNode = async (node: any, resolve: any) => { name: `储能(${res.data.batteryUnit.length})`, id: "chuneng", }); - if (res.data.dwellerPile.length) { - datanames.push({ - name: `居民充电桩(${res.data.dwellerPile.length})`, - id: "chongdianzhuang", - }); - } - - // ---------- - // 返回id + } + if (res.data.dwellerPile.length) { + datanames.push({ + name: `居民充电桩(${res.data.dwellerPile.length})`, + id: "chongdianzhuang", + }); } resolve(datanames); } else { @@ -229,9 +226,19 @@ const emits = defineEmits(["update-node-key"]); ////接收父组件的事件, // 点击树节点 // 处理选中target数据,最终得到由高层到底层的数组 -const handleTargetInfo = (data: TreeData, e: any) => { +const handleTargetInfo = (data: TreeData, e: any, node: any) => { // targetInfo.resultArr = []; // handleTarget(e); + + console.log("zheshishaya111",node.level,data); + + if (node.level === 4) { + console.log(node.level,'0000',node.key); + + console.log("zheshishaya"); + //点中第4层 为台区时 去返回id到父组件 并让父组件获取可调资源的相关信息和表格 + emits("update-node-key", node.key); //获取id,用于二级接口服务返回接口给可调资源列表 + } }; const handleTarget = (node: any) => { // 递归得到target结果数组