Prechádzať zdrojové kódy

fix(cockpit): 窨井补中心图标并支持用既有3D模型进入地下视图

ChenJZ 7 hodín pred
rodič
commit
220f494784

+ 35 - 10
src/modules/cockpit/CockpitShell.vue

@@ -592,7 +592,7 @@ import { selectMonitoringPoint } from './pointSelection.js'
 // 票 46:模式图层计划(唯一裁决点)+ 模式切换的选择态语义判定。
 import { planModeLayers, planModeSelectionTransition } from './domain/modeLayerPlan.js'
 import { PIPE_ENHANCEMENT_KIND, planPipeEnhancement } from './domain/pipeEnhancement.js'
-import { facilityUndergroundTarget } from './domain/facilityUnderground.js'
+import { facilityAsComponent, facilityUndergroundTarget } from './domain/facilityUnderground.js'
 // 票 48:图例计数纯函数(色值/词条/计数与地图管线同源的 domain 单源)。
 import { pipeColorCounts } from './domain/pipeVisual.js'
 import { usePipeEnhancementStore } from './stores/pipeEnhancementStore.js'
@@ -1230,6 +1230,33 @@ const modeLayerPlan = computed(() => planModeLayers({
     entered: !introVisible.value,
 }))
 
+/**
+ * 当前打开的设施在**地图标记行**里的那一行(含经纬度与类型)。
+ *
+ * 为什么要回查标记行:`entityDetailStore.detail` 只有详情字段,坐标在
+ * `facilityPointStore` 的标记行上。两者按「类别 + 主键」对上,不按编码猜。
+ */
+const currentFacilityRow = computed(() => {
+    if (!facilityDetailOpen.value) return null
+    const identity = entityDetailStore.identity || {}
+    const rows = facilityPointStore.points?.value ?? facilityPointStore.points ?? []
+    const category = String(identity.category || "").toUpperCase()
+    const id = String(identity.id || "")
+    const row = (Array.isArray(rows) ? rows : []).find((item) => item
+        && String(item.type || "").toUpperCase() === category
+        && String(item.id || "") === id)
+    return row || null
+})
+
+/** 当前设施转成的 3D 构件(只有窨井这类有模型的才非空)。 */
+const undergroundFacilityComponent = computed(() => facilityAsComponent(currentFacilityRow.value))
+
+/** 设施能否进「地下管线详情视图」:只看自身有没有可渲染的 3D 模型与坐标。 */
+const facilityUndergroundReady = computed(() => Boolean(
+    facilityDetailOpen.value && facilityUndergroundTarget(currentFacilityRow.value),
+))
+
+
 /**
  * 设备→设施真实关联索引(维护者 2026-10-22 批准的后端契约)。
  *
@@ -1254,7 +1281,12 @@ const pipeEnhancementPlan = computed(() => {
         selected: pipeEnhancementSelection.value,
         radiusM: pipeEnhancementRadius.value,
         visiblePipes: modeLayerPlan.value.pipelines,
-        visibleComponents: modeLayerPlan.value.facilities,
+        // 窨井(维护者 2026-11-16):设施自己有 3D 模型(井筒+井盖),
+        // 必须作为构件进入可见集合,否则 3D 视图里只有周边管线、没有它自己。
+        visibleComponents: [
+            ...modeLayerPlan.value.facilities,
+            ...(undergroundFacilityComponent.value ? [undergroundFacilityComponent.value] : []),
+        ],
     })
     return { ...plan, ...planEnhancementDevices(plan, enhancementDevicesStore.source.rows, {
         mode: mode.value, abnormalDevices: modeAbnormalDevices.value, facilityRelations: facilityRelations.value,
@@ -1302,17 +1334,10 @@ const pipeColorCountsView = computed(() => pipeColorCounts(pipeNetworkStore.laye
  * (窨井/排水设施用详情里的 networkId,管线用自身编码)。定位不到就不画按钮 ——
  * 画了就是「点了必然失败」的入口。
  */
-const facilityUndergroundReady = computed(() => Boolean(
-    facilityDetailOpen.value
-    && facilityUndergroundTarget(entityDetailStore.detail, pipeNetworkStore.pipelines?.value ?? pipeNetworkStore.pipelines ?? []),
-))
 
 /** 「查看详情」:选中关联管段,既有三维视图随之打开(不新建第二条渲染链)。 */
 function openFacilityUnderground() {
-    const target = facilityUndergroundTarget(
-        entityDetailStore.detail,
-        pipeNetworkStore.pipelines?.value ?? pipeNetworkStore.pipelines ?? [],
-    )
+    const target = facilityUndergroundTarget(currentFacilityRow.value)
     if (!target) return
     pipeEnhancementStore.select(target.kind, target.code)
 }

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 7 - 2
src/modules/cockpit/components/EntityDetailSections.vue


