|
|
@@ -1095,6 +1095,43 @@ function openRelationFromDetail(item) {
|
|
|
return false
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * 管段 → 设施详情卡的 prefill。
|
|
|
+ *
|
|
|
+ * 管网没有自己的详情端点(实测按 category=PIPE_NETWORK 请求 404),所以卡片内容
|
|
|
+ * 先从管线图层带出来;随后那次详情请求失败时,卡片保留这份摘要,而不是一片空白。
|
|
|
+ */
|
|
|
+function networkPrefill(networkCode) {
|
|
|
+ const pipes = (pipeNetworkStore.layer.data && pipeNetworkStore.layer.data.pipes) || []
|
|
|
+ const pipe = pipes.find((item) => item && item.code === networkCode)
|
|
|
+ if (!pipe) return null
|
|
|
+ const line = Array.isArray(pipe.sourceCoordinates) ? pipe.sourceCoordinates : []
|
|
|
+ const first = line[0] || null
|
|
|
+ const last = line[line.length - 1] || null
|
|
|
+ return {
|
|
|
+ code: pipe.code,
|
|
|
+ name: pipe.name || pipe.code,
|
|
|
+ category: 'PIPE_NETWORK',
|
|
|
+ location: pipe.remark || '',
|
|
|
+ coordinates: first && last
|
|
|
+ ? { longitude: first[0], latitude: first[1], endLongitude: last[0], endLatitude: last[1] }
|
|
|
+ : null,
|
|
|
+ attributes: {
|
|
|
+ networkType: pipe.networkType,
|
|
|
+ networkLevel: pipe.networkLevel,
|
|
|
+ diameterMillimeters: pipe.diameter,
|
|
|
+ remark: pipe.remark,
|
|
|
+ },
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 关联管网聚焦 = 复用设施那条链的三件事:**打开设施详情卡 + 画出设施图标 + 飞到管段中点**。
|
|
|
+ *
|
|
|
+ * 为什么不用 `locateFacility`:那条路走 `facilityPointStore.select` 的竞态令牌,
|
|
|
+ * 详情关闭或并发选择会把本次调用判成过期并返回 false(表现为「设施定位未完成」)。
|
|
|
+ * 这里把三件事拆开各自确定性执行,飞行交给不参与令牌的 `focusFacilityPoint`。
|
|
|
+ */
|
|
|
async function focusNetworkFromDetail(networkCode) {
|
|
|
if (!networkCode) return false
|
|
|
if (facilityDetailOpen.value) entityDetailStore.close()
|
|
|
@@ -1106,12 +1143,13 @@ async function focusNetworkFromDetail(networkCode) {
|
|
|
// 取不到就让下面的定位把原因如实说出来,不静默。
|
|
|
}
|
|
|
}
|
|
|
- // 只飞行、不开详情:走独立入口,不参与设施定位的竞态令牌
|
|
|
- // (旧路径会因详情关闭/并发选择被判过期,表现为「设施定位未完成」)。
|
|
|
- return pointLocateStore.focusFacilityPoint(
|
|
|
- { kind: 'facility', id: networkCode, category: 'PIPE_NETWORK' },
|
|
|
- { network: pipeNetworkStore.layer.data },
|
|
|
- )
|
|
|
+ const identity = { kind: 'facility', id: networkCode, category: 'PIPE_NETWORK' }
|
|
|
+ // 打开卡片与飞行并行:卡片一打开,设施图标就由 facilityPointStore 的选中点派生出来。
|
|
|
+ const [located] = await Promise.all([
|
|
|
+ pointLocateStore.focusFacilityPoint(identity, { network: pipeNetworkStore.layer.data }),
|
|
|
+ entityDetailStore.show(identity, networkPrefill(networkCode)),
|
|
|
+ ])
|
|
|
+ return located
|
|
|
}
|
|
|
|
|
|
function openLedgerCard(pointCode) {
|