Vue中使用ztree实现树形结构

1 篇文章 0 订阅
  • 官网链接 点击这里,
  • 效果图
    这里写图片描述

  • 后端返回数据结构为Object
    这里写图片描述

  • html部分:

<el-form-item label="所属部门:" prop="depname"   class="daiSelectUserInp subordinateDepartments">      
   <el-input 
     v-model.trim="form.depname" 
     @change='onchangeDept'
     size="small"
     @focus="showDept"
     suffix-icon="el-icon-search">
    </el-input>
 </el-form-item>
 <div class="aui-dd-parent resize-to-input" v-show="isShowDept">
   <div class="aui-dropdown aui-dropdown-left">
     <div class="departTree userTree">
       <zTree
         :zTreeId ="zTreeId"
         :treeData="zTreeData"
         :showOperIcon="showOperIcon"
         :dataConfig="zTreeDataConfig"
         :isDrag="zTreeIsDrag"
         @clickNode="clickDepartNode">
       </zTree>
     </div>
   </div>
 </div>
  • 初始化必要数据
    这里写图片描述
  • method
    //搜索所属部门
      onchangeDept:function(value){
        this.showDept();
      },
     // 查询部门树
      showDept(){
        var that = this;
        that.isShowDept =true;
        var param = {
          searchVal:that.form.depname,
          token:that._logintoken,
        };                                                                          
      getDepSubTreeList({queryStr:JSON.stringify(param)},that._logintoken).then(function(res){
          console.log("getDepSubTreeList+++++=========",res);
          if(res.STATUS="success" && res.RESULT!=null){
            that.zTreeData = res.RESULT;
          }
        }).catch(function (err) {

        });
      },
      //双击选中节点
    clickDepartNode:function (event, treeId, treeNode, clickFlag) {
       console.log("treeNode--",treeNode);
       this.isShowDept = false;
       this.form.depid = treeNode.id;
       this.form.depname = treeNode.depname;
     },
  • 2
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值