管道基础大数据平台系统开发-【前端】-新系統界面
13693261870
2023-06-13 be4c814230641d490b218c8cb5bd29c51cab7978
src/views/Tools/LayerTree.vue
@@ -122,6 +122,7 @@
        "m_sitepoint",
      ],
      treeData: [], // 树数据
      sourceData: [], // 源数据
      defaultProps: { // 默认属性值
        children: "children",
        label: "cnName",
@@ -172,6 +173,7 @@
      });
      // 存储选中图层
      this.treeData = this.setTreeData(layers);
      this.sourceData = JSON.parse(JSON.stringify(this.treeData));
      this.$refs.tree.setCheckedKeys(checkKey);
      sessionStorage.setItem("checkedLayers", JSON.stringify(checkedLayers));
    },
@@ -677,6 +679,8 @@
        checkedKeys.push(checkedLayers[i].id);
      }
      this.treeData = this.getNewTreeData(code);
      this.$store.state.treeData = this.treeData;
      this.$refs.tree.setCheckedKeys(checkedKeys);
      sessionStorage.setItem("checkedLayers", JSON.stringify(checkedLayers));
      this.isBusy = false;
@@ -706,8 +710,13 @@
            continue;
          }
          if (layer.type == 2 && (layer.isProject || isPrj)) {
            layers.push(layer);
          //if (layer.type == 2 && (layer.isProject || isPrj)) {
          //  layers.push(layer);
          //}
          if (code) {
            if (layer.type == 2 && (layer.isProject || isPrj)) layers.push(layer);
          } else {
            if (layer.isShow) layers.push(layer);
          }
        }
        return;
@@ -717,6 +726,88 @@
        layers.push(data);
      }
    },
    // 获取新树数据
    getNewTreeData (code) {
      let data = JSON.parse(JSON.stringify(this.sourceData));
      if (!code) return data;
      this.setSubTreeData(data, code);
      this.rmPrjTreeData(data, code);
      return data;
    },
    // 设置树数据子节点
    setSubTreeData (data, code) {
      let j = 0;
      while (j < data.length) {
        let d = data[j];
        if (d.type == 1 && d.isProject && d.enName != code) {
          data.splice(j, 1);
          continue;
        }
        j++;
      }
      for (let i = 0, c = data.length; i < c; i++) {
        if (data[i].children && data[i].children.length) {
          this.setSubTreeData(data[i].children, code);
        }
      }
    },
    // 移除项目树数据
    rmPrjTreeData (data, code) {
      /*let j = 0;
      while (j < data.length) {
        let d = data[j];
        if (d.type == 1 && d.isProject && d.enName == code) {
          data.splice(j, 1);
          data.concat(d.children);
          continue;
        }
        j++;
      }
      for (let i = 0, c = data.length; i < c; i++) {
        if (data[i].children && data[i].children.length) {
          this.rmPrjTreeData(data[i].children, code);
        }
      }*/
      let i = 0;
      while (i < data.length) {
        let d = data[i];
        if (!d.children) {
          i++;
          continue;
        }
        if (!d.children.length) {
          data.splice(i, 1);
          continue;
        }
        let j = 0;
        while (j < d.children.length) {
          let e = d.children[j];
          if (e.type == 1 && e.isProject && e.enName == code) {
            d.children.splice(j, 1);
            if (e.children && e.children.length) d.children = d.children.concat(e.children);
            continue;
          }
          j++;
        }
        i++;
      }
      for (let i = 0, c = data.length; i < c; i++) {
        if (data[i].children && data[i].children.length) {
          this.rmPrjTreeData(data[i].children, code);
        }
      }
    },
    // 添加WFS图层 *
    addWFSLayers (res) {
      let url =