| | |
| | | * @Author: shuishen 1109946754@qq.com |
| | | * @Date: 2024-10-31 10:47:29 |
| | | * @LastEditors: shuishen 1109946754@qq.com |
| | | * @LastEditTime: 2024-11-04 14:27:54 |
| | | * @LastEditTime: 2024-11-04 19:12:02 |
| | | * @FilePath: \bigScreen\src\views\layout\components\scomponents\layersControl.vue |
| | | * @Description: |
| | | * |
| | |
| | | |
| | | <template #content> |
| | | <div class="tree-content"> |
| | | <el-tree ref="tree" :data="data" draggable="" show-checkbox node-key="id" :default-expanded-keys="[2, 3]" |
| | | :default-checked-keys="[5]" :props="defaultProps" :indent="treeProps['indent']" @check="handleCheckChange"> |
| | | <el-tree ref="treeRef" :data="data" draggable="" show-checkbox node-key="id" default-expand-all |
| | | :default-checked-keys="['1']" :props="defaultProps" :indent="treeProps['indent']" @check="handleCheckChange"> |
| | | <template v-slot:default="{ node }"> |
| | | <element-tree-line :node="node" :showLabelLine="treeProps['showLabelLine']" :indent="treeProps['indent']"> |
| | | <!-- 自定义label的slot --> |
| | |
| | | <script setup> |
| | | import { getPage } from '@/api/indParkInfo' |
| | | import { getList } from "@/api/space/space" |
| | | import { getList as getRiskList } from "@/api/riskSource/riskSource" |
| | | |
| | | const { VITE_APP_BASE } = import.meta.env |
| | | import { getViewer } from 'utils/getViewer' |
| | | const globalViewer = getViewer() |
| | | |
| | | const treeRef = ref(null) |
| | | |
| | | const treeProps = { |
| | | indent: 16, |
| | |
| | | |
| | | const data = [ |
| | | { |
| | | id: 1, |
| | | id: '1', |
| | | label: '化工园区', |
| | | type: 'layer', |
| | | subType: '3Dtile', |
| | |
| | | }, |
| | | |
| | | { |
| | | id: 2, |
| | | id: '2', |
| | | label: '企业分布', |
| | | type: 'layer', |
| | | subType: 'labelPoint', |
| | |
| | | }, |
| | | |
| | | { |
| | | id: 3, |
| | | id: '3', |
| | | label: '应急空间', |
| | | children: [ |
| | | { |
| | | id: 3 - 1, |
| | | id: '3-1', |
| | | label: '应急池', |
| | | type: 'layer', |
| | | subType: 'labelPoint', |
| | |
| | | layerName: 'yjc' |
| | | }, |
| | | { |
| | | id: 3 - 2, |
| | | id: '3-2', |
| | | label: '阀门', |
| | | type: 'layer', |
| | | subType: 'labelPoint', |
| | |
| | | }, |
| | | |
| | | { |
| | | id: 3 - 3, |
| | | id: '3-3', |
| | | label: '公共管网', |
| | | type: 'layer', |
| | | subType: 'labelPoint', |
| | |
| | | }, |
| | | |
| | | { |
| | | id: 3 - 4, |
| | | id: '3-4', |
| | | label: '污水提升泵站', |
| | | type: 'layer', |
| | | subType: 'labelPoint', |
| | |
| | | }, |
| | | |
| | | { |
| | | id: 3 - 5, |
| | | id: '3-5', |
| | | label: '水库', |
| | | type: 'layer', |
| | | subType: 'labelPoint', |
| | |
| | | }, |
| | | |
| | | { |
| | | id: 3 - 6, |
| | | id: '3-6', |
| | | label: '应急泵', |
| | | type: 'layer', |
| | | subType: 'labelPoint', |
| | |
| | | }, |
| | | |
| | | { |
| | | id: 3 - 7, |
| | | id: '3-7', |
| | | label: '消防沙', |
| | | type: 'layer', |
| | | subType: 'labelPoint', |
| | |
| | | layerName: 'xfs' |
| | | } |
| | | ] |
| | | } |
| | | }, |
| | | |
| | | { |
| | | id: '4', |
| | | label: '风险源', |
| | | type: 'layer', |
| | | subType: 'labelPoint', |
| | | method: getRiskList, |
| | | params: { |
| | | size: 1000 |
| | | }, |
| | | showParams: 'category', |
| | | layerName: 'fxy' |
| | | }, |
| | | ] |
| | | |
| | | const defaultProps = { |
| | |
| | | let tileLayers = new DC.TilesetLayer('tileLayers') |
| | | globalViewer.addLayer(tileLayers) |
| | | |
| | | |
| | | const checkNodeById = (id) => { |
| | | const node = treeRef.value.getNode(id) |
| | | if (node) { |
| | | treeRef.value.setChecked(node, true, true) // true for checked, true for emit event |
| | | } |
| | | } |
| | | |
| | | const handleCheckChange = (data, options) => { |
| | | collectedNodes.value = [] |
| | |
| | | tileLayers.addOverlay(addTileLayers[item.layerName]) |
| | | globalViewer.flyTo(addTileLayers[item.layerName]) |
| | | } else if (item.subType == 'labelPoint') { |
| | | addTileLayers[item.layerName] = new DC.HtmlLayer('labelLayer') |
| | | globalViewer.addLayer(addTileLayers[item.layerName]) |
| | | if (!addTileLayers[item.layerName]) { |
| | | addTileLayers[item.layerName] = new DC.HtmlLayer(addTileLayers[item.layerName]) |
| | | globalViewer.addLayer(addTileLayers[item.layerName]) |
| | | } |
| | | |
| | | item.method(item.params).then(res => { |
| | | let data = res.data.data.records |
| | |
| | | new DC.Position(i.lng, i.lat, 0), |
| | | `<div class="public-map-popup"> |
| | | <div class="marsBlueGradientPnl"> |
| | | <div>${i.name}</div> |
| | | <div>${i[item.showParams] || i.name}</div> |
| | | </div> |
| | | </div>` |
| | | ) |
| | |
| | | }) |
| | | } |
| | | } else { |
| | | if (item.subType == '3Dtile') { |
| | | tileLayers.removeOverlay(addTileLayers[item.layerName]) |
| | | } else if (item.subType == 'labelPoint') { |
| | | globalViewer.removeLayer(addTileLayers[item.layerName]) |
| | | } |
| | | if (addTileLayers[item.layerName]) { |
| | | if (item.subType == '3Dtile') { |
| | | tileLayers.removeOverlay(addTileLayers[item.layerName]) |
| | | } else if (item.subType == 'labelPoint') { |
| | | globalViewer.removeLayer(addTileLayers[item.layerName]) |
| | | } |
| | | |
| | | delete addTileLayers[item.layerName] |
| | | delete addTileLayers[item.layerName] |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | |
| | | // onMounted(() => { |
| | | // setTimeout(() => { |
| | | // checkNodeById('1') |
| | | // }, 1000) |
| | | // }) |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |