田源
2023-10-10 e044be08ece38af7a400fb7f3eacdda2e4fc4113
整合代码
已修改1个文件
15 ■■■■ 文件已修改
Source/UBCS-WEB/src/views/integration/systemInfo.vue 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS-WEB/src/views/integration/systemInfo.vue
@@ -159,35 +159,35 @@
      if (checked) {
        this.addAllChildren(row.children);
        this.addToParentList(row);
        // 勾选行时,将当前行以及其所有子节点添加到ParentList中
        // 勾选行时将所有节点添加到ParentList中
      } else {
        this.removeAllChildren(row.children);
        this.removeFromParentList(row);
        // 取消勾选行时,将当前行以及其所有子节点从ParentList中移除
        // 取消勾选将所有节点添加从ParentList中移除
      }
      // console.table(this.ParentList);
    },
    //子节点添加
    addAllChildren(children) {
      for (let child of children) {
        this.addToParentList(child);
        // 将子节点添加到 ParentList 中
        if (child.children && child.children.length > 0) {
          this.addAllChildren(child.children);
          // 递归调用继续添加子节点的子节点
        }
      }
    },
    //子节点移除
    removeAllChildren(children) {
      for (let child of children) {
        this.removeFromParentList(child);
        // 将子节点从 ParentList 中移除
        if (child.children && child.children.length > 0) {
          this.removeAllChildren(child.children);
          // 递归调用继续移除子节点的子节点
        }
      }
    },
    //当前父节点添加
    addToParentList(item) {
      const classifyOid = item.attributes.classifyOid;
      if (!this.isClassifyOidExists(classifyOid)) {
@@ -197,9 +197,9 @@
          classifyOid: classifyOid,
        };
        this.ParentList.push(record);
        // 将节点添加到ParentList中
      }
    },
    //当前父节点移除
    removeFromParentList(item) {
      const classifyOid = item.attributes.classifyOid;
      if (this.isClassifyOidExists(classifyOid)) {
@@ -207,12 +207,13 @@
        if (index !== -1) {
          this.ParentList.splice(index, 1);
        }
        // 将节点从ParentList中移除
      }
    },
    //判重-ParentList
    isClassifyOidExists(classifyOid) {
      return this.ParentList.some(item => item.classifyOid === classifyOid);
    },
    //查找index位置
    findIndexByClassifyOid(classifyOid) {
      return this.ParentList.findIndex(item => item.classifyOid === classifyOid);
    },