Преглед изворни кода

fix(cockpit): 独立设备定位补上揭示来源,设备图层按业务编码也认揭示目标

- 独立设备没有宿主点位,此前揭示目标里既没有 deviceCode 也没有设备行,设备图层无处可画 ——
  表现就是「定位成功但图标丢了」。现在把对象自身作为揭示来源(device 行)交给设备图层。
- 设备图层的揭示判据从「只认 deviceCode」改为「认 code 或 deviceCode」:独立设备的 deviceCode 本来就是空的,
  只认 deviceCode 会让这类目标永远补不上图层;排除项兜底到设备行/入口编码。
- reveal 的 deviceCode 仍保持空(modeLayerPlan 靠它区分「关联设备」与「独立设备」),测试同步断言设备行。
ChenJZ пре 1 дан
родитељ
комит
f3a1a618e0

+ 5 - 2
src/modules/cockpit/stores/deviceLayerStore.js

@@ -294,12 +294,15 @@ export const useDeviceLayerStore = defineStore('deviceLayerStore', () => {
 
         pointCode.value = code
         // #131:关联设备定位时,即使它当前状态(NORMAL)/模式本应隐藏,也临时补一条可上图行。
-        const reveal = options.revealDevice && options.revealDevice.deviceCode ? options.revealDevice : null
+        // 揭示判据认 code 也认 deviceCode:独立设备定位时 deviceCode 是空的(它靠 code 揭示),
+        // 只认 deviceCode 会让这类目标永远补不上图层。
+        const reveal = options.revealDevice && (options.revealDevice.code || options.revealDevice.deviceCode) ? options.revealDevice : null
         let layerRows = withAssets
         if (reveal) {
             const forced = reveal.device ? revealRow(reveal.device, reveal.code) : null
             if (forced) {
-                layerRows = [...layerRows.filter((row) => row.code !== reveal.deviceCode), forced]
+                const exclude = reveal.deviceCode || (reveal.device && reveal.device.code) || reveal.code || ''
+                layerRows = [...layerRows.filter((row) => row.code !== exclude), forced]
             } else {
                 layerRows = layerRows.map((row) => (row.code === reveal.deviceCode && row.placement !== DEVICE_PLACEMENT.DRAWN
                     ? {

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

@@ -133,6 +133,10 @@ export const usePointLocateStore = defineStore('pointLocateStore', () => {
             if (device && !device.industry) device = { ...device, industry: pointIndustry }
         }
 
+        // 独立设备没有宿主点位:对象自身就是设备,把它作为揭示来源交给设备图层,
+        // 否则揭示目标里没有设备行,图层无处可画(表现就是「定位成功但图标丢了」)。
+        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' } : {}),

+ 6 - 1
tests/point-locate.test.js

@@ -46,7 +46,12 @@ test('设备定位:走完整视角、打开设备详情并写揭示目标', as
     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: '' } } })
+    // 独立设备:detail 仍然按设备编码打开;揭示目标带上设备行本身(deviceCode 保持空,
+    // 由 modeLayerPlan 区分「关联设备」与「独立设备」,设备图层用 code + device 行揭示)。
+    assert.equal(calls.openDevice[0].code, 'DEV-131')
+    assert.equal(calls.openDevice[0].options.locateTarget.code, 'DEV-131')
+    assert.equal(calls.openDevice[0].options.locateTarget.deviceCode, '')
+    assert.equal(calls.openDevice[0].options.locateTarget.device.code, 'DEV-131')
 })
 
 test('关联设备定位:越过宿主点位飞到设备自身坐标,再进设备级', async () => {