| | |
| | | autofocus |
| | | v-model="data.label" |
| | | :ref="'slotTreeInput' + data.id" |
| | | @blur.stop="NodeBlur(node, data)" |
| | | @keydown.native.enter="NodeBlur(node, data)"></el-input> |
| | | @blur.stop="nodeBlur(node, data)" |
| | | @keydown.native.enter="nodeBlur(node, data)"></el-input> |
| | | </span> |
| | | </span> |
| | | </el-tree> |
| | |
| | | v-show="menuVisible"> |
| | | <div class="edit" |
| | | @click="showLayerAttribute()" |
| | | v-if="!showlocal && !shwoHistogram" |
| | | v-show="!firstLevel"> |
| | | v-if="showProp && !shwoHistogram"> |
| | | <i class="el-icon-tickets"></i> 属性 |
| | | </div> |
| | | <div class="edit" |
| | | @click="positioning()" |
| | | v-if="showlocal"> |
| | | v-if="showLocal"> |
| | | <i class="el-icon-tickets"></i> 定位 |
| | | </div> |
| | | <div class="edit" |
| | | @click="pellucidity()" |
| | | v-if="showlocal"> |
| | | v-if="showOpacity"> |
| | | <i class="el-icon-tickets"></i> 透明度 |
| | | </div> |
| | | <div class="edit" |
| | |
| | | <i class="el-icon-tickets"></i> 钻孔柱状图 |
| | | </div> |
| | | </el-card> |
| | | <el-dialog :title="appendNodetitle" |
| | | :visible.sync="dialogVisible" |
| | | width="30%" |
| | | top="20vh" |
| | | :modal="false" |
| | | :before-close="handleClose"> |
| | | <el-form ref="form" |
| | | :model="addFormServer" |
| | | label-width="100px"> |
| | | <el-form-item label="服务类型"> |
| | | <el-select style="width: 100%" |
| | | :popper-append-to-body="false" |
| | | v-model="addFormServer.serveType" |
| | | placeholder="请选择"> |
| | | <el-option v-for="item in options" |
| | | :key="item.value" |
| | | :label="item.label" |
| | | :value="item.value"> |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="图层名称"> |
| | | <el-input v-model="addFormServer.cnName"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="服务名称"> |
| | | <el-input v-model="addFormServer.url"></el-input> |
| | | </el-form-item> |
| | | |
| | | <el-form-item label="服务地址"> |
| | | <el-input v-model="addFormServer.resource"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="透明度"> |
| | | <el-slider v-model="addFormServer.opacity"></el-slider> |
| | | </el-form-item> |
| | | </el-form> |
| | | <span slot="footer" |
| | | class="dialog-footer"> |
| | | <el-button type="primary" |
| | | @click="setAddServer">确 定</el-button> |
| | | </span> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import { image_layer } from "../../assets/js/index.js"; |
| | | import ImageWMS from "ol/source/ImageWMS"; |
| | | import Image from "ol/layer/Image"; |
| | | import GeoJSON from "ol/format/GeoJSON.js"; |
| | | import Map from "ol/Map.js"; |
| | | import queryinfo from "./queryinfo.vue"; |
| | | import { Vector as VectorSource } from "ol/source"; |
| | | import { Vector as VectorLayer } from "ol/layer"; |
| | | import { perms_selectLayers, comprehensive_selectPubById, project_selectDirAll, project_selectByDirid, } from "../../api/api.js"; |
| | | |
| | | import View from "ol/View.js"; |
| | | import { Fill, Stroke, Style } from "ol/style.js"; |
| | | import { |
| | | perms_selectLayers, inquiry_selectDomains, comprehensive_selectPubById, |
| | | project_selectDirAll, project_selectByDirid, dataQuerySelectWktById |
| | | } from "../../api/api.js"; |
| | | export default { |
| | | name: "tree", |
| | | components: { queryinfo }, |
| | | data () { |
| | | return { |
| | | shwoHistogram: false, |
| | | showlocal: false, |
| | | showProp: false, // 属性 |
| | | shwoHistogram: false, // 钻孔柱状图 |
| | | showLocal: false, // 定位 |
| | | showOpacity: false, // 不透明度 |
| | | menuVisible: false, // 菜单 |
| | | levelArray: [ // 调试数组 |
| | | 0, 40000000, 20000000, 10000000, 5000000, 2000000, 1000000, 500000, |
| | | 250000, 200000, 100000, 50000, 17000, 9000, 5000, 2000, 1000, 500, 200, |
| | | 100, 50, 25, 10, 0, |
| | | ], |
| | | eleId: "", |
| | | isShow: false, |
| | | currentData: "", |
| | | currentNode: "", |
| | | menuVisible: false, |
| | | firstLevel: false, |
| | | filterText: "", |
| | | appendNodetitle: "", |
| | |
| | | children: "children", |
| | | label: "cnName", |
| | | }, |
| | | options: [ |
| | | { |
| | | value: "WMS", |
| | | label: "WMS", |
| | | }, |
| | | { |
| | | value: "WFS", |
| | | label: "WFS", |
| | | }, |
| | | options: [{ |
| | | value: "WMS", |
| | | label: "WMS", |
| | | }, { |
| | | value: "WFS", |
| | | label: "WFS", |
| | | }, |
| | | ], |
| | | childOption: [], |
| | | mptLayer: [], |
| | |
| | | proValue: null, |
| | | }; |
| | | }, |
| | | watch: { |
| | | filterText (val) { |
| | | this.$refs.tree.filter(val); |
| | | }, |
| | | }, |
| | | mounted () { |
| | | this.getMenus() |
| | | this.$bus.$on("treeDataCopy", (res) => { |
| | | this.$store.state.treeData = this.treeData; |
| | | this.$store.state.checkedKeys = this.$refs.tree.getCheckedKeys(); |
| | | }); |
| | | if (this.$store.state.showAllLayers) { |
| | | this.layersStart(); |
| | | this.$store.state.showAllLayers = false; |
| | | } else { |
| | | this.treeData = this.$store.state.treeData; |
| | | this.$refs.tree.setCheckedKeys(this.$store.state.checkedKeys); |
| | | } |
| | | }, |
| | | methods: { |
| | | //转孔柱状图 |
| | | // 获取菜单 |
| | | async getMenus () { |
| | | let data = await project_selectDirAll(); |
| | | if (data && data.code == 200) this.optionts = data.result; |
| | | }, |
| | | // 初始化图层 |
| | | async layersStart () { |
| | | let data = await perms_selectLayers(); |
| | | if (data.code != 200) { |
| | | return this.$message.error("图层列表查询失败"); |
| | | } |
| | | |
| | | let checkKey = [], checkedLayers = []; |
| | | var layers = data.result.filter((lyr) => { |
| | | if (lyr.url && lyr.type == 2 && lyr.isShow == 1) { |
| | | checkKey.push(lyr.id); |
| | | if (lyr.serveType == "WMS") checkedLayers.push(lyr); |
| | | } |
| | | return lyr; |
| | | }); |
| | | // 存储选中图层 |
| | | this.treeData = this.setTreeData(layers); |
| | | this.$refs.tree.setCheckedKeys(checkKey); |
| | | sessionStorage.setItem("checkedLayers", JSON.stringify(checkedLayers)); |
| | | }, |
| | | // 设置树数据 |
| | | 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; // 返回一级菜单 |
| | | }); |
| | | }, |
| | | // 节点获得焦点事件 |
| | | nodeBlur (node, data) { |
| | | if (!data.label.length) return this.$message.error("菜单名不可为空!"); |
| | | if (data.isEdit) this.$set(data, "isEdit", false); |
| | | this.$nextTick(() => { |
| | | this.$refs["slotTreeInput" + data.id].$refs.input.focus(); |
| | | }); |
| | | }, |
| | | // 鼠标左击事件 |
| | | handleLeftclick (data, node) { |
| | | this.rmListener(); |
| | | }, |
| | | // 取消鼠标监听事件 |
| | | rmListener () { |
| | | this.menuVisible = false; |
| | | // 要及时关掉监听,不关掉的是一个坑,不信你试试,虽然前台显示的时候没有啥毛病,加一个alert你就知道了 |
| | | document.removeEventListener("click", this.rmListener); |
| | | }, |
| | | // 过滤节点 |
| | | filterNode (value, data) { |
| | | if (!value) return true; |
| | | return data.cnName.indexOf(value) !== -1; |
| | | }, |
| | | // 鼠标右击事件 |
| | | rightClick (event, object, node, element) { |
| | | debugger |
| | | if (object.type == 1 || node.data.children != null) return; |
| | | |
| | | this.currentNode = node; |
| | | this.currentData = object; |
| | | this.$store.state.propertiesName = object; |
| | | |
| | | this.showProp = object.serveType == "WMS"; // 属性 |
| | | this.shwoHistogram = this.showProp && object.enName == "s_explorationpoint"; // 钻孔柱状图 |
| | | this.showLocal = ["Tileset", "3DML", "Mpt", "TMS", "DOM", "DEM"].indexOf(object.serveType) > -1; // 定位 |
| | | this.showOpacity = ["Tileset", "3DML"].indexOf(object.serveType) > -1; // 不透明度 |
| | | this.menuVisible = this.showProp || this.shwoHistogram || this.showLocal || this.showOpacity; // 菜单 |
| | | |
| | | this.$refs.card.$el.style.left = event.pageX + 20 + "px"; |
| | | this.$refs.card.$el.style.top = event.pageY + "px"; |
| | | }, |
| | | // 属性显示 |
| | | showLayerAttribute (data) { |
| | | this.rmListener(); |
| | | this.currentData = data ? data : this.currentData; |
| | | var layer = this.currentData.enName.replaceAll("_", ""); |
| | | this.$store.state.mapSpaceQueryLayer = layer; |
| | | this.$store.state.showPopBoxFlag = true; |
| | | this.$store.state.mapPopBoxFlag = "2"; |
| | | }, |
| | | // 定位 |
| | | async positioning () { |
| | | this.menuVisible = false; |
| | | if (["Tileset", "3DML"].indexOf(this.currentData.serveType) > -1) { |
| | | for (var i in Viewer.scene.primitives._primitives) { |
| | | if (Viewer.scene.primitives._primitives[i].id == this.currentData.cnName) { |
| | | Viewer.flyTo(Viewer.scene.primitives._primitives[i]); |
| | | break; |
| | | } |
| | | } |
| | | return; |
| | | } |
| | | |
| | | if (["TMS", "DOM", "DEM"].indexOf(this.currentData.serveType) > -1 && this.currentData.pubid) { |
| | | var data = await comprehensive_selectPubById({ id: this.currentData.pubid }); |
| | | if (data.result && data.result.geom) { |
| | | var wkt = this.$wkt.parse(data.result.geom); |
| | | var height = this.getHeight(wkt.coordinates[2]); |
| | | Viewer.camera.flyTo({ |
| | | destination: Cesium.Cartesian3.fromDegrees(wkt.coordinates[1], wkt.coordinates[0], height), // 2000 |
| | | }); |
| | | } |
| | | return; |
| | | } |
| | | |
| | | if ("Mpt" == this.currentData.serveType) { |
| | | viewer.camera.flyTo({ destination: Cesium.Cartesian3.fromDegrees(101.8, 37.9, 10000000.0) }); // 中国 |
| | | } |
| | | }, |
| | | // 钻孔柱状图 |
| | | async histogram () { |
| | | this.menuVisible = false |
| | | var layer = this.currentData.enName.replaceAll("_", ""); |
| | |
| | | this.$store.state.mapPopBoxFlag = "2"; |
| | | this.$store.state.showPopBoxFlag = true; |
| | | }, |
| | | modelAttach () { |
| | | this.menuVisible = false; |
| | | this.$store.state.attachinfo = this.currentData; |
| | | this.$store.state.attachModel = true; |
| | | }, |
| | | NodeBlur (Node, data) { |
| | | if (data.label.length === 0) { |
| | | this.$message.error("菜单名不可为空!"); |
| | | return false; |
| | | } else { |
| | | if (data.isEdit) { |
| | | this.$set(data, "isEdit", false); |
| | | } |
| | | this.$nextTick(() => { |
| | | this.$refs["slotTreeInput" + data.id].$refs.input.focus(); |
| | | }); |
| | | } |
| | | }, |
| | | allowDrop (draggingNode, dropNode, type) { |
| | | if (dropNode.data.label === "二级 3-1") { |
| | | return type !== "inner"; |
| | | } else { |
| | | return true; |
| | | } |
| | | }, |
| | | allowDrag (draggingNode) { |
| | | return draggingNode.data.label.indexOf("三级 3-2-2") === -1; |
| | | }, |
| | | // 鼠标右击事件 |
| | | rightClick (event, object, Node, element) { |
| | | if (object.type == 1) { |
| | | return |
| | | } |
| | | this.currentData = object; |
| | | this.currentNode = Node; |
| | | |
| | | this.$store.state.propertiesName = this.currentData; |
| | | if (this.currentData.serveType == "Tileset" || this.currentData.serveType == "3DML") { |
| | | this.showModelAttach = true; |
| | | } else { |
| | | this.showModelAttach = false; |
| | | } |
| | | if (this.currentData.enName == "s_explorationpoint") { |
| | | this.shwoHistogram = true; |
| | | } else { |
| | | this.shwoHistogram = false; |
| | | } |
| | | |
| | | if (Node.data.children == null) { |
| | | this.firstLevel = false; |
| | | } else { |
| | | this.firstLevel = true; |
| | | } |
| | | if (Node.data.children == null && Node.data.serveType == "Tileset" || Node.data.serveType == "3DML") { |
| | | this.showlocal = true; |
| | | } else if (Node.data.children == null && Node.data.serveType != "Tileset" || Node.data.serveType == "3DML") { |
| | | this.showlocal = false; |
| | | } |
| | | this.menuVisible = true; |
| | | |
| | | this.$refs.card.$el.style.left = event.pageX + 20 + "px"; |
| | | this.$refs.card.$el.style.top = event.pageY + "px"; |
| | | }, |
| | | // 鼠标左击事件 |
| | | handleLeftclick (data, node) { |
| | | this.foo(); |
| | | if (node.checked == true) { |
| | | for (var i = 0; i < window.Viewer.imageryLayers._layers.length; i++) { |
| | | var val_id = |
| | | window.Viewer.imageryLayers._layers[i].imageryProvider.name; |
| | | if (val_id == data.label) { |
| | | const img_layer = window.Viewer.imageryLayers._layers[i]; |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | // 取消鼠标监听事件 菜单栏 |
| | | foo () { |
| | | this.menuVisible = false; |
| | | // 要及时关掉监听,不关掉的是一个坑,不信你试试,虽然前台显示的时候没有啥毛病,加一个alert你就知道了 |
| | | document.removeEventListener("click", this.foo); |
| | | }, |
| | | // 增加同级节点事件 |
| | | addSameLevelNode () { |
| | | this.menuVisible = false |
| | | this.foo(); |
| | | if (this.currentNode.level == 2) { |
| | | this.appendNodetitle = this.currentData.label; |
| | | this.dialogVisible = true; |
| | | } else { |
| | | let id = Math.ceil(Math.random() * 100); |
| | | var data = { id: id, label: "新增节点" }; |
| | | this.$refs.tree.append(data, this.currentNode.parent); |
| | | } |
| | | }, |
| | | // 增加子级节点事件 |
| | | addChildNode () { |
| | | this.foo(); |
| | | this.menuVisible = false |
| | | // if (this.currentNode.level >= 2) { |
| | | // this.$message.error("最多只支两级!"); |
| | | // return false; |
| | | // } |
| | | this.appendNodetitle = this.currentData.label; |
| | | this.dialogVisible = true; |
| | | }, |
| | | handleClose () { |
| | | this.dialogVisible = false; |
| | | this.addFormServer = { |
| | | opacity: 100, |
| | | serveType: "WMS", |
| | | type: 2, |
| | | }; |
| | | }, |
| | | setAddServer () { |
| | | var val = this.currentNode; |
| | | if (this.currentNode.level == 2) { |
| | | val = this.currentNode.parent; |
| | | } |
| | | var data = this.addFormServer; |
| | | data.id = Math.ceil(Math.random() * 100); |
| | | this.$refs.tree.append(data, val); |
| | | this.handleClose(); |
| | | }, |
| | | // 删除节点 |
| | | deleteNode () { |
| | | this.foo(); |
| | | this.menuVisible = false |
| | | var label = this.currentNode.data.cnName; |
| | | if (this.currentNode.data.serveType == "WMS") { |
| | | var value = this.$refs.tree.getCheckedNodes(); |
| | | this.$bus.$emit("showMenuLayer", value); |
| | | } else if (this.currentNode.data.serveType == "WFS") { |
| | | for (var i in window.Viewer.dataSources._dataSources) { |
| | | if (window.Viewer.dataSources._dataSources[i].name == label) { |
| | | window.Viewer.dataSources.remove( |
| | | window.Viewer.dataSources._dataSources[i] |
| | | ); |
| | | } |
| | | } |
| | | } else if (this.currentNode.data.serveType == "Tileset") { |
| | | for (var i in Viewer.scene.primitives._primitives) { |
| | | // Viewer.scene.primitives._primitives[i].show = checked; |
| | | if (Viewer.scene.primitives._primitives[i].id == label) { |
| | | Viewer.scene.primitives.remove( |
| | | Viewer.scene.primitives._primitives[i] |
| | | ); |
| | | } |
| | | } |
| | | var list = this.$store.state.setAlphaList; |
| | | for (var i = 0; i < list.length; i++) { |
| | | if (list[i].name == label) { |
| | | list.splice(i, 1) |
| | | } |
| | | } |
| | | |
| | | } |
| | | var layers_ol = window.map.getAllLayers(); |
| | | for (var i in layers_ol) { |
| | | var layerOl = layers_ol[i]; |
| | | if (layerOl.values_.name == label) { |
| | | window.map.removeLayer(layerOl); //显示图层 |
| | | } |
| | | } |
| | | this.$refs.tree.remove(this.currentNode); |
| | | }, |
| | | //属性显示 |
| | | showLayerAttribute (data) { |
| | | this.foo(); |
| | | this.menuVisible = false |
| | | this.currentData = data ? data : this.currentData; |
| | | var layer = this.currentData.enName.replaceAll("_", ""); |
| | | this.$store.state.mapSpaceQueryLayer = layer; |
| | | this.$store.state.showPopBoxFlag = true; |
| | | this.$store.state.mapPopBoxFlag = "2"; |
| | | }, |
| | | //模型设置透明度 |
| | | // 透明度 |
| | | pellucidity () { |
| | | this.foo(); |
| | | this.rmListener(); |
| | | this.menuVisible = false |
| | | var tile = this.currentData |
| | | for (var j in Viewer.scene.primitives._primitives) { |
| | |
| | | } |
| | | } |
| | | }, |
| | | //模型定位 |
| | | positioning () { |
| | | this.menuVisible = false |
| | | for (var i in Viewer.scene.primitives._primitives) { |
| | | if ( |
| | | Viewer.scene.primitives._primitives[i].id == this.currentData.cnName |
| | | ) { |
| | | Viewer.flyTo(Viewer.scene.primitives._primitives[i]); |
| | | } |
| | | } |
| | | }, |
| | | // 编辑节点 |
| | | editNode (data) { |
| | | this.foo(); |
| | | this.menuVisible = false |
| | | this.currentData = data ? data : this.currentData; |
| | | if (!this.currentData.isEdit) { |
| | | this.$set(this.currentData, "isEdit", true); |
| | | } |
| | | // 获取焦点 |
| | | this.$nextTick(() => { |
| | | this.$refs["slotTreeInput" + this.currentData.id].focus(); |
| | | }); |
| | | }, |
| | | menuMoveF (type) { |
| | | // 将变动之前的node备份 |
| | | var node = this.currentNode; |
| | | var data = this.currentData; |
| | | let copyNode = this.currentNode; |
| | | // 获取高度 |
| | | getHeight (level) { |
| | | if (level > -1 && level < 23) return this.levelArray[level]; |
| | | |
| | | let nodeData = {}; |
| | | if (type === "up") { |
| | | // 上移 |
| | | if (node.previousSibling) { |
| | | // 删除原先的node |
| | | this.$refs.tree.remove(node.data); |
| | | // 拿到copy的node |
| | | // nodeData = CircularJSON.parse(window.sessionStorage.getItem('menuNode')) |
| | | // // 复制该node到指定位置(参数:1. 要增加的节点的 data 2. 要增加的节点的后一个节点的 data、key 或者 node) |
| | | // this.$refs.tree.insertBefore(nodeData.data,nodeData.previousSibling.data) |
| | | window.sessionStorage.removeItem("menuNode"); |
| | | } else { |
| | | this.$message.warning("该菜单已经是当前层最上级"); |
| | | } |
| | | } else { |
| | | // 下移 |
| | | if (node.nextSibling) { |
| | | this.$refs.tree.remove(node.data); |
| | | nodeData = CircularJSON.parse( |
| | | window.sessionStorage.getItem("menuNode") |
| | | ); |
| | | // 参数:1. 要增加的节点的 data 2. 要增加的节点的前一个节点的 data、key 或者 node |
| | | this.$refs.tree.insertAfter(nodeData.data, nodeData.nextSibling.data); |
| | | window.sessionStorage.removeItem("menuNode"); |
| | | } else { |
| | | this.$message.warning("该菜单已经是当前层最下级"); |
| | | } |
| | | } |
| | | }, |
| | | handleDragStart (node, ev) { |
| | | console.log("drag start", node); |
| | | }, |
| | | handleDragEnter (draggingNode, dropNode, ev) { |
| | | console.log("tree drag enter: ", dropNode.label); |
| | | }, |
| | | handleDragLeave (draggingNode, dropNode, ev) { |
| | | console.log("tree drag leave: ", dropNode.label); |
| | | }, |
| | | handleDragOver (draggingNode, dropNode, ev) { |
| | | console.log("tree drag over: ", dropNode.label); |
| | | }, |
| | | handleDragEnd (draggingNode, dropNode, dropType, ev) { |
| | | console.log("tree drag end: ", dropNode && dropNode.label, dropType); |
| | | }, |
| | | handleDrop (draggingNode, dropNode, dropType, ev) { |
| | | console.log("tree drop: ", dropNode.label, dropType); |
| | | return this.levelArray[this.levelArray.length - 1]; |
| | | }, |
| | | handleCheckChange (data, checked, indeterminate) { |
| | | if (data.type == 1) { |
| | |
| | | |
| | | layer.name = res.cnName; |
| | | if (data.result.geom) { |
| | | var wkt = this.$wkt.parse(data.result.geom); |
| | | Viewer.camera.flyTo({ |
| | | destination: Cesium.Cartesian3.fromDegrees(wkt.coordinates[1], wkt.coordinates[0], 2000), |
| | | }); |
| | | // var wkt = this.$wkt.parse(data.result.geom); |
| | | // Viewer.camera.flyTo({ |
| | | // destination: Cesium.Cartesian3.fromDegrees(wkt.coordinates[1], wkt.coordinates[0], 2000), |
| | | // }); |
| | | } |
| | | this.setChangeWMS(); |
| | | } |
| | |
| | | //修改模型矩阵 |
| | | tileset.modelMatrix = Cesium.Matrix4.fromTranslation(translation); |
| | | // Viewer.flyTo(tileset); |
| | | }, |
| | | 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 layersStart () { |
| | | const data = await perms_selectLayers(); |
| | | if (data.code != 200) { |
| | | return this.$message.error("图层列表查询失败"); |
| | | } |
| | | var std = data.result; |
| | | var that = this; |
| | | var checkKey = []; |
| | | let checkedLayers = []; |
| | | var val = std.filter((str) => { |
| | | if (str.type == 1) { |
| | | return str; |
| | | } |
| | | if (str.url != null && str.type == 2) { |
| | | if (str.isShow == 1) { |
| | | checkKey.push(str.id); |
| | | // that.setAddLayers(str); |
| | | if (str.serveType == "WMS" && str.url) { |
| | | checkedLayers.push(str); |
| | | } |
| | | } |
| | | return str; |
| | | } |
| | | }); |
| | | //存储选中图层 |
| | | sessionStorage.setItem("checkedLayers", JSON.stringify(checkedLayers)); |
| | | var res = this.setTreeData(val); |
| | | this.treeData = res; |
| | | this.$refs.tree.setCheckedKeys(checkKey); |
| | | }, |
| | | async treelayersStart () { |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | | 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 && res.children.length != 0) { |
| | | return res; |
| | | } |
| | | }); |
| | | this.treeData = layer_groups; |
| | | |
| | | for (var i in data.result) { |
| | | if (data.result[i].type == 2 && data.result[i].url != null) { |
| | | for (var j = 0; j < window.Viewer.imageryLayers._layers.length; j++) { |
| | | var val_id = window.Viewer.imageryLayers._layers[j]; |
| | | if (val_id.show == true) { |
| | | if (val_id.imageryProvider.name == data.result[i].cnName) { |
| | | std.push(data.result[i].id); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | this.$refs.tree.setCheckedKeys(std); |
| | | }, |
| | | // 查询 |
| | | filterNode (value, data) { |
| | | |
| | | if (!value) return true; |
| | | return data.cnName.indexOf(value) !== -1; |
| | | }, |
| | | async setproChange (res) { |
| | | if (res) { |
| | |
| | | this.$bus.$emit("showMenuLayer", value); |
| | | } |
| | | }, |
| | | async getMenuProject () { |
| | | const data = await project_selectDirAll(); |
| | | if (data.code != 200) { |
| | | return |
| | | } |
| | | this.optionts = data.result; |
| | | }, |
| | | }, |
| | | watch: { |
| | | filterText (val) { |
| | | this.$refs.tree.filter(val); |
| | | }, |
| | | }, |
| | | mounted () { |
| | | this.getMenuProject() |
| | | this.$bus.$on("treeDataCopy", (res) => { |
| | | this.$store.state.treeData = this.treeData; |
| | | this.$store.state.checkedKeys = this.$refs.tree.getCheckedKeys(); |
| | | }); |
| | | |
| | | if (this.$store.state.showAllLayers == true) { |
| | | this.layersStart(); |
| | | this.$store.state.showAllLayers = false; |
| | | } else { |
| | | this.treeData = this.$store.state.treeData; |
| | | this.$refs.tree.setCheckedKeys(this.$store.state.checkedKeys); |
| | | } |
| | | }, |
| | | }; |
| | | </script> |