+ 17 - 9
src/modules/cockpit/components/FacilityDetailCard.vue

@@ -4,14 +4,6 @@
         <p v-if="locationReason" class="facility-detail__notice" data-facility-no-location>无地图位置 · {{ locationReason }}</p>
         <header class="facility-detail__head">
             <span class="facility-detail__title">{{ view.title }}</span>
-            <button
-                v-if="undergroundReady"
-                type="button"
-                class="facility-detail__action"
-                data-facility-detail-underground
-                title="进入地下管线详情视图查看该设施的三维位置"
-                @click="emit('open-underground')"
-            >查看详情</button>
             <button type="button" class="facility-detail__action" data-facility-detail-close @click="store.close()">关闭</button>
         </header>
         <div class="facility-detail__body">
@@ -27,7 +19,19 @@
                 设施详情未取到,已保留现有信息。
                 <button type="button" class="facility-detail__action" @click="store.retry()">重试</button>
             </p>
-            <EntityDetailSections :detail="store.detail" presentation="device" @locate-device="code => emit('locate-device', code)" />
+            <EntityDetailSections :detail="store.detail" presentation="device" @locate-device="code => emit('locate-device', code)">
+                <!-- 维护者 2026-11-16:「查看详情」放在「基本信息/业务信息/关联信息」TAB 行右侧。 -->
+                <template #tabs-action>
+                    <button
+                        v-if="undergroundReady"
+                        type="button"
+                        class="facility-detail__action facility-detail__tabs-action"
+                        data-facility-detail-underground
+                        title="进入地下管线详情视图查看该设施的三维位置"
+                        @click="emit('open-underground')"
+                    >查看详情</button>
+                </template>
+            </EntityDetailSections>
         </div>
     </section>
 </template>
@@ -73,7 +77,11 @@ const code = computed(() => store.detail?.displayCode || '未提供')
 .facility-detail__mono { font-family:var(--num,monospace); }
 .facility-detail__notice { margin:0 0 var(--space-2,8px); color:var(--muted); line-height:1.6; }
 .facility-detail__notice.is-error { color:var(--lv1); }
+.facility-detail__body :deep(.entity-sections__tabs) { display:flex; align-items:center; gap:var(--space-2,8px); }
 .facility-detail__body :deep(.entity-sections__tabs button) { font:inherit; font-size:var(--fs-caption); }
+/* 动作位推到最右(维护者 2026-11-16)。 */
+.facility-detail__tabs-action { margin-left:auto; }
+.facility-detail__body :deep(.entity-sections__tabs > .facility-detail__tabs-action) { margin-left:auto; }
 .facility-detail__body :deep(.entity-sections__grid) { display:grid; grid-template-columns:1fr; gap:calc(4 * var(--u,1px)); }
 .facility-detail__body :deep(.entity-sections__grid > div) { display:grid; grid-template-columns:calc(90 * var(--u,1px)) minmax(0,1fr); gap:calc(8 * var(--u,1px)); }
 .facility-detail__body :deep(.entity-sections__grid .is-wide) { grid-column:auto; }

+ 44 - 25
src/modules/cockpit/domain/facilityUnderground.js

@@ -2,40 +2,59 @@
  * 设施 → 「地下管线详情视图」的入口判据(维护者 2026-11-16)。
  *
  * 维护者原话:「需要点击设施点位时也能够查看详情,并在设施浮动面板中添加(查看详情)
- * 按钮进入 地下管线详情视图 来查看井盖在地下的 3D 模型(其他管线设施也一样)」。
+ * 按钮进入 地下管线详情视图 来查看井盖在地下的 3D 模型(其他管线设施也一样)」;
+ * 后续补充:「看窨井自身的 3D 模型和周边的其他管线 3D 模型。该方法也是已写好已有的旧方法,
+ * 只需调用实现即可(模型也是已有的通用窨井模型)」。
  *
- * 复用既有 `PipeEnhancement`(`PIPE_ENHANCEMENT_KIND` 只有 pipe / component 两类),
- * 不另造第二个 3D 视图。设施要通过它下钻,必须先能定位到**一条真实可见的管段**:
- *   · 管线本身(PIPE_NETWORK)用自身编码;
- *   · 其他设施用后端详情里的 `networkId`(窨井、排水工程设施都有这一列);
- *   · 定位不到(没关联 / 关联的管段不在当前可见管线里)就返回 null ——
- *     调用方据此**不画按钮**,而不是画一个点了必然失败的入口。
+ * 所以**不按关联管段下钻**(窨井是独立设施,`network_id` 可能悬空):
+ * 把设施自己转成一个 `component` 交给既有 3D 视图,
+ * `pipeEnhancement.componentView()` 凭 `industry==='MANHOLE'` 就会选中
+ * `threePipeEnhancement` 里那套井筒+井盖模型,周边管线由邻近半径自动带入。
  */
 
