| | |
| | | // import ResultAssess from "@/components/monifangzhen/ResultAssess.vue"; |
| | | // import DangerAssess from "@/components/monifangzhen/DangerAssess.vue"; |
| | | import { showDeviceDetail } from "@/store"; |
| | | import { setupTokenRefresh, getDangerPoint } from "@/api/hpApi.js"; |
| | | import { setupTokenRefresh, getDangerPoint, getAllCode } from "@/api/hpApi.js"; |
| | | import { convertToWKT } from "@/utils/wktUtils"; |
| | | import { getDeviceInfoSHG, getWeather } from "@/api/hpApi"; |
| | | |
| | | const route = useRoute(); |
| | | const simStore = useSimStore(); |
| | | const backHome = ref(false); |
| | | |
| | | // 接收来自 ComponentA 的事件,并更新 isFlying |
| | | function handleBackToHome() { |
| | |
| | | // 计算属性 |
| | | const showDetail = computed(() => showDeviceDetail.value); |
| | | |
| | | function groupTopWithLeafNodes(dataArray) { |
| | | const result = {}; |
| | | |
| | | function traverse(nodes, topLevelName = null) { |
| | | if (!Array.isArray(nodes)) return; |
| | | |
| | | for (const node of nodes) { |
| | | const isLeaf = !node.children || node.children.length === 0; |
| | | |
| | | // 如果是顶层节点,记录它的名字作为 key |
| | | if (!topLevelName && !isLeaf) { |
| | | topLevelName = node.nameChn; |
| | | if (!result[topLevelName]) { |
| | | result[topLevelName] = []; |
| | | } |
| | | } |
| | | |
| | | // 如果是叶子节点,加入对应数组 |
| | | if (isLeaf && topLevelName) { |
| | | result[topLevelName].push({ |
| | | name: node.nameChn, |
| | | code: node.code, |
| | | }); |
| | | } |
| | | |
| | | // 继续递归子节点(保持当前顶层名称) |
| | | if (node.children && node.children.length > 0) { |
| | | traverse(node.children, topLevelName); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 遍历整个大数组中的每一项(即每一个区域) |
| | | for (const item of dataArray) { |
| | | if (item && item.children && Array.isArray(item.children)) { |
| | | traverse([item]); // 把当前项包装成数组,方便统一处理 |
| | | } |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | onMounted(async () => { |
| | | getAllCode().then((res) => { |
| | | // 北京市所有村以及街道code |
| | | simStore.townCodeAll = groupTopWithLeafNodes(res.data[0].children); |
| | | console.log(simStore.townCodeAll, "中科软接口获取乡镇code"); |
| | | }); |
| | | setupTokenRefresh(); // 获取宏图token |
| | | // getSimData(); //测试tr后端 |
| | | // 获取隐患点列表(因为中科软后端接口获取加载时间较长) |
| | | getDangerPoint().then((res) => { |
| | | getDangerPoint("110116110000").then((res) => { |
| | | simStore.DangerPoint = res.data.pageData; |
| | | }); |
| | | |
| | | getDeviceInfoSHG(null).then((res) => { |
| | | simStore.devices = res.data.pageData; |
| | | }); |
| | | try { |
| | | const wktResult = convertToWKT(multiPolygonCoordinates); |
| | | // console.log(wktResult,'a'); |