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

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

View File

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