浏览代码

feat(cockpit): 管网卡片跳过空详情并补地下视图入口,工单可退回来源,定位详情不再依赖飞行

- 管网在基础设施详情端点里没有资源(实测 404),卡片一直被红字报「设施详情未取到」。
  改为跳过远端请求,内容用管线图层的名称/类型/等级/管径/起止坐标 prefill。
- 详情页签行右侧补「查看详情 →」入口(蓝色文字、靠右):地下设施从这里进「地下管线详情视图」;
  管网按管段编码直接选中三维视图,窨井沿用原有的可渲染判定。
- 从隐患/风险详情跳工单后,工单卡点 × 退回来源详情,而不是一路关掉(entityDetailStore 记 returnTo)。
- 定位设备:打开详情与飞行并行,且详情不依赖飞行结果 —— 地形/引擎导致的飞行失败不该让详情也打不开。
ChenJZ 7 小时之前
父节点
当前提交
c4b8e94a34

+ 0 - 14
src/modules/cockpit/CockpitShell.vue

@@ -1634,20 +1634,6 @@ function openUndergroundFromDetail() {
     openFacilityUnderground()
 }
 
-/**
- * 详情卡里的「查看详情 →」:进「地下管线详情视图」。
- *
- * 管网没有设施点行(走的是实体详情抽屉),所以直接按管段编码选中三维视图;
- * 其它地下设施仍走原有判定(要有可渲染的 3D 模型与坐标)。
- */
-function openUndergroundFromDetail() {
-    const identity = entityDetailStore.identity
-    if (identity && identity.category === 'PIPE_NETWORK' && identity.id) {
-        return pipeEnhancementStore.select(PIPE_ENHANCEMENT_KIND.PIPE, identity.id)
-    }
-    openFacilityUnderground()
-}
-
 function openFacilityUnderground() {
     const target = facilityUndergroundTarget(currentFacilityRow.value)
     if (!target) return

+ 29 - 3
src/modules/cockpit/components/EntityDetailDrawer.vue

@@ -25,7 +25,14 @@
                 详情暂未取到,已保留列表摘要。
                 <button type="button" @click="store.retry">重试</button>
             </p>
-            <div class="entity-drawer__body"><EntityDetailSections :detail="store.detail" @locate-device="(code) => emit('locate-device', code)" @focus-network="(code) => emit('focus-network', code)" @open-work-order="(code) => emit('open-work-order', code)" @open-relation="(item) => emit('open-relation', item)" /></div>
+            <div class="entity-drawer__body">
+                <EntityDetailSections :detail="store.detail" @locate-device="(code) => emit('locate-device', code)" @focus-network="(code) => emit('focus-network', code)" @open-work-order="(code) => emit('open-work-order', code)" @open-relation="(item) => emit('open-relation', item)">
+                    <!-- 地下设施(管网/窨井)从详情直接进「地下管线详情视图」(维护者 2026-12-02)。 -->
+                    <template #tabs-action>
+                        <button v-if="undergroundReady" type="button" class="entity-drawer__underground" data-entity-underground @click="emit('open-underground')">查看详情 →</button>
+                    </template>
+                </EntityDetailSections>
+            </div>
         </aside>
     </Transition>
 </template>
@@ -34,8 +41,12 @@ 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' } })
-const emit = defineEmits(['locate-device', 'focus-network', 'open-work-order', 'open-relation'])
+defineProps({
+    side: { type: String, default: 'right' },
+    /** 当前详情对应的地下设施能否进「地下管线详情视图」(由外壳判定)。 */
+    undergroundReady: { type: Boolean, default: false },
+})
+const emit = defineEmits(['locate-device', 'focus-network', 'open-work-order', 'open-relation', 'open-underground'])
 const store = useEntityDetailStore()
 const view = computed(() => entityDetailView(store.detail))
 </script>
@@ -103,6 +114,21 @@ const view = computed(() => entityDetailView(store.detail))
     overflow-wrap: anywhere;
 }
 
