From f3ecdf8c0cbf60f46f7d32d2bd8408c55f71ea12 Mon Sep 17 00:00:00 2001 From: hym Date: Sat, 4 Apr 2026 23:09:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=95=E4=BD=8D=E7=BB=9F=E8=AE=A1=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E5=A2=9E=E5=8A=A0=E5=9C=B0=E5=9B=BE=E5=BC=B9=E7=AA=97?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/vector-layer-utils.js | 44 +++++++++++++++++++++- src/views/statistics/UuvUnitStatistics.vue | 5 ++- 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/src/utils/vector-layer-utils.js b/src/utils/vector-layer-utils.js index b149f65..9c801b5 100644 --- a/src/utils/vector-layer-utils.js +++ b/src/utils/vector-layer-utils.js @@ -145,10 +145,15 @@ export async function loadVectorFeature(layerId, feature, color, visibility, map export function setHighlight(layerId, sourceId, mapId = "homeMap") { let hoveredLineId = null; let clickedLineId = null; - Vue.config.maps[mapId].on('click', layerId, (e) => { + Vue.config.maps[mapId].on('click', layerId, async (e) => { if (!e.features || e.features.length <= 0) return; + if (mapId == "workUnitMap_uuv") { + showUnitReport(mapId, e.features[0].properties.unit_name, e.features[0].geometry.coordinates); + return; + } + // // 查询点击点周围的所有要素(使用边界框) // const bbox = [ // [e.point.x - 10, e.point.y - 10], // 左上 @@ -203,6 +208,9 @@ export function setHighlight(layerId, sourceId, mapId = "homeMap") { // When the user moves their mouse over the state-fill layer, we'll update the feature state for the feature under the mouse. Vue.config.maps[mapId].on('mousemove', layerId, (e) => { + if (mapId == "workUnitMap_uuv") + return; + if (e.features.length <= 0) return; sourceLayer = e.features[0].sourceLayer; @@ -231,6 +239,40 @@ export function setHighlight(layerId, sourceId, mapId = "homeMap") { }); } +export async function showUnitReport(mapId, unit, coordinates) { + const result = await (await fetch(`${Vue.config.baseUrl}/ds/report/unit/total.htm?unit=${unit}`)).json(); + const unitReports = result.array || []; + if (!unitReports.length) { + alert("未查询到相关单位的统计信息"); + return; + } + const description = ` + + + + + + + + + + + + + + + + + + + + + + `; + + showPopupDetails(mapId, coordinates, description, "350px"); +} + export function changeCursor(layerId, mapId = "homeMap", cursor = "pointer") { Vue.config.maps[mapId].on("mouseenter", layerId, () => { Vue.config.maps[mapId].getCanvas().style.cursor = cursor; diff --git a/src/views/statistics/UuvUnitStatistics.vue b/src/views/statistics/UuvUnitStatistics.vue index fd5858f..9e7d7df 100644 --- a/src/views/statistics/UuvUnitStatistics.vue +++ b/src/views/statistics/UuvUnitStatistics.vue @@ -60,7 +60,7 @@ import BarChart from './components/BarChart.vue' import { unitTotal, hovUnit, shipUnit, shipVoyage } from '../../api/statistics' import { getYearRange } from '../../utils/index' import { initMapbox, handleWheel } from '@/utils/mapbox-utils' -import { loadVectorLayer, loadJsonPointFeature } from '@/utils/vector-layer-utils' +import { loadVectorLayer, loadJsonPointFeature, showPopupDetails,showUnitReport } from '@/utils/vector-layer-utils' import { ColorGenerator } from '@/utils/color-generator' /** @@ -184,6 +184,9 @@ export default { const nameSet = new Set(sel.map(u => u && u.unit_name).filter(Boolean)) const filtered = raw.filter(row => nameSet.has(row.unit_name)) this.applyUnitTotalRows(filtered) + + // 地图显示最后一个选中单位的相关信息 + showUnitReport('workUnitMap_uuv', this.selectedUnits.at(-1).unit_name, [this.selectedUnits.at(-1).unit_lon, this.selectedUnits.at(-1).unit_lat]) }, /**