| | |
| | | }, |
| | | //树点击事件 |
| | | async nodeClick(data) { |
| | | const response = this.findTheTopLevelNode(data,this.Treedata) |
| | | console.log('response',response.label) |
| | | this.allButtons = true; |
| | | getAuthButtonList({classifyId: data.oid, code: "classifyTree", authType: "classify_auth"}).then(res => { |
| | | this.btnAuthList = res.data.data; |
| | |
| | | } |
| | | }, |
| | | |
| | | // 递归查找顶层节点Id |
| | | findTheTopLevelNode(data,TreeData){ |
| | | if(data.parentId === ""){ |
| | | return data; |
| | | } |
| | | const parentNode = this.findParentNode(data.parentId, TreeData); |
| | | if (parentNode) { |
| | | return this.findTheTopLevelNode(parentNode, TreeData); // 继续查找父节点 |
| | | } |
| | | }, |
| | | // 递归查找出来多层节点的父节点 |
| | | findParentNode(parentId, TreeData){ |
| | | for (const node of TreeData) { |
| | | if (node.oid === parentId) { |
| | | return node; |
| | | } |
| | | // 如果当前节点还有子节点,继续去查子节点的父节点 |
| | | if (node.children) { |
| | | const parentNode = this.findParentNode(parentId, node.children); |
| | | if (parentNode) { |
| | | return parentNode; |
| | | } |
| | | } |
| | | } |
| | | return null; |
| | | }, |
| | | async gridCode() { |
| | | try { |
| | | const res = await gridCodeClassifyTemplateAttr({ |