+/* 「查看详情 →」:贴在页签行右侧的蓝色文字入口(与设施卡的按钮同一位置)。 */
+.entity-drawer__underground {
+    margin-left: auto;
+    padding: 0;
+    border: 0;
+    background: none;
+    color: var(--cyan-hi, #35d8ff);
+    font: inherit;
+    font-size: var(--fs-caption, 10.5px);
+    cursor: pointer;
+    white-space: nowrap;
+}
+.entity-drawer__underground:hover,
+.entity-drawer__underground:focus-visible { color: var(--text-strong, #eaf6ff); }
+
 .entity-drawer__close {
     width: calc(22 * var(--u, 1px));
     height: calc(22 * var(--u, 1px));

+ 22 - 0
src/modules/cockpit/stores/entityDetailStore.js

@@ -30,6 +30,8 @@ export const useEntityDetailStore = defineStore('entityDetailStore', () => {
         identity.value = next
         sourceSide.value = options.side === 'left' ? 'left' : 'right'
         listPrefill = prefill && typeof prefill === 'object' ? { ...prefill } : null
+        // 从另一个详情跳过来时记住来源,关闭时退回去(而不是把整张卡关掉)。
+        if (options.returnTo) returnTo.value = { ...options.returnTo }
         open.value = true
         error.value = ''
         // 同实体缓存命中时保留已取到的完整详情,不能先用摘要覆盖再跳过取数。
@@ -56,6 +58,17 @@ export const useEntityDetailStore = defineStore('entityDetailStore', () => {
         const mine = token
         loading.value = true
         loaded.value = false
+        /**
+         * 地下设施(管网、窨井)在基础设施详情端点里没有对应资源(实测按 category 请求 404),
+         * 卡片内容由管线图层带来的 prefill 就够。这里直接跳过远端请求,
+         * 免得界面用一条红字把「本来就没有这个端点」说成「详情取不到」。
+         */
+        if (options.skipRemote) {
+            loading.value = false
+            loaded.value = true
+            error.value = ''
+            return detail.value
+        }
         const active = { ...requestOptions, ...options, prefill }
         try {
             const result = await fetchEntityDetail(target, active)
@@ -76,7 +89,16 @@ export const useEntityDetailStore = defineStore('entityDetailStore', () => {
         }
     }
 
+    /** 跳转来源:从 A 详情跳到 B 详情时记下 A,B 关闭时退回 A 而不是整个关掉。 */
+    const returnTo = ref(null)
+
     function close() {
+        const back = returnTo.value
+        returnTo.value = null
+        if (back) {
+            void show(back)
+            return
+        }
         token += 1
         open.value = false
         loading.value = false

+ 18 - 10
src/modules/cockpit/stores/pointLocateStore.js

@@ -137,22 +137,25 @@ export const usePointLocateStore = defineStore('pointLocateStore', () => {
         // 否则揭示目标里没有设备行,图层无处可画(表现就是「定位成功但图标丢了」)。
         if (!device && plan.object.kind !== MAP_OBJECT_KIND.MONITORING_POINT) device = plan.object
 
-        let failure = TERRAIN_LOCATE_REASON.MAP
-        const applied = await flyPoint(device || plan.object, {
-            ...(device ? { tier: 'device' } : {}),
-            onFailure: (reason) => { failure = reason },
-        })
-        if (applied !== true) {
-            return setLocate({ ...base, result: LOCATE_RESULT.UNAVAILABLE, reasonText: locateFailureText(failure) })
-        }
-
-        // 揭示目标 = 实际飞到的对象;关联设备把设备坐标一起带给设备图层,
+        // 揭示目标 = 要看的对象;关联设备把设备坐标一起带给设备图层,
         // 使它在当前模式/状态(例如 NORMAL)下也能临时画出并锚定详情。
         const reveal = {
             code: plan.object.code,
             deviceCode: plan.deviceCode || '',
             ...(device ? { device } : {}),
         }
+
+        // 飞行与开详情**并行**,而且开详情不依赖飞行结果:
+        // 定位的意义是「看到它」,地形/引擎导致的飞行失败不该连带详情也打不开
+        // (维护者 2026-12-02:只飞到位置、看不到设备详情)。
+        let failure = TERRAIN_LOCATE_REASON.MAP
+        const flying = Promise.resolve()
+            .then(() => flyPoint(device || plan.object, {
+                ...(device ? { tier: 'device' } : {}),
+                onFailure: (reason) => { failure = reason },
+            }))
+            .catch(() => false)
+
         if (plan.object.kind === MAP_OBJECT_KIND.MONITORING_POINT) {
             if (plan.deviceCode) {
                 await selectDevice(plan.deviceCode, { locateTarget: reveal })
@@ -163,6 +166,11 @@ export const usePointLocateStore = defineStore('pointLocateStore', () => {
             // 独立设备没有宿主点位:直接用设备编码进设备级详情(openDevice('') 打不开任何东西)。
             await openDevice(plan.pointCode || code, { locateTarget: reveal })
         }
+
+        const applied = await flying
+        if (applied !== true) {
+            return setLocate({ ...base, result: LOCATE_RESULT.UNAVAILABLE, reasonText: locateFailureText(failure) })
+        }
         return setLocate({ ...base, result: LOCATE_RESULT.OK, reasonText: '' })
     }