|
@@ -11,7 +11,7 @@ import { computed, ref } from 'vue'
|
|
|
import { defineStore, acceptHMRUpdate } from 'pinia'
|
|
import { defineStore, acceptHMRUpdate } from 'pinia'
|
|
|
import { SECTION_STATE, section } from '../domain/sectionState.js'
|
|
import { SECTION_STATE, section } from '../domain/sectionState.js'
|
|
|
import { facilityInventory, filterFacilityPoints } from '../domain/facilityPoints.js'
|
|
import { facilityInventory, filterFacilityPoints } from '../domain/facilityPoints.js'
|
|
|
-import { fetchFacilityPoints } from '../services/facilityPointService.js'
|
|
|
|
|
|
|
+import { fetchFacilityPoints, refreshFacilityPointDetails } from '../services/facilityPointService.js'
|
|
|
import { useFilterStore } from './filterStore.js'
|
|
import { useFilterStore } from './filterStore.js'
|
|
|
import { useEntityDetailStore } from './entityDetailStore.js'
|
|
import { useEntityDetailStore } from './entityDetailStore.js'
|
|
|
import { usePipeNetworkStore } from './pipeNetworkStore.js'
|
|
import { usePipeNetworkStore } from './pipeNetworkStore.js'
|
|
@@ -26,7 +26,7 @@ import { cancelPointLocate, locateFacilityPoint } from '../services/mapService.j
|
|
|
function pending() {
|
|
function pending() {
|
|
|
return {
|
|
return {
|
|
|
...section(SECTION_STATE.EMPTY, {
|
|
...section(SECTION_STATE.EMPTY, {
|
|
|
- data: { points: null, inventory: facilityInventory(null, null), archivesAvailable: false, detailFailures: 0 },
|
|
|
|
|
|
|
+ data: { points: null, inventory: facilityInventory(null, null), archivesAvailable: false, archivesData: null, detailFailures: 0 },
|
|
|
}),
|
|
}),
|
|
|
loaded: false,
|
|
loaded: false,
|
|
|
}
|
|
}
|
|
@@ -127,14 +127,56 @@ export const useFacilityPointStore = defineStore('facilityPointStore', () => {
|
|
|
} catch {
|
|
} catch {
|
|
|
// 适配层不抛;真抛了也要收成失败分区,不能让一次台账失败掀掉整个外壳。
|
|
// 适配层不抛;真抛了也要收成失败分区,不能让一次台账失败掀掉整个外壳。
|
|
|
result = section(SECTION_STATE.FAILED, {
|
|
result = section(SECTION_STATE.FAILED, {
|
|
|
- data: { points: null, inventory: facilityInventory(null, null), archivesAvailable: false, detailFailures: 0 },
|
|
|
|
|
|
|
+ data: { points: null, inventory: facilityInventory(null, null), archivesAvailable: false, archivesData: null, detailFailures: 0 },
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
layer.value = { ...result, loaded: true }
|
|
layer.value = { ...result, loaded: true }
|
|
|
return layer.value
|
|
return layer.value
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- return { layer, loaded, state, reason, points, inventory, filtered, selectedPoint, renderPoints, locate, select, clearLocate, load, configure, setLayer }
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 统一刷新里的设施点那一项(票 03)。
|
|
|
|
|
+ *
|
|
|
|
|
+ * `mode='full'` —— 手动刷新:重新枚举运行信息 + 逐条补详情(与 {@link load} 同一条路径);
|
|
|
|
|
+ * `mode='details'` —— 自动轮询:只对**已枚举**的设施补详情,不重拉全量运行信息与档案。
|
|
|
|
|
+ *
|
|
|
|
|
+ * 失败只降级本层:全量失败时 `points: null`(图例说未取到);轮询全失败时保留已枚举的点位
|
|
|
|
|
+ * (如实标 failed,界面仍能看见上一轮的位置,不整层清空)。
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param {{mode?: 'full'|'details'}} [options]
|
|
|
|
|
+ * @returns {Promise<object>} 设施的 section(供 `judgeFacilityLayer` 判成败)
|
|
|
|
|
+ */
|
|
|
|
|
+ async function refresh(options = {}) {
|
|
|
|
|
+ const mode = options.mode === 'details' ? 'details' : 'full'
|
|
|
|
|
+ const current = layer.value && layer.value.data
|
|
|
|
|
+ const existing = current && Array.isArray(current.points) ? current.points : null
|
|
|
|
|
+ // 还没枚举过就没有「已枚举设施」可刷 —— 退回全量,否则图层会永远停在未取到。
|
|
|
|
|
+ if (mode === 'details' && !existing) return load()
|
|
|
|
|
+ if (mode === 'full') return load()
|
|
|
|
|
+
|
|
|
|
|
+ let result
|
|
|
|
|
+ try {
|
|
|
|
|
+ result = await refreshFacilityPointDetails(existing, requestOptions)
|
|
|
|
|
+ } catch {
|
|
|
|
|
+ result = { points: existing, detailFailures: existing.length, ok: false, reason: '' }
|
|
|
|
|
+ }
|
|
|
|
|
+ const state = result.ok ? SECTION_STATE.SUCCESS : SECTION_STATE.FAILED
|
|
|
|
|
+ const next = section(state, {
|
|
|
|
|
+ reason: result.reason || '',
|
|
|
|
|
+ data: {
|
|
|
|
|
+ // 失败时保留上一轮的点位(不整层清空),成功时用新坐标/状态替换。
|
|
|
|
|
+ points: result.points,
|
|
|
|
|
+ inventory: facilityInventory(current.archivesData || null, result.points),
|
|
|
|
|
+ archivesAvailable: current.archivesAvailable,
|
|
|
|
|
+ archivesData: current.archivesData || null,
|
|
|
|
|
+ detailFailures: result.detailFailures,
|
|
|
|
|
+ },
|
|
|
|
|
+ })
|
|
|
|
|
+ layer.value = { ...next, loaded: true }
|
|
|
|
|
+ return layer.value
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return { layer, loaded, state, reason, points, inventory, filtered, selectedPoint, renderPoints, locate, select, clearLocate, load, refresh, configure, setLayer }
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
// 更新设施选择/定位 API 时必须同步已有 Pinia 实例,不能让新组件拿着旧 store 接口。
|
|
// 更新设施选择/定位 API 时必须同步已有 Pinia 实例,不能让新组件拿着旧 store 接口。
|