elementui el-tree复选框是否被选中

<el-tree ref="treeX" accordion :check-strictly="true" :data="organizationList"
   :props="organizationProps" show-checkbox node-key="id" :expand-on-click-node='true'
    @check-change="handleCheckChange"></el-tree>
// 新增
showplan() {
      let self = this
      setTimeout(() => {
        self.$refs.treeX.setCheckedKeys([])
      }, 0)
},
// 编辑
updateDialog(row) {
      let self = this
      setTimeout(() => {
        self.$refs.treeX.setCheckedKeys(row.orgIdList)
      }, 0)
},
handleCheckChange(data, checked, indeterminate) {
      if (checked) {
        this.checkedKeyArr.push(data.id)
        this.checkedKeyArr = Array.from(new Set(this.checkedKeyArr)) //数组去重
        this.checkedKeyStr = this.checkedKeyArr.join(',') // 把选中的节点id数组转为字符串传给后台的参数
      } else {
        this.checkedKeyArr.splice(this.checkedKeyArr.findIndex(v => v === data.id),1)
        this.checkedKeyStr = this.checkedKeyArr.join(',')
      }
},

猜你喜欢

转载自blog.csdn.net/weixin_43173924/article/details/89379511