田源
2024-01-25 eac13244556686dfecf5aaeb6efee931745b9cd7
Source/UBCS-WEB/src/components/Theme/ThemeClassifyTrees.vue
@@ -1151,6 +1151,8 @@
    },
    //树点击事件
    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;
@@ -1196,6 +1198,32 @@
      }
    },
    // 递归查找顶层节点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({