|
|
@@ -76,9 +76,20 @@ export default {
|
|
|
{ id: '3-2', label: '兴平市团结采砂区', meta: { type: 'polygon', url: '/geojson/tuanjie.geojson' } },
|
|
|
{ id: '3-3', label: '兴平市汤坊龙兴1区采砂区', meta: { type: 'polygon', url: '/geojson/longxing.geojson' } }
|
|
|
]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: '4',
|
|
|
+ label: '防汛应急预案',
|
|
|
+ type: 'plan',
|
|
|
+ children: [
|
|
|
+ { id: '4-1', type: 'plan', label: '2025年度渭河兴平段水灾害防御工作方案' },
|
|
|
+ { id: '4-2', type: 'plan', label: '2025年度渭河水灾害防御工作方案' },
|
|
|
+ { id: '4-3', type: 'plan', label: '陕西省防汛应急预案' }
|
|
|
+ ]
|
|
|
}
|
|
|
],
|
|
|
- mainMenu: ''
|
|
|
+ mainMenu: '',
|
|
|
+ checkedNodes: []
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
@@ -105,48 +116,61 @@ export default {
|
|
|
this.isExpanded = !this.isExpanded
|
|
|
},
|
|
|
|
|
|
- async onCheckChange(node, checked) {
|
|
|
+ async onCheckChange(node, checked,) {
|
|
|
+ if (checked && node.type === 'plan' &&!node.children) {
|
|
|
+ this.checkedNodes.push(node);
|
|
|
+ } else if (!checked) {
|
|
|
+ this.checkedNodes = this.checkedNodes.filter(n => n.id !== node.id);
|
|
|
+ }
|
|
|
const id = node.id
|
|
|
- if (!node.meta?.url) {
|
|
|
- return
|
|
|
- }
|
|
|
if (checked) {
|
|
|
- // 已缓存直接显示
|
|
|
- if (layerCache[id]) {
|
|
|
- layerCache[id].show = true
|
|
|
- return
|
|
|
- }
|
|
|
- // 开始加载
|
|
|
- this.$set(node, 'loading', true)
|
|
|
- this.$set(node, 'error', '')
|
|
|
- try {
|
|
|
- const layer = new mars3d.layer.GeoJsonLayer({
|
|
|
- id: node.id,
|
|
|
- name: node.label,
|
|
|
- url: node.meta.url,
|
|
|
- crs: 'EPSG:4326',
|
|
|
- clampToGround: true,
|
|
|
- symbol: this.getStyleByName(node.label)
|
|
|
- })
|
|
|
- console.log(window.map, 111111111)
|
|
|
- window.map.addLayer(layer)
|
|
|
- this.bindEvent(layer)
|
|
|
- layerCache[id] = layer
|
|
|
- // 父子关联:勾选子节点时,父节点作为 groupId
|
|
|
- const parent = this.$refs.treeRef.getNode(id).parent
|
|
|
- if (parent && parent.data.id) {
|
|
|
- layer.options.parentId = parent.data.id
|
|
|
+ if (node.type && node.type == 'plan') {
|
|
|
+ this.$globalEventBus.$emit('showPlanDialog',{list:this.checkedNodes})
|
|
|
+ } else {
|
|
|
+ if (!node.meta?.url) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 已缓存直接显示
|
|
|
+ if (layerCache[id]) {
|
|
|
+ layerCache[id].show = true
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 开始加载
|
|
|
+ this.$set(node, 'loading', true)
|
|
|
+ this.$set(node, 'error', '')
|
|
|
+ try {
|
|
|
+ const layer = new mars3d.layer.GeoJsonLayer({
|
|
|
+ id: node.id,
|
|
|
+ name: node.label,
|
|
|
+ url: node.meta.url,
|
|
|
+ crs: 'EPSG:4326',
|
|
|
+ clampToGround: true,
|
|
|
+ symbol: this.getStyleByName(node.label)
|
|
|
+ })
|
|
|
+ console.log(window.map, 111111111)
|
|
|
+ window.map.addLayer(layer)
|
|
|
+ this.bindEvent(layer)
|
|
|
+ layerCache[id] = layer
|
|
|
+ // 父子关联:勾选子节点时,父节点作为 groupId
|
|
|
+ const parent = this.$refs.treeRef.getNode(id).parent
|
|
|
+ if (parent && parent.data.id) {
|
|
|
+ layer.options.parentId = parent.data.id
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ this.$set(node, 'error', e.message || '加载失败')
|
|
|
+ } finally {
|
|
|
+ this.$set(node, 'loading', false)
|
|
|
}
|
|
|
- } catch (e) {
|
|
|
- this.$set(node, 'error', e.message || '加载失败')
|
|
|
- } finally {
|
|
|
- this.$set(node, 'loading', false)
|
|
|
}
|
|
|
} else {
|
|
|
// 取消勾选 -> 销毁
|
|
|
- if (layerCache[id]) {
|
|
|
- window.map.removeLayer(layerCache[id])
|
|
|
- delete layerCache[id]
|
|
|
+ if (node.type && node.type == 'plan') {
|
|
|
+ this.$globalEventBus.$emit('showPlanDialog',{list:this.checkedNodes})
|
|
|
+ } else {
|
|
|
+ if (layerCache[id]) {
|
|
|
+ window.map.removeLayer(layerCache[id])
|
|
|
+ delete layerCache[id]
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
@@ -249,8 +273,10 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
.custom-tree-node {
|
|
|
- white-space: wrap;
|
|
|
font-size: px-to-rem(16);
|
|
|
+ overflow: hidden;
|
|
|
+ white-space: nowrap;
|
|
|
+ text-overflow: ellipsis;
|
|
|
}
|
|
|
}
|
|
|
}
|