浏览代码

feat(cockpit): 统一点位定位入口并补报警/工单定位

- 新增 pointLocateStore:设备/监测点/事件回联/设施共用 locateTarget,
  负责解析、地形感知完整视角、打开对应详情、写 #127 揭示目标与统一反馈
- monitoringStore / infrastructureStore / eventStore 的定位改为薄包装;
  事件回联不再 setCameraFocus 只换中心,改走完整视角 + 高亮(修报警详情定位)
- 设施点地图点击与面板卡也走统一入口(内部仍复用 facilityPointStore 详情流)
- workOrderRows 补回 deviceCode,设备详情工单卡加「定位设备」按钮并接到外壳
- 新增 tests/point-locate.test.js(4 项)
ChenJZ 1 天之前
父节点
当前提交
045768f1c6

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

@@ -392,6 +392,7 @@
                 @device-close="enhancementDevicesStore.closeDetail"
                 @device-retry="enhancementDevicesStore.open(enhancementDevicesStore.selected)"
                 @radius-change="pipeEnhancementStore.setRadius"
+                @locate-device="locateDeviceFromDetail"
                 @close="closePipeEnhancement"
             />
 
@@ -503,7 +504,7 @@
                     @locate-device="locateDeviceFromDetail"
                     @open-underground="openFacilityUnderground"
                 />
-                <PointDetailCard v-else :location-reason="fixedLocationReason" />
+                <PointDetailCard v-else :location-reason="fixedLocationReason" @locate-device="locateDeviceFromDetail" />
             </aside>
             <aside v-if="eventStore.selectedEvent && uiStore.mode === 'warningResponse' && !introVisible"
                 class="cockpit-shell__event-detail" aria-label="事件详情" @keydown.esc="eventStore.closeEvent()">
@@ -614,6 +615,7 @@ import { useDetailStore } from './stores/detailStore.js'
 import { useDeviceLayerStore } from './stores/deviceLayerStore.js'
 import { useInfrastructureStore } from './stores/infrastructureStore.js'
 import { useMonitoringStore } from './stores/monitoringStore.js'
+import { usePointLocateStore } from './stores/pointLocateStore.js'
 import { useDeviceStatusStore } from './stores/deviceStatusStore.js'
 import { useEventStore } from './stores/eventStore.js'
 import { useEntityDetailStore } from './stores/entityDetailStore.js'
@@ -678,6 +680,7 @@ const detailStore = useDetailStore()
 const mapStore = useMapStore()
 const infrastructureStore = useInfrastructureStore()
 const monitoringStore = useMonitoringStore()
+const pointLocateStore = usePointLocateStore()
 // 维护者 2026-11-04:设备状态池是**全站口径**(顶部状态栏四个模式都常驻),
 // 所以它有独立的全局数据源,不挂在「运行监测」的面板分区上。
 const deviceStatusStore = useDeviceStatusStore()
@@ -950,11 +953,11 @@ function panelMeta(panelId) {
     return `${view.blocks.length} 组读数`
 }
 
-/** 定位反馈:只有失败情形值得给一行字(成功时地图与详情卡自己会说话)。 */
+/** 定位反馈:取最近一次失败结果(成功时地图与详情卡自己会说话)。 */
 const locateFeedback = computed(() => {
-    const current = facilityPointStore.locate || infrastructureStore.locate
-    if (!current || !current.result || current.result === LOCATE_RESULT.OK) return null
-    return current
+    const candidates = [pointLocateStore.locate, facilityPointStore.locate].filter((item) => item && item.result)
+    const latest = candidates.sort((a, b) => (b.at || 0) - (a.at || 0))[0]
+    return latest && latest.result !== LOCATE_RESULT.OK ? latest : null
 })
 
 /** 离开 /cockpit 后不再启动延迟任务(重图层空闲加载可能晚于卸载)。 */
