管道基础大数据平台系统开发-【前端】-新系統界面
修改图层管理逻辑(选中项目后去除其它项目图层,去除项目时恢复原始图层信息)
已修改1个文件
32 ■■■■■ 文件已修改
src/views/Tools/LayerTree.vue 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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;
@@ -717,6 +721,34 @@
        layers.push(data);
      }
    },
    // 获取新树数据
    getNewTreeData (code) {
      if (!code) return this.sourceData;
      let data = JSON.parse(JSON.stringify(this.sourceData));
      this.setSubTreeData(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);
        }
      }
    },
    // 添加WFS图层 *
    addWFSLayers (res) {
      let url =