| | |
| | | <script setup> |
| | | import { ref, computed, onMounted, watch, onBeforeUnmount } from "vue"; |
| | | import { useRoute, onBeforeRouteUpdate } from "vue-router"; |
| | | import { createPoint, removeEntities } from "@/utils/map"; |
| | | import { createPoint, removeEntities, clearAllPoints } from "@/utils/map"; |
| | | import { deviceDictList, getDictName } from "@/constant/dict.js"; |
| | | import { getDeviceInfoShg, getDeviceInfo } from "@/api/hpApi"; |
| | | import { initeWaterPrimitiveView } from "@/utils/water"; //相机flyTo函数,后续options列表中有对应经纬度后弃用 |
| | |
| | | } |
| | | }); |
| | | |
| | | onBeforeRouteUpdate((to, from, next) => { |
| | | if (to.path !== "/zhjc") { |
| | | handleCleanup(); |
| | | } |
| | | next(); |
| | | }); |
| | | // onBeforeRouteUpdate((to, from, next) => { |
| | | // if (to.path !== "/zhjc") { |
| | | // handleCleanup(); |
| | | // } |
| | | // next(); |
| | | // }); |
| | | const route = useRoute(); |
| | | |
| | | onBeforeUnmount(() => { |
| | | if (route.path !== "/zhjc") { |
| | | handleCleanup(); |
| | | clearAllPoints(); |
| | | } |
| | | }); |
| | | watch( |
| | |
| | | if (newValue) { |
| | | initializeDevicePoints(); |
| | | } else { |
| | | handleCleanup(); |
| | | clearAllPoints(); |
| | | } |
| | | } |
| | | ); |
| | | |
| | | const deviceListAll = ref([]); |
| | | const deviceEntities = ref([]); |
| | | const handleCleanup = () => { |
| | | deviceListAll.value.forEach((item) => { |
| | | removeEntities(item.deviceId); |
| | | }); |
| | | }; |
| | | |
| | | // const initializeDevicePoints = (val) => { |
| | | const initializeDevicePoints = () => { |
| | | const list = []; |
| | |
| | | // 根据区域名称加载设备列表 |
| | | const loadDeviceList = async (areaName) => { |
| | | try { |
| | | clearAllPoints(); |
| | | isLoading.value = true; |
| | | handleCleanup(); |
| | | // const res = await getDeviceInfoShg(); |
| | | // const allDevices = res.data.pageData; |
| | | const devicesInArea = allDevices.value.filter((item) => |
| | | deviceListAll.value = allDevices.value.filter((item) => |
| | | item.deviceName?.includes(areaName) |
| | | ); |
| | | deviceListAll.value = devicesInArea; |
| | | |
| | | initializeDevicePoints(); |
| | | // getDeviceInfo().then((res) => { |
| | | // const list = res.data.pageData; |
| | | // deviceListAll.value = []; |
| | |
| | | |
| | | .tree-container { |
| | | position: relative; |
| | | height: calc(100% - 80px); |
| | | margin-top: 10px; |
| | | height: calc(100% - 22px); |
| | | // margin-top: 10px; |
| | | overflow-y: auto; |
| | | } |
| | | |