修改图层管理逻辑(选中项目后去除其它项目图层,去除项目时恢复原始图层信息)
| | |
| | | "m_sitepoint", |
| | | ], |
| | | treeData: [], // 树数据 |
| | | sourceData: [], // 源数据 |
| | | defaultProps: { // 默认属性值 |
| | | children: "children", |
| | | label: "cnName", |
| | |
| | | }); |
| | | // 存储选中图层 |
| | | this.treeData = this.setTreeData(layers); |
| | | this.sourceData = JSON.parse(JSON.stringify(this.treeData)); |
| | | this.$refs.tree.setCheckedKeys(checkKey); |
| | | sessionStorage.setItem("checkedLayers", JSON.stringify(checkedLayers)); |
| | | }, |
| | |
| | | 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; |
| | |
| | | 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 = |