<el-tree
    :props="props"
    :load="loadNode"
     ref="tree"
     lazy
     accordion
     @node-click="handleNodeClick">
</el-tree>
export default {
data() {
    return {
      node_had: undefined,
      resolve_had : undefined
      }
}
  methods: {
 loadNode(node, resolve) {
        if (node.level === 0) {
          this.node_had = node // 保存一下根节点
          this.resolve_had = resolve // 保存一下根节点

          console.log('节点是根节点id=' + this.rootId +' 名字====' + this.rootName);
          return resolve([{ MDM_ORG_CODE:this.rootId,ORG_NAME: this.rootName }]);
        }else{
          console.log("获取到的node=" + node.data.MDM_ORG_CODE);
          let paraobj = node.data.MDM_ORG_CODE ;
          this.commonSearchT(paraobj, resolve);
        }
      },

clearTree(){// 清空树的方法
      this.node_had.childNodes = [];
      this.loadNode(this.node_had, this.resolve_had); //再次执行懒加载的方法
    }
}

 

Logo

前往低代码交流专区

更多推荐