ludc
2023-09-28 de25a25c52aa3119fd80afb2804f8c570f0a8829
Source/UBCS-WEB/src/views/integration/systemInfo.vue
@@ -59,7 +59,7 @@
    return {
      checkAll: {},
      ParentList: [],
      ParentRemoveList:[],
      ParentRemoveList: [],
      //避免缓存
      reload: Math.random(),
      TreeLoading: false,
@@ -147,7 +147,7 @@
    //分类授权多选回调
    checkChange(row, checked) {
      if (checked) {
        if (!row.parentId && row.children) {
        if (!row.parentId) {
          const parentRecord = {
            oid: row.oid,
            classifyId: row.attributes.classifyId,
@@ -179,26 +179,41 @@
              }
            }
          }
          console.log(this.ParentList);
        }
      } else {
        if (!row.parentId && row.children) {
          this.ParentRemoveList = this.ParentList.filter(record => record.oid !== row.oid);
        // 取消勾选的节点是父节点
        if (!row.parentId) {
          // 找到父节点在ParentList中的索引
          const parentIndex = this.ParentList.findIndex(item => item.oid === row.oid);
          if (parentIndex !== -1) {
            const parentOid = this.ParentList[parentIndex].classifyOid;
          if (row.children && row.children.length > 0) {
            for (let child of row.children) {
              this.ParentRemoveList = this.ParentList.filter(record => record.oid !== child.oid);
              if (child.children && child.children.length > 0) {
                for (let subChild of child.children) {
                  this.ParentRemoveList = this.ParentList.filter(record => record.oid !== subChild.oid);
                }
            // 查找所有需要删除的子节点的索引
            const childIndexes = this.ParentList.reduce((indexes, item, index) => {
              if (item.classParentOid === parentOid && item.classifyOid !== parentOid) {
                indexes.push(index);
              }
              return indexes;
            }, []);
            // 从后往前删除子节点的数据,保证索引的正确性
            for (let i = childIndexes.length - 1; i >= 0; i--) {
              this.ParentList.splice(childIndexes[i], 1);
            }
            // 删除父节点的数据
            this.ParentList.splice(parentIndex, 1);
          }
        } else {
          // 取消勾选的节点是子节点
          const childIndex = this.ParentList.findIndex(item => item.oid === row.oid);
          if (childIndex !== -1) {
            // 删除子节点的数据
            this.ParentList.splice(childIndex, 1);
          }
        }
        console.log(this.ParentRemoveList)
      }
      console.log(this.ParentList);
    },
    //分类授权
    classifyHandler(row) {