-/** 从设施详情里取关联管段主键:顶层与 `attributes` 都可能承载(两个端点字段位置不同)。 */
-function networkIdOf(facility) {
-    if (!facility) return ''
-    const attributes = facility.attributes && typeof facility.attributes === 'object' ? facility.attributes : {}
-    const raw = facility.networkId ?? attributes.networkId
-    return typeof raw === 'string' ? raw.trim() : ''
+/** 只有这些设施类型在「地下管线详情视图」里有自己的 3D 模型。 */
+const UNDERGROUND_FACILITY_TYPES = new Set(['MANHOLE'])
+
+function finite(value) {
+    return typeof value === 'number' && Number.isFinite(value)
 }
 
 /**
- * @param {object|null} facility 设施详情(`entityDetailStore.detail` 或其 `raw`)
- * @param {Array<{code:string}>} visiblePipes 当前可上图的管线
- * @returns {{kind:'pipe', code:string}|null} 可直接喂给 `pipeEnhancementStore.select()` 的目标
+ * 设施行 → 3D 视图可直接消费的构件形状(`visibleComponents` 的一项)。
+ *
+ * 形状对齐 `pipeEnhancement.componentView()` 的入参:`industry` 决定选哪套模型,
+ * `position` 是 `[经度, 纬度]`,`code` 作标识。缺坐标返回 `null`(3D 里无处安放)。
+ *
+ * @param {object|null} facility 设施点行(`facilityPointMarkers()` 的输出)
+ * @returns {object|null}
  */
-export function facilityUndergroundTarget(facility, visiblePipes) {
+export function facilityAsComponent(facility) {
     if (!facility) return null
-    const pipes = Array.isArray(visiblePipes) ? visiblePipes : []
-    const hasPipe = (code) => Boolean(code) && pipes.some((row) => row && row.code === code)
-
-    // 管线自己就是管段:设施编码即管段编码,不需要再关联一次。
+    const type = String(facility.type || facility.category || '').toUpperCase()
+    if (!UNDERGROUND_FACILITY_TYPES.has(type)) return null
+    if (!finite(facility.longitude) || !finite(facility.latitude)) return null
     const code = typeof facility.code === 'string' ? facility.code.trim() : ''
-    if (String(facility.category || '').toUpperCase() === 'PIPE_NETWORK' && hasPipe(code)) {
-        return { kind: 'pipe', code }
+    if (!code) return null
+    return {
+        kind: type,
+        code,
+        name: facility.name || code,
+        industry: type,
+        position: [facility.longitude, facility.latitude],
+        statusLabel: facility.statusLabel || '',
     }
+}
 
-    const networkId = networkIdOf(facility)
-    return hasPipe(networkId) ? { kind: 'pipe', code: networkId } : null
+/**
+ * 该设施能否进入「地下管线详情视图」。
+ *
+ * 判据只看**自身能不能在 3D 里立起来**(有类型、有坐标),不再要求关联管段 ——
+ * 窨井、水厂、泵站都是独立设施,`network_id` 是否悬空不该决定按钮出不出现。
+ *
+ * @param {object|null} facility 设施点行
+ * @returns {{kind:'component', code:string}|null}
+ */
+export function facilityUndergroundTarget(facility) {
+    const component = facilityAsComponent(facility)
+    return component ? { kind: 'component', code: component.code } : null
 }

+ 3 - 1
src/modules/cockpit/domain/markerPlan.js

@@ -65,6 +65,8 @@ const FACILITY_INNER_ICONS = {
     WATER_USER: 'facilityUser',
     PIPE_NETWORK: 'pipeSpecial',
     ENGINEERING_FACILITY: 'pipeSpecial',
+    // 窨井(维护者 2026-11-16):沿用构件链那枚窨井图标,图上不能只画一个没图案的水滴。
+    MANHOLE: 'manhole',
 }
 
 /** @param {string} facilityType 设施类型(WATER_PLANT/PUMP_STATION/WATER_SOURCE/WATER_USER) */
@@ -235,4 +237,4 @@ export function markerGeometryDataset(plan) {
         markerDrawWidth: plan.draw.width.toFixed(2),
         markerPad: plan.draw.pad.toFixed(2),
     }
-}
+}

Niektoré súbory nie sú zobrazené, pretože je v týchto rozdielových dátach zmenené mnoho súborov