田源
2024-01-25 49345facf3334b3b35d603e732dd69db6a294e6d
Source/UBCS-WEB/src/components/Theme/ThemeClassifyTrees.vue
@@ -49,7 +49,7 @@
                     :defaultExpandAll="false"
                     :option="Treeoption"
                     class="classifyTree"
                     style="height: 690px"
                     style="height: 610px"
                     @node-click="nodeClick"
          >
            <template slot-scope="{ node, data }" class="el-tree-node__label">
@@ -512,6 +512,7 @@
      Treedata: [],
      CloneTreedata: [],
      Treeoption: {
        height:'auto',
        addBtn: false,
        editBtn: false,
        delBtn: false,
@@ -708,7 +709,7 @@
    },
    treeStyle() {
      return {
        height: this.btnAuthList.length > 0 ? '620px' : '785px',
        height: this.allButtons ? '610px' : '690px',
      };
    },
    crudTreeOption() {
@@ -1151,6 +1152,9 @@
    },
    //树点击事件
    async nodeClick(data) {
      const response = this.findTheTopLevelNode(data,this.Treedata)
      console.log(response)
      console.log('response',response.attributes.id)
      this.allButtons = true;
      getAuthButtonList({classifyId: data.oid, code: "classifyTree", authType: "classify_auth"}).then(res => {
        this.btnAuthList = res.data.data;
@@ -1196,6 +1200,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({