Przeglądaj źródła

fix(cockpit): 管段详情按 sourceId 取,地下视图入口改由身份判断,设备定位补开详情

- 实测:基础设施详情端点对管段按 **sourceId**(raw_P4527)取返回 200,按业务编码(TCWS202609080346)取是 404。
  聚焦管网改用 sourceId 作详情标识(飞行仍按业务编码匹配),所以卡片拿到的是真实详情,
  不是「跳过请求 + 用图层摘要遮住红字」。只有拿不到 sourceId 时才跳过远端。
- 「查看详情 →」改由详情抽屉按 identity.category 自行判断(管网/窨井),去掉父组件传参的环节。
- 定位设备:定位完成后不依赖定位结果,直接按设备编码补开设备级详情 ——
  定位链在「设备未上图 / 宿主点位取不到」时不会进设备级,用户点了却看不到详情。
ChenJZ 7 godzin temu
rodzic
commit
da765874fd

+ 24 - 8
src/modules/cockpit/CockpitShell.vue

@@ -1047,9 +1047,15 @@ function locateOnMap(pointCode) {
  * 详情里的「关联设备定位」——统一走 pointLocateStore(#131)。
  * 判定、地形感知飞行、打开设备详情、揭示目标都由通用入口承担。
  */
-function locateDeviceFromDetail(deviceCode) {
+async function locateDeviceFromDetail(deviceCode) {
     if (facilityDetailOpen.value) entityDetailStore.close()
-    return pointLocateStore.locateTarget({ kind: 'map-object', code: deviceCode })
+    const result = await pointLocateStore.locateTarget({ kind: 'map-object', code: deviceCode })
+    // 兜底:定位链在「设备未上图 / 宿主点位取不到」时不会进设备级详情,
+    // 而用户点这个按钮要的是「看到设备」。这里不依赖定位结果,直接按设备编码补开一次。
+    const selection = detailStore.selection
+    const opened = selection && selection.level === DETAIL_LEVEL.EQUIPMENT && selection.deviceCode === deviceCode
+    if (!opened) await detailStore.openDevice(deviceCode, {})
+    return result
 }
 
 /**
@@ -1107,11 +1113,19 @@ function openRelationFromDetail(item) {
 }
 
 /**
- * 管段 → 设施详情卡的 prefill。
+ * 管段的详情标识。
  *
- * 管网没有自己的详情端点(实测按 category=PIPE_NETWORK 请求 404),所以卡片内容
- * 先从管线图层带出来;随后那次详情请求失败时,卡片保留这份摘要,而不是一片空白。
+ * 实测:基础设施详情端点按 **sourceId**(`raw_P4527` 这类)取才 200,
+ * 用业务编码(`TCWS202609080346`)取是 404 —— 所以详情必须用图层里的 sourceId。
+ * 拿不到 sourceId 时才退回编码(那种情况详情取不到,卡片用 prefill 兜底)。
  */
+function networkEntityId(networkCode) {
+    const pipes = (pipeNetworkStore.layer.data && pipeNetworkStore.layer.data.pipes) || []
+    const pipe = pipes.find((item) => item && item.code === networkCode)
+    return pipe && pipe.sourceId ? String(pipe.sourceId) : networkCode
+}
+
+/** 管段 → 设施详情卡的 prefill(图层里已有的名称/类型/等级/管径/起止坐标)。 */
 function networkPrefill(networkCode) {
     const pipes = (pipeNetworkStore.layer.data && pipeNetworkStore.layer.data.pipes) || []
     const pipe = pipes.find((item) => item && item.code === networkCode)
@@ -1154,12 +1168,14 @@ async function focusNetworkFromDetail(networkCode) {
             // 取不到就让下面的定位把原因如实说出来,不静默。
         }
     }
-    const identity = { kind: 'facility', id: networkCode, category: 'PIPE_NETWORK' }
+    // 详情按 sourceId 取(实测按业务编码 404);飞行也用它 —— resolveFacilityPoint 认 sourceId。
+    const entityId = networkEntityId(networkCode)
+    const identity = { kind: 'facility', id: entityId, category: 'PIPE_NETWORK' }
     // 打开卡片与飞行并行:卡片一打开,设施图标就由 facilityPointStore 的选中点派生出来。
     const [located] = await Promise.all([
         pointLocateStore.focusFacilityPoint(identity, { network: pipeNetworkStore.layer.data }),
-        // 管网在基础设施详情端点里没有资源(实测 404),直接跳过远端请求,卡片用 prefill 就够。
-        entityDetailStore.show(identity, networkPrefill(networkCode), { skipRemote: true }),
+        // 只有拿不到 sourceId 时才跳过远端(那种情况确实没有可取的详情)。
+        entityDetailStore.show(identity, networkPrefill(networkCode), entityId === networkCode ? { skipRemote: true } : {}),
     ])
     return located
 }

+ 9 - 5
src/modules/cockpit/components/EntityDetailDrawer.vue

@@ -41,13 +41,17 @@ import { computed } from 'vue'
 import { entityDetailView } from '../domain/entityDetail.js'
 import { useEntityDetailStore } from '../stores/entityDetailStore.js'
 import EntityDetailSections from './EntityDetailSections.vue'
-defineProps({
-    side: { type: String, default: 'right' },
-    /** 当前详情对应的地下设施能否进「地下管线详情视图」(由外壳判定)。 */
-    undergroundReady: { type: Boolean, default: false },
-})
+defineProps({ side: { type: String, default: 'right' } })
 const emit = defineEmits(['locate-device', 'focus-network', 'open-work-order', 'open-relation', 'open-underground'])
 const store = useEntityDetailStore()
+/**
+ * 地下设施直接从身份判断,不再依赖父组件传 prop:
+ * 详情一打开 identity 就位,按钮与卡片内容同源,少一个可能传丢的环节。
+ */
+const undergroundReady = computed(() => {
+    const category = store.identity && store.identity.category
+    return category === 'PIPE_NETWORK' || category === 'MANHOLE'
+})
 const view = computed(() => entityDetailView(store.detail))
 </script>
 <style scoped>