@@ -1001,6 +1004,7 @@ watch(locateFeedback, (current) => {
     if (!current) return
     locateDismissTimer = window.setTimeout(() => {
         locateDismissTimer = null
+        pointLocateStore.clearLocate()
         infrastructureStore.clearLocate()
         facilityPointStore.clearLocate()
     }, 8000)
@@ -1011,12 +1015,14 @@ function dismissLocateFeedback() {
         window.clearTimeout(locateDismissTimer)
         locateDismissTimer = null
     }
+    pointLocateStore.clearLocate()
     infrastructureStore.clearLocate()
     facilityPointStore.clearLocate()
 }
 
-/** 点面板里的可定位对象 → 地图定位(接缝在 store,本组件只管转发)。 */function locateOnMap(pointCode) {
-    return infrastructureStore.locatePoint(pointCode)
+/** 点面板里的可定位对象 → 地图定位(#131:统一走 pointLocateStore)。 */
+function locateOnMap(pointCode) {
+    return pointLocateStore.locateTarget({ kind: 'map-object', code: pointCode })
 }
 
 /**
@@ -1026,13 +1032,12 @@ function dismissLocateFeedback() {
  * 与地图设施点点击共用 facilityPointStore.select,不再走历史固定抽屉。
  */
 /**
- * 详情里的「关联设备定位」——沿用运行监测「设备台账」的定位方法(维护者 2026-10-29)。
- * 即 `monitoringStore.locateCode`:判定能否定位 → 地形感知飞行 → 进设备详情;
- * 三种「点不动」由 `domain/mapLocate.js` 如实反馈,不另造第二套。
+ * 详情里的「关联设备定位」——统一走 pointLocateStore(#131)。
+ * 判定、地形感知飞行、打开设备详情、揭示目标都由通用入口承担。
  */
 function locateDeviceFromDetail(deviceCode) {
     if (facilityDetailOpen.value) entityDetailStore.close()
-    return monitoringStore.locateCode(deviceCode)
+    return pointLocateStore.locateTarget({ kind: 'map-object', code: deviceCode })
 }
 
 function openLedgerCard(pointCode) {
@@ -1048,8 +1053,8 @@ function handleCardAction(action, sourceSide = 'right') {
     }
     if (action.kind === CARD_ACTION.POINT) return selectMonitoringPoint(action.code, { mode: mode.value })
     // 维护者 2026-10-29:设备台账卡要像监测点台账一样「定位 + 进设备级详情」。
-    // `locateCode` 是既有的设备维度定位接缝(判定 → 相机 → 详情),不新造第二条路径。
-    if (action.kind === CARD_ACTION.DEVICE) return monitoringStore.locateCode(action.code)
+    // #131:统一走 pointLocateStore,不再另造设备维度定位路径。
+    if (action.kind === CARD_ACTION.DEVICE) return pointLocateStore.locateTarget({ kind: 'map-object', code: action.code })
     const row = action.row || {}
     const prefill = row.identityPayload || row
     if (action.kind === CARD_ACTION.EVENT) {
@@ -1061,7 +1066,14 @@ function handleCardAction(action, sourceSide = 'right') {
         }, prefill, { side: sourceSide })
     }
     if (action.kind === CARD_ACTION.FACILITY) {
-        return facilityPointStore.select({ kind: 'facility', id: action.code, category: row.identityCategory || row.category || '' }, prefill, { side: sourceSide })
+        return pointLocateStore.locateTarget({
+            kind: 'facility',
+            code: action.code,
+            category: row.identityCategory || row.category || '',
+            facility: { kind: 'facility', id: action.code, category: row.identityCategory || row.category || '' },
+            prefill,
+            side: sourceSide,
+        })
     }
     if ([CARD_ACTION.WORK_ORDER, CARD_ACTION.EMERGENCY].includes(action.kind)) {
         return entityDetailStore.show({

+ 23 - 1
src/modules/cockpit/components/EquipmentDetailSections.vue

@@ -287,7 +287,9 @@
                             </span>
                             <span class="equipment-section__wo-row">
                                 <span class="equipment-section__wo-label">关联设备</span>
-                                <span data-work-order-device>{{ order.deviceLabel }}</span>
+                                <span class="equipment-section__wo-value" data-work-order-device>{{ order.deviceLabel }}</span>
+                                <button v-if="order.deviceCode" type="button" class="equipment-section__locate"
+                                    :data-locate-device="order.deviceCode" @click.stop="locateDevice(order.deviceCode)">定位设备</button>
                             </span>
                             <span class="equipment-section__wo-row">
                                 <span class="equipment-section__wo-label">设备位置</span>
@@ -481,6 +483,12 @@ const props = defineProps({
     deviceCode: { type: String, default: '' },
     monitorSource: { type: String, default: 'detail' },
 })
+const emit = defineEmits(['locate-device'])
+
+/** 工单卡「关联设备」定位:#131 统一由外壳的 pointLocateStore 处理。 */
+function locateDevice(code) {
+    if (code) emit('locate-device', code)
+}
 
 const sectionsRoot = ref(null)
 const panels = computed(() => equipmentPanels(props.aggregate))
@@ -1250,6 +1258,20 @@ function isPlaceholder(text) {
     line-height: 1.5;
 }
 .equipment-section__wo-row > span:last-child { min-width: 0; overflow-wrap: anywhere; }
+.equipment-section__wo-value { min-width: 0; flex: 1; overflow-wrap: anywhere; }
+.equipment-section__locate {
+    flex: none;
+    padding: 0 calc(7 * var(--u, 1px));
+    border: 1px solid rgba(1, 171, 234, .45);
+    border-radius: calc(9 * var(--u, 1px));
+    background: rgba(0, 20, 72, .5);
+    color: var(--cyan-hi, #35d8ff);
+    font: inherit;
+    font-size: calc(10 * var(--u, 1px));
+    cursor: pointer;
+}
+.equipment-section__locate:hover,
+.equipment-section__locate:focus-visible { border-color: var(--cyan-hi, #00b8ff); color: var(--text-strong); }
 /* 工单详情子页签(维护者 2026-11-23):工单信息与处置流程分开看,各自独立。 */
 .equipment-section__wo-tabs {
     display: flex;

+ 11 - 5
src/modules/cockpit/components/MapCanvas.vue

@@ -179,6 +179,7 @@ import { storeToRefs } from 'pinia'
 import { useDeviceLayerStore } from '../stores/deviceLayerStore.js'
 import { useEntityDetailStore } from '../stores/entityDetailStore.js'
 import { useFacilityPointStore } from '../stores/facilityPointStore.js'
+import { usePointLocateStore } from '../stores/pointLocateStore.js'
 import { useFilterStore } from '../stores/filterStore.js'
 import { useMapStore } from '../stores/mapStore.js'
 import { useDeviceStatusStore } from '../stores/deviceStatusStore.js'
@@ -252,6 +253,7 @@ const DEVICE_POOL_ROW_KEYS = ['ALARM', 'WARNING', 'WORK_ORDER', 'NORMAL', 'OFFLI
 const { pointStatus: selectedStatuses, facilityTypes: selectedFacilityTypes } = storeToRefs(filterStore)
 // 票 68:设施点的图例口径来自设施点图层 store(档案计数 + 可上图数),只读不写。
 const facilityPointStore = useFacilityPointStore()
+const pointLocateStore = usePointLocateStore()
 // 票 101:设施点点击打开的详情与「设施台账」卡片点击**同一个** store(同一份设施实体详情)。
 const entityDetailStore = useEntityDetailStore()
 
@@ -620,11 +622,15 @@ function handlePointPick(picked) {
     //(领域层 `clickable` 已拦),这里再兜一层,不伪装可点。
     if (picked.kind === 'facility-point') {
         if (!picked.id || !picked.category) return
-        return facilityPointStore.select(
-            { kind: 'facility', id: picked.id, category: picked.category },
-            { category: picked.category, industry: picked.industry, status: picked.status, name: picked.name, code: picked.code },
-            { side: 'right' },
-        )
+        // #131:设施点点击也走统一入口;设施详情取数仍由 facilityPointStore 承担。
+        return pointLocateStore.locateTarget({
+            kind: 'facility',
+            code: picked.id,
+            category: picked.category,
+            facility: { kind: 'facility', id: picked.id, category: picked.category },
+            prefill: { category: picked.category, industry: picked.industry, status: picked.status, name: picked.name, code: picked.code },
+            side: 'right',
+        })
     }
     // 票 41:监测点走**统一选择入口**(与台账卡片同一条)——它负责点位级定位 + 打开两级详情。
     if (picked.kind === 'monitoring-point') selectMonitoringPoint(picked.code)

+ 2 - 2
src/modules/cockpit/components/PipeEnhancement.vue

@@ -80,7 +80,7 @@
                                 <p class="pipe-enhancement__hint">设备详情暂不可用</p>
                                 <button type="button" class="pipe-enhancement__action" @click="$emit('device-retry')">重新加载</button>
                             </template>
-                            <EquipmentDetailSections v-else :aggregate="deviceState.aggregate" :device-code="deviceState.selected.code" monitor-source="enhancement" />
+                            <EquipmentDetailSections v-else :aggregate="deviceState.aggregate" :device-code="deviceState.selected.code" monitor-source="enhancement" @locate-device="(code) => emit('locate-device', code)" />
                         </template>
                         <template v-else-if="assetKind === 'facility'">
                             <p v-if="assetFacility?.loading" class="pipe-enhancement__hint" data-asset-facility-loading>设施详情加载中…</p>
@@ -123,7 +123,7 @@ const props = defineProps({
     /** 设施详情状态:{ detail, loading, error };由外壳把选中设施接进来,与设备详情并列可选。 */
     facilityState: { type: Object, default: () => ({ detail: null, loading: false, error: false }) },
 })
-const emit = defineEmits(['close', 'radius-change', 'device-pick', 'device-close', 'device-retry', 'devices-reload', 'object-pick', 'facility-retry'])
+const emit = defineEmits(['close', 'radius-change', 'device-pick', 'device-close', 'device-retry', 'devices-reload', 'object-pick', 'facility-retry', 'locate-device'])
 
 /**
  * 右侧两个页签:管道临近资产(原双列列表)|资产详情(设备或设施)。

+ 2 - 0
src/modules/cockpit/components/PointDetailCard.vue

@@ -287,6 +287,7 @@
                 data-device-detail-body
                 :aggregate="aggregateSection"
                 :device-code="selection.deviceCode"
+                @locate-device="(code) => emit('locate-device', code)"
             />
         </div>
     </section>
@@ -325,6 +326,7 @@ const props = defineProps({
      */
     locationReason: { type: String, default: '' },
 })
+const emit = defineEmits(['locate-device'])
 const detailStore = useDetailStore()
 const mapStore = useMapStore()
 // 票 42:关联设备清单与它的独立图例(总数来自当前快照,不由本组件重算)。

+ 2 - 0
src/modules/cockpit/domain/equipmentDetailView.js

@@ -482,6 +482,8 @@ export function workOrderRows(data) {
             // 维护者 2026-11-13:卡片按管理端样式展示(工单号/描述/关联设备/设备位置/故障时间)。
             title: order.code || DETAIL_PLACEHOLDER,
             deviceLabel: [order.deviceName, order.deviceCode ? `(${order.deviceCode})` : ''].filter(Boolean).join('') || DETAIL_PLACEHOLDER,
+            // #131:工单卡加设备定位按钮需要独立编码(设备名为空时也能定位)。
+            deviceCode: order.deviceCode || '',
             deviceLocation: order.deviceLocation || DETAIL_PLACEHOLDER,
             faultTimeText: formatEventTime(order.faultTime),
             // 详情要用的其余字段原样带到行视图(组件不回头翻领域对象)。

+ 12 - 22
src/modules/cockpit/stores/eventStore.js

@@ -29,9 +29,9 @@ import { REQUEST_REASON } from '../domain/requestReason.js'
 import { EVENT_FAMILY } from '../domain/events.js'
 import { currentEventsView, prepareCurrentEventItems, isKnownEventMode, refreshedEventSelection } from '../domain/eventList.js'
 import { fetchCurrentEvents } from '../services/eventApi.js'
-import { EVENT_DETAIL_RESULT, eventDetailView, planEventLocate } from '../domain/eventDetail.js'
-import { getCameraState, getAssociatedDeviceState, highlightMapObject, setCameraFocus } from '../services/mapService.js'
-import { useMapStore } from './mapStore.js'
+import { eventDetailView } from '../domain/eventDetail.js'
+import { highlightMapObject } from '../services/mapService.js'
+import { usePointLocateStore } from './pointLocateStore.js'
 import { EVENT_RANGES } from '../domain/warningResponsePanels.js'
 import { eventTimeWindow, historyWindows } from '../domain/eventRange.js'
 import { fetchEventAnalysis, fetchEventHistory, fetchHandlingEfficiency, fetchIncidentTrend } from '../services/warningResponseApi.js'
@@ -626,25 +626,15 @@ export const useEventStore = defineStore('eventStore', () => {
     async function locateEvent(event = selectedEvent.value, deps = {}) {
         if (event) selectedEvent.value = event
         const current = selectedEvent.value
-        const mapStore = useMapStore()
-        const objects = deps.objects || [
-            ...getAssociatedDeviceState().plan.filter((row) => row.placement === 'drawn').map((row) => ({ ...row, kind: 'monitoring-device' })),
-            ...mapStore.summary.objects,
-        ]
-        const mapReady = deps.mapReady === undefined ? !!getCameraState() : !!deps.mapReady
-        const plan = planEventLocate(current, objects, mapReady)
-        locate.value = { result: plan.result, deviceCode: plan.deviceCode, pointCode: plan.pointCode, reasonText: plan.reasonText }
-        if (plan.result !== EVENT_DETAIL_RESULT.OK) return locate.value
-        const focus = deps.focus || setCameraFocus
-        const highlight = deps.highlight || highlightMapObject
-        if (!plan.target || focus(plan.target) !== true) {
-            locate.value = { result: EVENT_DETAIL_RESULT.UNAVAILABLE, deviceCode: plan.deviceCode, pointCode: plan.pointCode, reasonText: '地图尚未就绪,稍后重试' }
-            return locate.value
-        }
-        // 设备与关联管线一起高亮;一个都没高亮到 = 目标还没上图(如实说,不假装成功)。
-        const matched = highlight(plan.codes)
-        if (!matched) {
-            locate.value = { result: EVENT_DETAIL_RESULT.UNAVAILABLE, deviceCode: plan.deviceCode, pointCode: plan.pointCode, reasonText: '关联设备尚未出现在地图上' }
+        // #131:事件回联也走通用点位定位(完整视角 + 高亮),不再用 setCameraFocus 只换中心。
+        const locator = usePointLocateStore()
+        const result = await locator.locateTarget({ kind: 'event', event: current }, deps)
+        locate.value = {
+            result: result.result,
+            code: (current && current.code) || '',
+            deviceCode: result.deviceCode || '',
+            pointCode: result.pointCode || '',
+            reasonText: result.reasonText,
         }
         return locate.value
     }

+ 2 - 2
src/modules/cockpit/stores/facilityPointStore.js

@@ -59,12 +59,12 @@ export const useFacilityPointStore = defineStore('facilityPointStore', () => {
         const mine = ++selectToken
         cancelPointLocate()
         useDetailStore().closeDetail()
-        locate.value = { result: 'ok', pointCode: '', reasonText: '' }
+        locate.value = { result: 'ok', pointCode: '', reasonText: '', at: Date.now() }
         await entityStore.show(identity, prefill, options)
         if (mine !== selectToken || !entityStore.open || !sameEntity(entityStore.identity, identity)) return false
         const point = selectedPoint.value
         const finish = (result, reasonText = '') => {
-            locate.value = { result, pointCode: point?.code || identity.id, reasonText }
+            locate.value = { result, pointCode: point?.code || identity.id, reasonText, at: Date.now() }
             return locate.value
         }
         if (!point || point.placement === 'pending') return finish('unavailable', point?.reasonText || '设施位置尚未取到,请稍后重试')

+ 12 - 54
src/modules/cockpit/stores/infrastructureStore.js

@@ -18,18 +18,14 @@ import { defineStore } from 'pinia'
 import { SECTION_STATE, section } from '../domain/sectionState.js'
 import { REQUEST_REASON } from '../domain/requestReason.js'
 import { INFRASTRUCTURE_PANEL_IDS } from '../domain/infrastructurePanels.js'
-import { LOCATE_RESULT, locateFailureText, planLocate } from '../domain/mapLocate.js'
-import { TERRAIN_LOCATE_REASON } from '../domain/pointLocate.js'
-import { MAP_OBJECT_KIND } from '../domain/mapSummary.js'
+import { LOCATE_RESULT } from '../domain/mapLocate.js'
 import {
     fetchBaseArchives,
     fetchEmergencySupport,
     fetchManagementInformation,
     fetchOperatingInformation,
 } from '../services/infrastructureApi.js'
-import { getCameraState, locateMonitoringPoint } from '../services/mapService.js'
-import { useDetailStore } from './detailStore.js'
-import { useMapStore } from './mapStore.js'
+import { usePointLocateStore } from './pointLocateStore.js'
 
 /** 未取数时的分区(与 `detailStore.pending()` 同形,`loaded:false` 表示"还没请求过")。 */
 function pending() {
@@ -110,59 +106,21 @@ export const useInfrastructureStore = defineStore('infrastructureStore', () => {
     }
 
     /**
-     * 点面板里的可定位对象 → 联动地图(票 17 验收第 6 条;票 38 第 5 条修复「点了没反应」)。
+     * 点面板里的可定位对象 → 联动地图(#131 起是薄包装)。
      *
-     * 三步,顺序有意为之:
-     *   1. **先判定**能否定位(纯函数:找不到 / 后端说不可上图 / 地图未就绪,三种分得开);
-     *   2. 判定通过再动相机,两类对象都走**地形感知接缝** `locateMonitoringPoint`
-     *      (票 53:中心高程取采样地表,取不到就失败,不以椭球 0 冒充成功),
-     *      **分流保留**:监测点 = 点位级完整视角(`pointSelection` 同一条相机语义),
-     *      非监测点 = `centerOnly` 只换中心、保持 heading/range(ADR 0008 的中心规则)。
-     *      票 38 实测的「没反应」根因之一:旧写法 `setCameraFocus` 按 ADR 0008 只换中心、
-     *      行星球尺度下镜头几乎无感,而点地图上的同一个点位是真的会飞;
-     *      同一件事两种手感,慢的那个就被读成缺陷。
-     *   3. 相机没吃下指令(引擎未接上 / 地形采样取不到 / 被更新指令顶掉)时**按原因**如实降级
-     *      (地图未就绪 / 坐标不可用 / 地形待确认三种说法,票 53 验收第 3 条),
-     *      **不假装定位成功**;成功才开两级详情(设备图层由外壳既有的
-     *      selection 监听按同一条件 force 同步,本层不越权)。
-     * @param {string} pointCode 目标编码(点位编码,或**关联设备编码** —— 后者由 `planLocate` 回联宿主监测点)
+     * 判定、地形感知完整视角、打开详情、揭示目标全部由 `pointLocateStore.locateTarget`
+     * 单点入口承担;本 store 只保留 `locate` 读数给基础设施面板显示结果。
+     * @param {string} pointCode 目标编码(点位编码或设备编码)
      * @param {object} [deps] 注入点(单测用):`{ objects, mapReady, flyPoint, openPoint, openDevice }`
      */
     async function locatePoint(pointCode, deps = {}) {
-        const mapStore = useMapStore()
-        const detailStore = useDetailStore()
-
-        const objects = deps.objects || mapStore.summary.objects
-        // 就绪判据用相机状态:引擎还没接上时 `getCameraState()` 回 null(票 03 的交接点)。
-        const mapReady = deps.mapReady === undefined ? !!getCameraState() : !!deps.mapReady
-        const flyPoint = deps.flyPoint || locateMonitoringPoint
-        const openPoint = deps.openPoint || ((code) => detailStore.openPoint(code))
-        const openDevice = deps.openDevice || ((code) => detailStore.selectDevice(code))
-
-        const plan = planLocate({ objects, pointCode, mapReady })
-        locate.value = { result: plan.result, pointCode: plan.pointCode, reasonText: plan.reasonText }
-        if (plan.result !== LOCATE_RESULT.OK) return locate.value
-
-        // 默认按「地图未就绪」口径:接缝没给原因时不替用户猜成地形问题(票 53 验收第 3 条)。
-        let failureReason = TERRAIN_LOCATE_REASON.MAP
-        const applied = await flyPoint(plan.object, {
-            centerOnly: plan.object.kind !== MAP_OBJECT_KIND.MONITORING_POINT,
-            onFailure: (reason) => { failureReason = reason },
-        })
-        if (applied !== true) {
-            locate.value = {
-                result: LOCATE_RESULT.UNAVAILABLE,
-                pointCode: plan.pointCode,
-                reasonText: locateFailureText(failureReason),
-            }
-            return locate.value
+        const locator = usePointLocateStore()
+        const result = await locator.locateTarget({ kind: 'map-object', code: pointCode }, deps)
+        locate.value = {
+            result: result.result,
+            pointCode: result.pointCode || pointCode,
+            reasonText: result.reasonText,
         }
-
-        // 开的是**回联到的对象自己的编码**(票 38 第二轮:点关联设备时那是它的宿主监测点),
-        // 再进设备级 —— 与点地图上同一个点位、再点它的设备卡片是同一条详情路径,
-        // 「返回点位」才回得去。`plan.pointCode`(点击的那个码)只用于反馈显示。
-        await openPoint(plan.object.code)
-        if (plan.deviceCode) await openDevice(plan.deviceCode)
         return locate.value
     }
 

+ 13 - 53
src/modules/cockpit/stores/monitoringStore.js

@@ -29,8 +29,6 @@ import { MONITORING_PANEL_IDS, shouldLoadBadge } from '../domain/monitoringPanel
 import { createLedgerLoader, ledgerLoading, ledgerView } from '../domain/ledgerLoader.js'
 // 票 37:类型码的归一收口(数据值无静态白名单,认不出回空串=不筛)。
 import { normalizeDeviceType } from '../domain/filterOptions.js'
-import { LOCATE_RESULT, locateFailureText, planLocate } from '../domain/mapLocate.js'
-import { TERRAIN_LOCATE_REASON } from '../domain/pointLocate.js'
 import {
     fetchMonitoringDistribution,
     fetchMonitoringDistributionBatch,
@@ -39,9 +37,7 @@ import {
     fetchMonitoringSituation,
 } from '../services/monitoringApi.js'
 import { fetchMonitoringPointDetail } from '../services/detailApi.js'
-import { getCameraState, locateMonitoringPoint } from '../services/mapService.js'
-import { useDetailStore } from './detailStore.js'
-import { useMapStore } from './mapStore.js'
+import { usePointLocateStore } from './pointLocateStore.js'
 import { sameInputs } from '../domain/panelViewCache.js'
 // 票 41:监测点选择的统一入口(与地图点选共用同一个函数)。
 import { selectMonitoringPoint } from '../pointSelection.js'
@@ -408,57 +404,21 @@ export const useMonitoringStore = defineStore('monitoringStore', () => {
     }
 
     /**
-     * 点运行概况里的异常设备 → 联动地图(复用票 17 立的那条共享接缝 ④)。
+     * 点运行概况里的异常设备 → 联动地图。
      *
-     * 三步,顺序有意为之:先判定能否定位(三种"点不动"分得开)→ 判定通过再动相机
-     * → 相机下发成功再打开两级详情。票 53:相机走**地形感知接缝** `locateMonitoringPoint`
-     * (中心高程取采样地表,取不到就失败,不以椭球 0 冒充成功),按失败原因如实给说法
-     * (地图未就绪 / 坐标不可用 / 地形待确认),**不假装定位成功**。
-     * @param {string} code 目标编码(异常设备是设备维度,但未关联设备也以自身编码上图)
-     * @param {object} [deps] 注入点(单测用):`{ objects, mapReady, flyPoint, openPoint }`
+     * #131 起本函数只做**薄包装**:判定、地形感知飞行、打开详情、揭示目标全部由
+     * `pointLocateStore.locateTarget` 这一条通用入口承担;本 store 保留 `locate` 读数
+     * 供运行监测面板自己显示结果,不再维护第二套定位实现。
+     * @param {string} code 目标编码(设备编码;关联设备由通用入口回联宿主点位)
+     * @param {object} [deps] 注入点(单测用):`{ objects, mapReady, flyPoint, openPoint, openDevice, selectDevice }`
      */
     async function locateCode(code, deps = {}) {
-        const mapStore = useMapStore()
-        const detailStore = useDetailStore()
-
-        const objects = deps.objects || mapStore.summary.objects
-        const mapReady = deps.mapReady === undefined ? !!getCameraState() : !!deps.mapReady
-        const flyPoint = deps.flyPoint || locateMonitoringPoint
-        const openPoint = deps.openPoint || ((value, options) => detailStore.openPoint(value, options))
-
-        const plan = planLocate({ objects, pointCode: code, mapReady })
-        locate.value = { result: plan.result, pointCode: plan.pointCode, reasonText: plan.reasonText }
-        if (plan.result !== LOCATE_RESULT.OK) return locate.value
-
-        // 默认按「地图未就绪」口径:接缝没给原因时不替用户猜成地形问题(票 53 验收第 3 条)。
-        let failureReason = TERRAIN_LOCATE_REASON.MAP
-        const applied = await flyPoint(plan.object, {
-            onFailure: (reason) => { failureReason = reason },
-        })
-        if (applied !== true) {
-            locate.value = {
-                result: LOCATE_RESULT.UNAVAILABLE,
-                pointCode: plan.pointCode,
-                reasonText: locateFailureText(failureReason),
-            }
-            return locate.value
-        }
-
-        // 定位 = 让目标可见(#127):打开详情时把「揭示目标」写进 detailStore,
-        // 由模式计划临时放行;关闭/换选择/切模式/改图例筛选时清除。
-        if (plan.object.kind === 'monitoring-point') {
-            const hostCode = plan.object.code
-            if (plan.deviceCode) {
-                // 关联设备:先打开宿主点位(第一级),再进设备级;揭示目标是宿主点位标记。
-                await openPoint(hostCode)
-                await detailStore.selectDevice(plan.deviceCode, {
-                    locateTarget: { code: hostCode, deviceCode: plan.deviceCode },
-                })
-            } else {
-                await openPoint(hostCode, { locateTarget: { code: hostCode } })
-            }
-        } else {
-            await detailStore.openDevice(plan.pointCode, { locateTarget: { code: plan.pointCode } })
+        const locator = usePointLocateStore()
+        const result = await locator.locateTarget({ kind: 'map-object', code }, deps)
+        locate.value = {
+            result: result.result,
+            pointCode: result.pointCode || code,
+            reasonText: result.reasonText,
         }
         return locate.value
     }

+ 165 - 0
src/modules/cockpit/stores/pointLocateStore.js

@@ -0,0 +1,165 @@
+/**
+ * 坐标点定位的唯一入口(#131)。
+ *
+ * 为什么收成一个 store:设备、监测点、设施、事件回联原本各自实现「解析 → 飞相机 →
+ * 开详情 → 反馈」,同一件事四份代码、四种手感(有的只换中心、有的不开详情、有的不复用
+ * #127 的揭示)。本 store 只做**编排**:解析交给既有 domain 纯函数,相机/高亮交给
+ * mapService,详情交给 detailStore / facilityPointStore;调用方只传目标身份。
+ *
+ * 目标形状:
+ *   - `{ kind: 'map-object', code }`:监测点、未关联设备或关联设备编码(后者由
+ *     `planLocate` 回联宿主点位);设备与监测点共用同一条地形感知完整视角。
+ *   - `{ kind: 'event', event }`:事件详情卡回联;用 `planEventLocate` 解析,飞完整视角 + 高亮,
+ *     不替换已打开的事件详情卡。
+ *   - `{ kind: 'facility', code, category?, facility?, prefill? }`:设施点;设施专用详情流
+ *     仍由 `facilityPointStore.select` 承担,本 store 只统一入口与反馈。
+ */
+import { ref } from 'vue'
+import { defineStore } from 'pinia'
+import { useMapStore } from './mapStore.js'
+import { useDetailStore } from './detailStore.js'
+import { useFacilityPointStore } from './facilityPointStore.js'
+import {
+    getAssociatedDeviceState,
+    getCameraState,
+    highlightMapObject,
+    locateMonitoringPoint,
+} from '../services/mapService.js'
+import { LOCATE_RESULT, locateFailureText, planLocate } from '../domain/mapLocate.js'
+import { EVENT_DETAIL_RESULT, planEventLocate } from '../domain/eventDetail.js'
+import { TERRAIN_LOCATE_REASON } from '../domain/pointLocate.js'
+import { MAP_OBJECT_KIND } from '../domain/mapSummary.js'
+
+const EMPTY_RESULT = { result: '', code: '', pointCode: '', deviceCode: '', reasonText: '', at: 0 }
+
+export const usePointLocateStore = defineStore('pointLocateStore', () => {
+    const mapStore = useMapStore()
+    const detailStore = useDetailStore()
+    const facilityPointStore = useFacilityPointStore()
+
+    /** 最近一次定位的统一反馈(成功/失败都写;外壳与各面板读它)。 */
+    const locate = ref({ ...EMPTY_RESULT })
+
+    function setLocate(next = {}) {
+        locate.value = { ...EMPTY_RESULT, ...next, at: Date.now() }
+        return locate.value
+    }
+
+    function clearLocate() {
+        locate.value = { ...EMPTY_RESULT }
+    }
+
+    /** 事件回联的可用目标:已上图的关联设备 + 地图摘要对象(与 eventStore 旧口径一致)。 */
+    function eventObjects() {
+        const associated = getAssociatedDeviceState().plan
+            .filter((row) => row && row.placement === 'drawn')
+            .map((row) => ({ ...row, kind: 'monitoring-device' }))
+        return [...associated, ...(mapStore.summary.objects || [])]
+    }
+
+    async function locateMapObject(code, options = {}) {
+        const objects = options.objects || mapStore.summary.objects
+        const mapReady = options.mapReady === undefined ? !!getCameraState() : !!options.mapReady
+        const flyPoint = options.flyPoint || locateMonitoringPoint
+        const openPoint = options.openPoint || ((value, opts) => detailStore.openPoint(value, opts))
+        const openDevice = options.openDevice || ((value, opts) => detailStore.openDevice(value, opts))
+        const selectDevice = options.selectDevice || ((value, opts) => detailStore.selectDevice(value, opts))
+
+        const plan = planLocate({ objects, pointCode: code, mapReady })
+        const base = {
+            result: plan.result,
+            code,
+            pointCode: plan.pointCode,
+            deviceCode: plan.deviceCode || '',
+            reasonText: plan.reasonText,
+        }
+        if (plan.result !== LOCATE_RESULT.OK) return setLocate(base)
+
+        let failure = TERRAIN_LOCATE_REASON.MAP
+        const applied = await flyPoint(plan.object, { onFailure: (reason) => { failure = reason } })
+        if (applied !== true) {
+            return setLocate({ ...base, result: LOCATE_RESULT.UNAVAILABLE, reasonText: locateFailureText(failure) })
+        }
+
+        // 揭示目标 = 实际飞到的地图对象(关联设备是宿主点位),由 #127 的模式计划临时放行。
+        const reveal = { code: plan.object.code, deviceCode: plan.deviceCode || '' }
+        if (plan.object.kind === MAP_OBJECT_KIND.MONITORING_POINT) {
+            if (plan.deviceCode) {
+                await openPoint(plan.object.code)
+                await selectDevice(plan.deviceCode, { locateTarget: reveal })
+            } else {
+                await openPoint(plan.object.code, { locateTarget: reveal })
+            }
+        } else {
+            await openDevice(plan.pointCode, { locateTarget: reveal })
+        }
+        return setLocate({ ...base, result: LOCATE_RESULT.OK, reasonText: '' })
+    }
+
+    async function locateEvent(event, options = {}) {
+        const objects = options.objects || eventObjects()
+        const mapReady = options.mapReady === undefined ? !!getCameraState() : !!options.mapReady
+        const flyPoint = options.flyPoint || locateMonitoringPoint
+        const focus = options.focus // 仅单测注入:直接接收 plan.target(旧 eventStore 的接缝)
+        const highlight = options.highlight || highlightMapObject
+
+        const plan = planEventLocate(event, objects, mapReady)
+        const base = {
+            result: plan.result,
+            code: (event && event.code) || '',
+            pointCode: plan.pointCode || '',
+            deviceCode: plan.deviceCode || '',
+            reasonText: plan.reasonText,
+        }
+        if (plan.result !== EVENT_DETAIL_RESULT.OK) return setLocate(base)
+
+        let failure = TERRAIN_LOCATE_REASON.MAP
+        const applied = typeof focus === 'function'
+            ? await focus(plan.target)
+            : await flyPoint(plan.object, { onFailure: (reason) => { failure = reason } })
+        if (applied !== true) {
+            return setLocate({ ...base, result: LOCATE_RESULT.UNAVAILABLE, reasonText: locateFailureText(failure) })
+        }
+        // 事件不新建标记;高亮设备与关联管线,一个都没命中 = 目标还没上图,如实说。
+        const matched = highlight(plan.codes)
+        if (!matched) {
+            return setLocate({ ...base, result: LOCATE_RESULT.UNAVAILABLE, reasonText: '关联设备尚未出现在地图上' })
+        }
+        return setLocate({ ...base, result: LOCATE_RESULT.OK, reasonText: '' })
+    }
+
+    async function locateFacility(target, options = {}) {
+        const facility = target.facility || {
+            kind: 'facility',
+            id: target.code,
+            category: target.category || '',
+        }
+        const result = await facilityPointStore.select(facility, target.prefill || null, {
+            ...options,
+            side: target.side,
+            fly: options.flyPoint || options.fly,
+        })
+        if (!result) {
+            return setLocate({ result: LOCATE_RESULT.UNAVAILABLE, code: target.code, reasonText: '设施定位未完成' })
+        }
+        return setLocate({
+            result: result.result,
+            code: target.code,
+            pointCode: result.pointCode || target.code,
+            reasonText: result.reasonText || '',
+        })
+    }
+
+    /**
+     * 唯一入口:按目标身份定位。`options` 只给测试/特殊链路注入(objects / flyPoint / openPoint…),
+     * 业务调用方不传。
+     */
+    async function locateTarget(target = {}, options = {}) {
+        const kind = target.kind || 'map-object'
+        if (kind === 'facility') return locateFacility(target, options)
+        if (kind === 'event') return locateEvent(target.event, options)
+        return locateMapObject(target.code, options)
+    }
+
+    return { locate, locateTarget, clearLocate }
+})

+ 89 - 0
tests/point-locate.test.js

@@ -0,0 +1,89 @@
+/**
+ * #131 通用点位定位回归:设备/监测点/事件回联都从 `pointLocateStore.locateTarget` 进入;
+ * 工单行保留 deviceCode 供定位按钮使用。
+ */
+import assert from 'node:assert/strict'
+import { test } from 'node:test'
+import { createPinia, setActivePinia } from 'pinia'
+
+import { usePointLocateStore } from '../src/modules/cockpit/stores/pointLocateStore.js'
+import { workOrderRows } from '../src/modules/cockpit/domain/equipmentDetailView.js'
+
+const coordinate = { state: 'VALID', reason: null, renderable: true, crs: 'WGS84' }
+const device = {
+    kind: 'unassociated-equipment',
+    code: 'DEV-131',
+    name: '测试设备',
+    status: 'ALARM',
+    longitude: 110.410194,
+    latitude: 28.445044,
+    coordinate,
+}
+const point = {
+    kind: 'monitoring-point',
+    code: 'MP-131',
+    name: '测试点位',
+    status: 'ALARM',
+    deviceCodes: ['DEV-131'],
+    longitude: device.longitude,
+    latitude: device.latitude,
+    coordinate,
+}
+
+test('设备定位:走完整视角、打开设备详情并写揭示目标', async () => {
+    setActivePinia(createPinia())
+    const locator = usePointLocateStore()
+    const calls = { fly: [], openDevice: [] }
+    const result = await locator.locateTarget({ kind: 'map-object', code: 'DEV-131' }, {
+        objects: [device],
+        mapReady: true,
+        flyPoint: async (object, options) => { calls.fly.push({ object, options }); return true },
+        openDevice: async (code, options) => { calls.openDevice.push({ code, options }) },
+    })
+    assert.equal(result.result, 'ok')
+    assert.equal(calls.fly.length, 1)
+    assert.equal(calls.fly[0].object.code, 'DEV-131')
+    assert.deepEqual(calls.openDevice[0], { code: 'DEV-131', options: { locateTarget: { code: 'DEV-131', deviceCode: '' } } })
+})
+
+test('关联设备定位:先开宿主点位、再进设备级,揭示宿主点位', async () => {
+    setActivePinia(createPinia())
+    const locator = usePointLocateStore()
+    const calls = { openPoint: [], selectDevice: [] }
+    const result = await locator.locateTarget({ kind: 'map-object', code: 'DEV-131' }, {
+        objects: [point],
+        mapReady: true,
+        flyPoint: async () => true,
+        openPoint: async (code, options) => { calls.openPoint.push({ code, options }) },
+        selectDevice: async (code, options) => { calls.selectDevice.push({ code, options }) },
+    })
+    assert.equal(result.result, 'ok')
+    assert.deepEqual(calls.openPoint[0], { code: 'MP-131', options: undefined })
+    assert.deepEqual(calls.selectDevice[0], {
+        code: 'DEV-131',
+        options: { locateTarget: { code: 'MP-131', deviceCode: 'DEV-131' } },
+    })
+})
+
+test('事件回联:走完整视角飞行 + 高亮,不再只换中心', async () => {
+    setActivePinia(createPinia())
+    const locator = usePointLocateStore()
+    const calls = { fly: [], highlight: [] }
+    const event = { code: 'E-131', deviceCode: 'DEV-131', monitoringPointCode: null, coordinate: { validated: true, renderable: true } }
+    const result = await locator.locateTarget({ kind: 'event', event }, {
+        objects: [device],
+        mapReady: true,
+        flyPoint: async (object, options) => { calls.fly.push({ object, options }); return true },
+        highlight: (codes) => { calls.highlight.push(codes); return 1 },
+    })
+    assert.equal(result.result, 'ok')
+    assert.equal(calls.fly.length, 1)
+    assert.equal(calls.fly[0].object.code, 'DEV-131')
+    assert.ok(calls.highlight[0].includes('DEV-131'))
+})
+
+test('工单行保留设备编码,供工单卡定位按钮使用', () => {
+    const rows = workOrderRows([{ code: 'WO-131', deviceName: '测试设备', deviceCode: 'DEV-131', stateCode: 3 }])
+    assert.equal(rows[0].deviceCode, 'DEV-131')
+    assert.ok(rows[0].deviceLabel.includes('DEV-131'))
+})