| | |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { ref, onMounted, watch, nextTick, onUnmounted } from "vue"; |
| | | import { |
| | | ref, |
| | | onMounted, |
| | | watch, |
| | | nextTick, |
| | | onUnmounted, |
| | | computed, |
| | | watchEffect, |
| | | } from "vue"; |
| | | import { createPoint, removeEntities, addTileset } from "@/utils/map"; |
| | | import { deviceDictList, getDictName } from "@/constant/dict.js"; |
| | | import { useRoute } from "vue-router"; |
| | | import { loadAreaPolygon, clearAreaPolygon } from "@/utils/area"; |
| | | import { checkedKeys } from "@/store/index"; |
| | | import { |
| | | getDuanMainData, |
| | | getDevicetListData, |
| | | getDistrictListData, |
| | | } from "@/api/index.js"; |
| | | import { init } from "echarts"; |
| | | import { getDuanMainData, getDistrictListData } from "@/api/index.js"; |
| | | import { getDeviceInfo, getDangerPoint } from "@/api/hpApi"; |
| | | |
| | | import { useSimStore } from "@/store/simulation"; |
| | | |
| | | const simStore = useSimStore(); |
| | | |
| | | const route = useRoute(); |
| | | |
| | |
| | | label: "三维服务", |
| | | children: [ |
| | | { label: "模型数据" }, |
| | | { label: "地形数据" }, // 确保这里的 label 是 "地形数据" |
| | | { label: "地形数据" }, |
| | | { label: "影像数据" }, |
| | | ], |
| | | }, |
| | |
| | | { label: "孙胡沟隐患点" }, |
| | | { label: "综合监测设备信息" }, |
| | | { label: "孙胡沟断面" }, |
| | | { label: "避险点" }, |
| | | { label: "避险场所" }, |
| | | ], |
| | | }, |
| | | ]); |
| | |
| | | // // }); |
| | | // // treeMap.set("影像数据", ImageryLayer); |
| | | // } |
| | | |
| | | |
| | | // 地形数据 |
| | | let TerrainLayer = null; |
| | |
| | | } |
| | | return; |
| | | } |
| | | if (label === "综合监测设备信息") { |
| | | simStore.DeviceShowSwitch = checked; |
| | | if (checked) { |
| | | if (!treeMap.get("综合监测设备信息")) { |
| | | } else { |
| | | toggleLayerVisible("综合监测设备信息", true); |
| | | } |
| | | } else { |
| | | toggleLayerVisible("综合监测设备信息", false); |
| | | } |
| | | return; |
| | | } |
| | | |
| | | // 其他图层的处理逻辑 |
| | | const list = treeMap.get(label); |
| | |
| | | case "泥石流隐患点面数据": |
| | | case "综合监测设备信息": |
| | | case "孙胡沟断面": |
| | | case "避险点": |
| | | case "避险场所": |
| | | console.log(label, checked, indeterminate); |
| | | break; |
| | | } |
| | |
| | | */ |
| | | function toggleLayerVisible(name, checked) { |
| | | const entityList = treeMap.get(name); |
| | | |
| | | console.log(`Toggling visibility for ${name}:`, checked); |
| | | |
| | | if (Array.isArray(entityList)) { |
| | | entityList.forEach((entity) => { |
| | | console.log(`Setting entity show to:`, checked); |
| | | // console.log(`Setting entity show to:`, checked); |
| | | entity.show = checked; |
| | | }); |
| | | } else if (entityList && typeof entityList.show !== "undefined") { |
| | | console.log(`Setting layer show to:`, checked); |
| | | entityList.show = checked; |
| | | } else { |
| | | console.error(`无法设置图层 ${name} 的可见性`); |
| | | } |
| | | } |
| | | |
| | | // 设备列表 |
| | | // 监测设备列表 |
| | | const devicetList = ref([]); |
| | | |
| | | /** |
| | | * 获取设备列表并初始化设备点 |
| | | */ |
| | | // 监测设备列表 |
| | | const getDevicetList = async () => { |
| | | await getDevicetListData().then((res) => { |
| | | console.log(res.data, "devicetList.value2"); |
| | | devicetList.value = res.data; |
| | | }); |
| | | const res = await getDeviceInfo(); // 调整getDeviceInfo以接受动态参数,如果需要的话 |
| | | devicetList.value = res.data.pageData.filter((item) => |
| | | item.deviceName?.includes("孙胡沟") |
| | | ); |
| | | }; |
| | | |
| | | // 默认加载部分已替换至Device.vue中,逻辑修改为根据当前选择地形切换设备点显示 |
| | | async function initDevicePoint() { |
| | | let list = []; |
| | | await getDevicetList(); |
| | | devicetList.value.forEach((item) => { |
| | | item.type = getDictName(deviceDictList, item.dictDeviceType); |
| | | item.name = item.type; |
| | | item.name = item.deviceName.split("孙胡沟")[1]; |
| | | item.id = item.deviceId; |
| | | item.className = "device"; |
| | | item.showLabel = true; |
| | |
| | | treeMap.set("综合监测设备信息", list); |
| | | } |
| | | |
| | | // 区域列表 |
| | | const districtList = ref([]); |
| | | // 隐患点列表 |
| | | watchEffect(() => { |
| | | const dangerPoints = simStore.DangerPoint.filter((item) => |
| | | item.position?.includes("孙胡沟") |
| | | ); |
| | | |
| | | /** |
| | | * 获取区域列表并初始化区域点 |
| | | */ |
| | | const getDistrictList = async () => { |
| | | await getDistrictListData().then((res) => { |
| | | districtList.value = res.data; |
| | | }); |
| | | }; |
| | | if (dangerPoints && dangerPoints.length > 0) { |
| | | const list = []; |
| | | |
| | | async function initDistrictPoint() { |
| | | let list = []; |
| | | await getDistrictList(); |
| | | districtList.value.forEach((item) => { |
| | | item.showBillboard = true; |
| | | item.className = "district"; |
| | | item.type = "泥石流"; |
| | | const entity = createPoint(item); |
| | | entity.show = false; |
| | | list.push(entity); |
| | | }); |
| | | treeMap.set("孙胡沟隐患点", list); |
| | | } |
| | | dangerPoints.forEach((item) => { |
| | | // console.log(item, "item"); |
| | | item.id = item.hdId; |
| | | item.name = item.hdName; |
| | | item.latitude = item.lat; |
| | | item.longitude = item.lon; |
| | | item.showBillboard = true; |
| | | item.type = item.disasterType; |
| | | item.className = "district"; |
| | | const entity = createPoint(item); |
| | | entity.show = false; |
| | | list.push(entity); |
| | | }); |
| | | |
| | | treeMap.set("孙胡沟隐患点", list); |
| | | } |
| | | }); |
| | | |
| | | let divPointList = []; |
| | | |
| | | /** |
| | | * 初始化断面点 |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * 添加避险点 |
| | | * 添加避险场所 |
| | | */ |
| | | function addTetrahedron(visible) { |
| | | const emergencyAreaList = []; |
| | | // 加载避险点底层面片 |
| | | // 加载避险场所底层面片 |
| | | loadAreaPolygon("/json/emergency_area.geojson", true).then((entities) => { |
| | | emergencyAreaList.push(...entities); |
| | | |
| | | // 默认隐藏避险点 |
| | | // 默认隐藏避险场所 |
| | | entities.forEach((entity) => { |
| | | entity.show = false; |
| | | }); |
| | | |
| | | // 将避险点实体存储到 treeMap |
| | | treeMap.set("避险点", entities); |
| | | // 将避险场所实体存储到 treeMap |
| | | treeMap.set("避险场所", entities); |
| | | }); |
| | | } |
| | | |
| | |
| | | * 初始化所有数据 |
| | | */ |
| | | function getData() { |
| | | initDevicePoint(); |
| | | initDistrictPoint(); |
| | | // initDevicePoint(); |
| | | // initDistrictPoint(); |
| | | initDuanmianPoint(); |
| | | addTetrahedron(); |
| | | } |
| | |
| | | </script> |
| | | |
| | | <style lang="less" scoped> |
| | | @import url("../../assets/css/infobox.css"); |
| | | .layer-tree { |
| | | background: url("@/assets/img/tools/plotting_new.png"); |
| | | width: 200px; |
| | | height: 200px; |
| | | // height: 200px; |
| | | z-index: 99; |
| | | overflow: hidden; |
| | | } |
| | | /deep/ .el-tree { |
| | | overflow: hidden !important; |
| | | } |
| | | </style> |