参航单位使用船侧数据,优化地图弹窗与统计数据交互逻辑。

This commit is contained in:
hym 2026-04-05 20:15:42 +08:00
parent 378d1b8778
commit 621b368d38
2 changed files with 31 additions and 22 deletions

View File

@ -236,7 +236,7 @@ export async function showUnitReport(mapId, unit, coordinate, callbackOnClose =
}
const description = `
<table class="popup-table" style="min-width:320px;">
<table class="popup-table" style="min-width:280px;">
<thead>
<tr>
<td colspan="2">单位参航信息</td>
@ -259,7 +259,7 @@ export async function showUnitReport(mapId, unit, coordinate, callbackOnClose =
</tr>
</table>`;
showPopupDetails({ mapId, coordinate, description, maxWidth: "350px", callbackOnClose: callbackOnClose });
showPopupDetails({ mapId, coordinate, description, maxWidth: "300px", callbackOnClose: callbackOnClose });
}
export function changeCursor(layerId, mapId = "homeMap", cursor = "pointer") {

View File

@ -85,6 +85,8 @@ export default {
selectedUnits: [],
/** unitTotal 全量缓存,便于按 Banner 选择做前端过滤 */
unitTotalRawList: [],
// Banner
totalUnits: [],
numbers: [
{
label: '参航单位数量',
@ -143,8 +145,8 @@ export default {
mounted() {
initMapbox('workUnitMap_uuv', {
tileKey: 'gaode',
zoom: 3,
center: [110, 33],
zoom: 2.8,
center: [120, 31],
minZoom: 2,
maxZoom: 29
})
@ -184,6 +186,7 @@ export default {
const filtered = raw.filter(row => nameSet.has(row.unit_name))
this.applyUnitTotalRows(filtered)
console.log('applyFilteredUnitTotal', this.selectedUnits);
//
showUnitReport('workUnitMap_uuv', this.selectedUnits.at(-1).unit_name, [this.selectedUnits.at(-1).unit_lon, this.selectedUnits.at(-1).unit_lat])
},
@ -299,12 +302,13 @@ export default {
*/
getHovUnit() {
hovUnit().then(res => {
const map = new Map()
; (res.array || []).forEach(unit => {
const k = unit.unit_id || unit.unitId || unit.unit_name
if (!map.has(k)) map.set(k, unit)
})
this.unitOptions = Array.from(map.values())
//
// const map = new Map();
// (res.array || []).forEach(unit => {
// const k = unit.unit_id || unit.unitId || unit.unit_name
// if (!map.has(k)) map.set(k, unit)
// })
// this.unitOptions = Array.from(map.values());
})
},
@ -314,11 +318,19 @@ export default {
*/
getShipUnit() {
shipUnit().then(res => {
this.totalUnits = res.array || [];
const map = new Map();
this.totalUnits.forEach(unit => {
const k = unit.unit_id || unit.unitId || unit.unit_name
if (!map.has(k)) map.set(k, unit)
})
this.unitOptions = Array.from(map.values())
const geojson = {
type: 'FeatureCollection',
features: []
};
(res.array || []).forEach(element => {
this.totalUnits.forEach(element => {
geojson.features.push({
type: 'Feature',
geometry: {
@ -338,6 +350,9 @@ export default {
Vue.config.maps['workUnitMap_uuv'].on('click', 'workUnit', async (e) => {
if (!e.features || e.features.length <= 0)
return;
// Banner Banner
this.selectedUnits = this.totalUnits.filter(u => u.unit_name === e.features[0].properties.unit_name);
//
showUnitReport('workUnitMap_uuv', e.features[0].properties.unit_name, e.features[0].geometry.coordinates, this.resetFilter);
//
@ -347,15 +362,9 @@ export default {
},
resetFilter() {
const raw = this.unitTotalRawList || []
const sel = this.selectedUnits || []
if (!sel.length) {
this.applyUnitTotalRows(raw)
return
}
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)
//
this.selectedUnits = [];
this.applyUnitTotalRows(this.unitTotalRawList || []);
}
}
}