wchbrad / vue-easy-tree

A tree component based on vue2.x that supports a small amount of data or a large amount of data, multiple functions, and virtual scrolling.
MIT License
124 stars 39 forks source link

大数据量的数据回显问题,父级没有半选的状态 #44

Closed oubohua closed 7 months ago

oubohua commented 7 months ago
          这个还有点小问题,父级没有半选的状态。

Originally posted by @oubohua in https://github.com/wchbrad/vue-easy-tree/issues/43#issuecomment-1922739657

oubohua commented 7 months ago

或者有没有办法在赋值后触发check-change事件

wchbrad commented 7 months ago

稍加点东西即可


setTreeValue() {
      let arr = [];
      for (let i = 10; i < 3000; i++) {
        arr.push(`id-${i}`);
      }
      const allNodes = this.$refs["veTree"].store._getAllNodes();

      for (const node of allNodes) {
        if (arr.includes(node.key)) {
          node.checked = true;
          // 对父级节点增加半选效果
          if (node.parent && node.parent.indeterminate == false) {
            node.parent.indeterminate = true;
          }
        }
      }
    }