| | |
| | | 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 { perms_selectLayers, comprehensive_selectPubById, project_selectDirAll } from "../../api/api.js"; |
| | | |
| | | export default { |
| | | name: "tree", |
| | |
| | | }, |
| | | // 设置树数据 |
| | | setTreeData (source) { |
| | | let cloneData = JSON.parse(JSON.stringify(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; // 返回一级菜单 |
| | | });*/ |
| | | |
| | | let arr = []; |
| | | let data = JSON.parse(JSON.stringify(source)); |
| | | this.setTreeChildData(data, arr, 0); |
| | | |
| | | return arr; |
| | | }, |
| | | // 设置树子节点数据 |
| | | setTreeChildData (data, arr, pid) { |
| | | let i = 0; |
| | | while (i < data.length) { |
| | | let d = data[i]; |
| | | if (d.pid == pid) { |
| | | arr.push(d); |
| | | data.splice(i, 1); |
| | | continue; |
| | | } |
| | | |
| | | i++; |
| | | } |
| | | |
| | | arr.sort(function (a, b) { |
| | | return a.orderNum - b.orderNum; |
| | | }); |
| | | |
| | | for (let i in arr) { |
| | | let children = []; |
| | | this.setTreeChildData(data, children, arr[i].id); |
| | | if (children.length) arr[i].children = children; |
| | | } |
| | | }, |
| | | // 节点获得焦点事件 |
| | | nodeBlur (node, data) { |
| | |
| | | } |
| | | } |
| | | |
| | | this.setChangeDEM(obj.DEM, checked); |
| | | if (obj.TMS.length) this.setChangeDEM(obj.DEM, checked); |
| | | if (obj.TMS.length) this.setChangeTMS(obj.TMS, checked); |
| | | if (obj.Mpt.length) this.setChangeMpt(obj.Mpt, checked); |
| | | if (obj.Tileset.length) this.setChangeTileset(obj.Tileset, checked); |
| | |
| | | // 切换项目 |
| | | prjChanged (code) { |
| | | this.$store.state.pigCode = code; |
| | | if (code) { |
| | | this.isBusy = true; |
| | | let checkedLayers = this.getCheckedLayersByCode(code); |
| | | //if (code) { |
| | | this.isBusy = true; |
| | | let checkedLayers = this.getCheckedLayersByCode(code); |
| | | |
| | | let checkedKeys = []; |
| | | for (let i in checkedLayers) { |
| | | checkedKeys.push(checkedLayers[i].id); |
| | | } |
| | | |
| | | this.$refs.tree.setCheckedKeys(checkedKeys); |
| | | sessionStorage.setItem("checkedLayers", JSON.stringify(checkedLayers)); |
| | | this.isBusy = false; |
| | | let checkedKeys = []; |
| | | for (let i in checkedLayers) { |
| | | checkedKeys.push(checkedLayers[i].id); |
| | | } |
| | | |
| | | this.$refs.tree.setCheckedKeys(checkedKeys); |
| | | sessionStorage.setItem("checkedLayers", JSON.stringify(checkedLayers)); |
| | | this.isBusy = false; |
| | | //} |
| | | |
| | | for (let i = 0, c = this.treeData.length; i < c; i++) { |
| | | this.handleCheckChange(this.treeData[i], true); |
| | | } |