管道基础大数据平台系统开发-【前端】-新系統界面
Surpriseplus
2023-03-23 98aec0baaef46392f6bede8f507466fc75eca137
src/views/datamanage/catalogueManage.vue
@@ -493,8 +493,11 @@
          exts: res[i].exts,
          orderNum: null,
          pid: null,
          tid: parseInt(value[2]) + 1,
          sid: parseInt(value[3]) + 1
        })
      }
      this.tableData = arr;
      this.setInsertData(this.tableData);
@@ -511,19 +514,20 @@
        }
      }
      if (chLevel == 1) {
        return [res['L' + chLevel], null]
        return [res['L' + chLevel], null, flag, -1]
      } else {
        faLevel = chLevel - 1;
        for (var i = flag; i >= 0; i--) {
          var val = result[i]
          if (val['L' + faLevel]) {
            return [res['L' + chLevel], val['L' + faLevel]]
            return [res['L' + chLevel], val['L' + faLevel], flag, i]
            break;
          }
        }
      }
    },
    setInsertData(res) {
      var list = this.excelData(res);
      if (list.length != 0) {
@@ -531,7 +535,7 @@
          return this.$message.error("上传数据错误,第一条数据不为空");
        }
        this.getAllNodeId(list);
        this.getAllNodeId(res);
      }
    },
    async getAllNodeId(res) {
@@ -542,8 +546,9 @@
          val.orderNum = this.dirList[this.dirList.length - 1].orderNum + 1;
          val.pid = 0;
        } else {
          this.tableData.filter((child) => {
            if (child.name == val.pname) {
            if (child.tid == val.sid) {
              val.pid = child.id;
              val.orderNum = i + 1;
            }
@@ -553,29 +558,31 @@
        const data = await insertDir(val);
        if (data.code != 200) {
        }
        this.tableData.filter((child) => {
          if (child.name == val.name && child.pname == val.pname) {
          if (child.name == val.name && child.tid == val.tid) {
            child.id = data.result;
          }
        });
        this.itemaName = data.result;
        this.getDirTree();
        if (res[i].children) {
          this.getAllNodeId(res[i].children);
        }
        // if (res[i].children) {
        //   this.getAllNodeId(res[i].children);
        // }
      }
    },
    excelData(source) {
      let cloneData = JSON.parse(JSON.stringify(source)); // 对源数据深度克隆
      return cloneData.filter((father) => {
        // 循环所有项
        let branchArr = cloneData.filter((child) => father.name == child.pname); // 对比ID,分别上下级菜单,并返回数据
        let branchArr = cloneData.filter((child) => father.tid == child.sid); // 对比ID,分别上下级菜单,并返回数据
        branchArr.length > 0 ? (father.children = branchArr) : ""; // 给父级添加一个children属性,并赋值
        // 属于同一对象问题,例如:令 a=b、c=1 ,然后再令 b.c=c , 那么 a.c=b.c=c=1 ;同理,后续令 c.d=2 ,那么 a.c.d 也是=2;
        // 由此循环多次后,就能形成相应的树形数据结构
        return father.pname == null; // 返回一级菜单
        return father.sid == 0; // 返回一级菜单
      });
    },
    readFile(file) {