美文网首页
el-tree 选中取消 回显

el-tree 选中取消 回显

作者: 疯泽清 | 来源:发表于2021-11-03 09:04 被阅读0次
image.png
  1. <el-input placeholder="输入关键字进行过滤"
    v-model="filterText"
    @input='filterTextchange'
    style='margin-bottom: 20px;'>
    </el-input>
    <el-tree class="filter-tree"
    :data="ruleForm.rangeType==10?unionList:industryCategory"
    accordion
    node-key="id"
    show-checkbox
    default-expand-all
    :default-checked-keys="treekeydata"
    :props="defaultProps"
    @check="handleCheckChange"
    :filter-node-method="filterNode"
    ref="tree">
    </el-tree>
    2 . treekeydata Array tree选中的key
    treedata1 Array 右边tree的数据

  2. 选中节点事件
    handleCheckChange (data, checked) {
    let keyFalg = this.treedata1.findIndex(item => item.code == data.code)
    if (keyFalg == -1) {
    this.set(data, 'isCheck', true) this.treedata1.push(data) } else { this.treedata1.splice(keyFalg, 1) this.treekeydata = this.treedata1.map(item => item.id) console.log(this.treekeydata); } this.treekeydata = this.refs.tree.getCheckedKeys(true)
    this.treekeydata = this.treedata1.map(item => item.id)

    },
    //右边删除事件
    handleClose (data) {
    this.treedata1.splice(this.treekeydata.indexOf(data.id), 1)
    this.treekeydata.splice(this.treekeydata.indexOf(data.id), 1)

    this.$refs.tree.setCheckedKeys(this.treekeydata)
    },

相关文章

网友评论

      本文标题:el-tree 选中取消 回显

      本文链接:https://www.haomeiwen.com/subject/gquqzltx.html