Przeglądaj źródła

fix(cockpit): 揭示目标被清空时从定位状态兜底找回设备行

实测:locateTarget 完成后 detailStore.locateTarget 读到的是 null(被后续 close/回收链路清掉),
于是设备图层的 revealDevice 为空,独立设备补不出揭示行 —— 图标不出现、详情浮层也锚定不到。

syncDeviceLayer 增加兜底:detailStore.locateTarget 为空时,用 pointLocateStore.locate 里的
设备编码在地图摘要中找回那一行作为揭示目标。
ChenJZ 2 dni temu
rodzic
commit
c28a6c1155
1 zmienionych plików z 15 dodań i 1 usunięć
  1. 15 1
      src/modules/cockpit/CockpitShell.vue

+ 15 - 1
src/modules/cockpit/CockpitShell.vue

@@ -1392,6 +1392,16 @@ const deviceFilterActive = computed(
     () => industryQuery(industry.value) !== '' || districtQuery(scope.value) !== '' || String(deviceType.value || '').trim() !== '',
 )
 
+/** 定位状态兜底:detailStore 的揭示目标被清空时,用最近一次定位的编码在摘要里找回那一行。 */
+function revealFromLocateState() {
+    const state = pointLocateStore.locate
+    const deviceCode = (state && (state.deviceCode || state.code)) || ''
+    if (!deviceCode) return null
+    const device = (mapStore.summary.objects || []).find((item) => item && item.code === deviceCode) || null
+    if (!device) return null
+    return { code: deviceCode, deviceCode: state.deviceCode || '', device }
+}
+
 function syncDeviceLayer(options = {}) {
     // 票 46:`entered` 跟随引导态 —— 进入前关联设备图层整体不呈现(规格 18 的引导列)。
     // 票 45:重叠展开阈值来自 `map.overlap.maxFan`,未配置时用规格默认 10。
@@ -1410,7 +1420,11 @@ function syncDeviceLayer(options = {}) {
         maxFan,
         filterActive: deviceFilterActive.value,
         // #131:关联设备定位时把揭示目标(含设备自身坐标)交给设备图层,正常/离线也能临时上图。
-        revealDevice: detailStore.locateTarget,
+        //
+        // detailStore.locateTarget 会被后续的 close/回收链路清掉(实测定位完成后读已是 null),
+        // 一旦为空,设备图层就补不出揭示行 —— 图标与锚定全都失去依据。
+        // 所以这里再从定位状态本身兜底构造一次:定位已知设备编码时,用摘要里的那一行。
+        revealDevice: detailStore.locateTarget || revealFromLocateState(),
     })
 }