管道基础大数据平台系统开发-【前端】-新系統界面
Surpriseplus
2023-03-09 94174101b5e3c7b952a5bf5c2626f0a8f2ead3dd
在线制图修改
已修改1个文件
149 ■■■■ 文件已修改
src/views/exportMap/index.vue 149 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/exportMap/index.vue
@@ -324,9 +324,12 @@
      value: "A4",
      treeData: [],
      arrList: [],
      layername: [
        1, 2, 5, 13, 15, 31
      ],
      defaultProps: {
        children: "children",
        label: "label",
        label: "cnName",
      },
      draw: null,
      vector: null,
@@ -338,6 +341,7 @@
        pageIndex: 1,
      },
      count: 0,
    }
  },
@@ -347,88 +351,67 @@
    this.showMapLayer()
  },
  methods: {
    setTreeData(source) {
      let cloneData = JSON.parse(JSON.stringify(source)); // 对源数据深度克隆
      return cloneData.filter((father) => {
        // 循环所有项
        let branchArr = cloneData.filter((child) => father.id == child.pid); // 对比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.pid == 0; // 返回一级菜单
      });
    },
    async LayerStart() {
      const data = await perms_selectLayers()
      if (data.code != 200) {
        return this.$message.error("图层列表查询失败")
      }
      var std = []
      var layer_list = []
      var layer_groups = []
      for (var i in data.result) {
        if (data.result[i].type == 1) {
          layer_groups.push({
            id: data.result[i].id,
            label: data.result[i].cnName,
            type: data.result[i].type,
            isEdit: false,
            children: [],
          })
        } else if (data.result[i].type == 2) {
          if (data.result[i].url != null) {
            var layer_entity = {
              id: data.result[i].id,
              pid: data.result[i].pid,
              label: data.result[i].cnName,
              resource: data.result[i].url,
              type: data.result[i].type,
              isEdit: false,
            }
            layer_list.push(layer_entity)
            if (data.result[i].isShow == 1) {
              std.push(data.result[i].id)
              this.tableData.push({
                name: layer_entity.label,
              })
              this.showMapLayer(layer_entity)
            }
          }
        }
      }
      for (var i in layer_list) {
        for (var j in layer_groups) {
          if (layer_list[i].pid === layer_groups[j].id) {
            layer_groups[j].children.push(layer_list[i])
          }
        }
      }
      layer_groups = layer_groups.filter((res) => {
        if (res.children != null && res.children.length != 0) {
          return res
        }
      })
      this.treeData = layer_groups;
      var res = data.result;
      // for (var i in data.result) {
      //   if (data.result[i].type == 2 && data.result[i].url != null) {
      //     for (var j = 0; j <  window.mapView.imageryLayers._layers.length; j++) {
      //       var val_id = window.mapView.imageryLayers._layers[j]
      //       if (val_id.show == true) {
      //         if (val_id.imageryProvider.name == data.result[i].cnName) {
      //           std.push(data.result[i].id)
      //         }
      //       }
      //     }
      //   }
      // }
      var val = [];
      var std = [];
      for (var i in res) {
        var str = res[i];
        if (str.type == 1 && this.layername.indexOf(str.id) != -1) {
          val.push(str)
        } else if (str.url != null && str.type == 2 && this.layername.indexOf(str.pid) != -1) {
          if (str.isShow == 1) {
            std.push(str.id)
            this.showMapLayer(str)
            this.tableData.push({
              name: str.cnName,
              ename: str.enName,
            })
          }
          val.push(str)
        }
      }
      var res = this.setTreeData(val);
      this.treeData = res;
      this.$refs.tree.setCheckedKeys(std)
    },
    showMapLayer(val) {
      if (val == undefined) return;
      var layer2 = new Image({
        name: val.label,
        source: new ImageWMS({
          crossOrigin: "anonymous",
          url: geoServerURl,
      if (val.serveType == "WMS") {
        var layer2 = new Image({
          name: val.cnName,
          source: new ImageWMS({
            crossOrigin: "anonymous",
            url: geoServerURl,
          params: {
            FORMAT: "image/png",
            VERSION: "1.1.1",
            LAYERS: val.resource,
          },
        }),
      })
      mapView.addLayer(layer2)
            params: {
              FORMAT: "image/png",
              VERSION: "1.1.1",
              LAYERS: val.url,
            },
          }),
        })
        mapView.addLayer(layer2)
      }
    },
    showLeftMenu(res) {
      switch (res) {
@@ -597,7 +580,7 @@
      this.loading = true
      var val_data = []
      for (var i in this.tableData) {
        val_data.push(this.tableData[i].name)
        val_data.push(this.tableData[i].ename)
      }
      if (this.isActive) {
        val_data.push("矢量图")
@@ -612,20 +595,22 @@
    handleClose() { },
    handleTreeNodeClick(data, nodes) {
      if (data.children != null) return
      var layers = mapView.getAllLayers()
      for (var i in layers) {
        var layer = layers[i]
        var str = 0
        if (layer.values_.name == data.label) {
        if (layer.values_.name == data.cnName) {
          layer.setVisible(nodes) //显示图层
          if (nodes == true) {
            str++
            this.tableData.push({
              name: data.label,
              name: data.cnName,
              ename: data.enName
            })
          } else {
            this.tableData.some((item, i) => {
              if (item.name === data.label) {
              if (item.name === data.cnName) {
                this.tableData.splice(i, 1)
              }
            })
@@ -636,7 +621,8 @@
      if (str == 0 && nodes == true) {
        this.showMapLayer(data)
        this.tableData.push({
          name: data.label,
          name: data.cnName,
          ename: data.enName,
        })
      }
@@ -796,5 +782,14 @@
  /deep/.el-form-item {
    margin-top: 10px;
  }
  /deep/ .el-tree-node {
    .is-leaf + .el-checkbox .el-checkbox__inner {
      display: inline-block;
    }
    .el-checkbox .el-checkbox__inner {
      display: none;
    }
  }
}
</style>