| | |
| | | import { loadAreaPolygon } from "@/utils/area.js"; |
| | | import { loadAreaPolygonAll } from "@/utils/area_all.js"; |
| | | import { isVisibleDistance } from "@/utils/customEntity"; |
| | | import { getDistrictCount, getDistrictCountByCity } from "@/api/index"; |
| | | import { useRoute } from "vue-router"; |
| | | import { EventBus } from "@/eventBus"; // 引入事件总线 |
| | | import { useSimStore } from "@/store/simulation"; |
| | | const route = useRoute(); |
| | | const simStore = useSimStore(); |
| | | |
| | | import { |
| | |
| | | getDeviceInfo, |
| | | getAeraCode, |
| | | getAeraTownCode, |
| | | getDeviceCount, |
| | | } from "@/api/hpApi"; |
| | | /////////////////////////地图影像选择///////////////////////// |
| | | const views = [ |
| | |
| | | }; |
| | | /////////////////////////地图影像选择///////////////////////// |
| | | |
| | | const route = useRoute(); |
| | | let handler = null; |
| | | /////////////////////////初始化地图///////////////////////// |
| | | function initMap() { |
| | |
| | | }, |
| | | }; |
| | | |
| | | const showDeviceCount = ref(false); |
| | | |
| | | // 监听路由变化 |
| | | watch( |
| | | () => route.name, |
| | | (newName) => { |
| | | console.log("路由名称变化:", newName); |
| | | // 使用三元运算符来决定 showDeviceCount 的值 |
| | | showDeviceCount.value = newName === "zhjc" ? true : false; |
| | | initDistrictCount("primary"); |
| | | }, |
| | | { immediate: true } |
| | | ); |
| | | |
| | | // 初始化区域统计 |
| | | async function initDistrictCount(level = "secondary") { |
| | | try { |
| | | const deviceTotal = ref([]); |
| | | if (level === "primary") { |
| | | // 一级区域:直接调用 getAeraCode() |
| | | // 如果是 "/zhjc" 路由,先获取设备统计接口数据 |
| | | if (showDeviceCount.value) { |
| | | deviceTotal.value = await getDeviceCount(); |
| | | } |
| | | const res = await getAeraCode(); |
| | | res.data.forEach((item) => { |
| | | if (showDeviceCount.value) { |
| | | const matchedDistrict = deviceTotal.value.data.find( |
| | | (d) => d.districtName === item.districtName |
| | | ); |
| | | if (matchedDistrict) { |
| | | item.count = matchedDistrict.count; // 更新 count |
| | | } |
| | | } |
| | | processDistrictItem(item, LEVEL_CONFIG[level], level); |
| | | }); |
| | | } else if (level === "secondary") { |
| | |
| | | res = await getDangerPoint(item.districtCode); |
| | | } else if (route.path === "/zhjc") { |
| | | // 请求监测设备数据 |
| | | res = await getDeviceInfo(item.districtCode); |
| | | res = await getDeviceInfo(null,item.districtCode); |
| | | } else { |
| | | loadingInstance.close(); |
| | | return; |