Ver Fonte

fix(cockpit): 窨井业务详情补字段并修正资产详情归属判据

ChenJZ há 7 horas atrás
pai
commit
ee408e6372

+ 4 - 2
src/modules/cockpit/CockpitShell.vue

@@ -593,6 +593,7 @@ import { selectMonitoringPoint } from './pointSelection.js'
 import { planModeLayers, planModeSelectionTransition } from './domain/modeLayerPlan.js'
 import { PIPE_ENHANCEMENT_KIND, planPipeEnhancement } from './domain/pipeEnhancement.js'
 import { facilityAsComponent, facilityUndergroundTarget } from './domain/facilityUnderground.js'
+import { facilityBelongsToObject } from './domain/assetDetailKind.js'
 // 票 48:图例计数纯函数(色值/词条/计数与地图管线同源的 domain 单源)。
 import { pipeColorCounts } from './domain/pipeVisual.js'
 import { usePipeEnhancementStore } from './stores/pipeEnhancementStore.js'
@@ -679,8 +680,9 @@ const enhancementFacilityState = computed(() => {
     const identity = entityDetailStore.identity
     const object = pipeEnhancementPlan.value?.object
     if (!identity || identity.kind !== 'facility' || !object) return { detail: null, loading: false, error: false }
-    const belongs = String(identity.id) === String(object.code || object.sourceId || '')
-    if (!belongs) return { detail: null, loading: false, error: false }
+    // 归属判据见 domain/assetDetailKind.js:设施 identity.id 是 UUID,
+    // 3D 对象的 code 是设施编码,只比 code 会永不相等(窨井设施详情因此恒为 null)。
+    if (!facilityBelongsToObject(identity, object)) return { detail: null, loading: false, error: false }
     return {
         detail: entityDetailStore.detail,
         loading: entityDetailStore.loading === true,

+ 8 - 5
src/modules/cockpit/components/PipeEnhancement.vue

@@ -115,6 +115,7 @@ import EntityDetailSections from './EntityDetailSections.vue'
 import DeviceStateTags from './DeviceStateTags.vue'
 import AssetDetailPanel from './AssetDetailPanel.vue'
 import { ASSET_KIND } from '../domain/assetDetail.js'
+import { resolveAssetKind } from '../domain/assetDetailKind.js'
 
 const props = defineProps({
     plan: { type: Object, required: true },
@@ -145,10 +146,13 @@ const assetContext = computed(() => ({
     } : null,
 }))
 const assetKind = computed(() => {
-    // 设备优先级高于设施:两者同时存在时以最近一次选择的设备为准(device 选择会清掉设施详情)。
-    if (props.deviceState?.selected?.code) return ASSET_KIND.DEVICE
-    if (assetFacility.value?.detail) return ASSET_KIND.FACILITY
-    return ''
+    // 设施详情优先(维护者 2026-11-16):用户是在这里主动选了窨井才进来的,
+    // 上一次残留的设备选择不该继续霸占「资产详情」。判据收在 domain/assetDetailKind.js。
+    const kind = resolveAssetKind({
+        deviceCode: props.deviceState?.selected?.code || '',
+        facilityDetail: assetFacility.value?.detail || null,
+    })
+    return kind === 'facility' ? ASSET_KIND.FACILITY : kind === 'device' ? ASSET_KIND.DEVICE : ''
 })
 // 有资产被选中就切到详情页;全部取消则退回列表页,避免停在空白详情。
 watch(assetKind, (kind) => { sideTab.value = kind ? 'detail' : 'nearby' }, { immediate: true })
@@ -316,4 +320,3 @@ onBeforeUnmount(() => {
 .pipe-enhancement__facts dd { margin: 2px 0 0; overflow-wrap: anywhere; }
 .pipe-enhancement__note { margin: 0; color: #a7c4d9; font-size: 12px; line-height: 1.45; }
 </style>
-

+ 39 - 0
src/modules/cockpit/domain/assetDetailKind.js

@@ -0,0 +1,39 @@
+/**
+ * 3D 视图「资产详情」的归属判据(维护者 2026-11-16)。
+ *
+ * 维护者原话:「『地下管线详情视图』中,右侧的『资产详情』TAB 只能够显示设备详情,
+ * 无法显示设施详情…需要使资产详情根据当前选中的设备或设施来显示对应的详情信息,
+ * 例如选中管道就显示管道详情,选择窨井(设备)就显示窨井设备详情,
+ * 选中窨井(设施)就显示窨井设施详情。」
+ *
+ * 旧实现的判据是 `identity.id === object.code`:
+ * 窨井设施的 identity.id 是 **UUID**(b410acff…),而 3D 对象的 code 是
+ * **设施编码**(YL-YJ-003),两者永不相等 → 设施详情恒为 null → 永远显示设备分支。
+ *
+ * 正确判据:设施详情要归属到它自己的 3D 对象,可以按**编码**或**主键**任一相等;
+ * 且明确的设施选择必须让位给设施详情(不能被上一次的设备选择压住)。
+ */
+
+/** 设施 identity 与 3D 对象是否同一个设施。 */
+export function facilityBelongsToObject(identity, object) {
+    if (!identity || !object) return false
+    if (String(identity.kind || '') !== 'facility') return false
+    const byId = String(identity.id || '')
+    const candidates = [object.code, object.sourceId, object.id].map((v) => String(v || '')).filter(Boolean)
+    return Boolean(byId) && candidates.includes(byId)
+}
+
+/**
+ * 资产详情当前该显示哪一类。
+ *
+ * 与旧实现的差别:**设施优先**。用户是在 3D 视图里主动选了某个设施(窨井)才进来的,
+ * 此时上一次残留的设备选择不该继续霸占详情位;两者都不成立才算没有资产。
+ *
+ * @param {{deviceCode?: string, facilityDetail?: object|null}} input
+ * @returns {'device'|'facility'|''}
+ */
+export function resolveAssetKind({ deviceCode = '', facilityDetail = null } = {}) {
+    if (facilityDetail) return 'facility'
+    if (deviceCode) return 'device'
+    return ''
+}

+ 11 - 0
src/modules/cockpit/domain/entityDetail.js

@@ -272,6 +272,8 @@ const NETWORK_TYPE_TEXT = { '0': '燃气管网', '1': '排水管网', '2': '供
 const NETWORK_LEVEL_TEXT = { '0': '污水', '1': '雨水' }
 /** 排水工程设施类型(0 闸门 / 1 调蓄设施 / 2 泵站):同样是码值,一并直译。 */
 const ENGINEERING_FACILITY_TYPE_TEXT = { '0': '闸门', '1': '调蓄设施', '2': '泵站' }
+/** 窨井井形(manhole_shape):码值直译,认不出回原码(与上面几条同一纪律)。 */
+const MANHOLE_SHAPE_TEXT = { '0': '圆形', '1': '方形', '2': '矩形' }
 /** 泵站表供水/排水共用(后端 PumpStationType:water_supply / drainage),码值直译;认不出回原码。 */
 const PUMP_STATION_TYPE_TEXT = { water_supply: '供水泵站', drainage: '排水泵站' }
 /** 类别中文名:界面上用「中文 + 英文码」,只印英文等于把接口词汇漏上大屏。 */
@@ -343,6 +345,15 @@ function pipesFields(a) {
 
 const ASSET_FIELD_ROWS = {
     PIPE_NETWORK: null, // 见 pipesFields():需要按管网类型决定二级分类是否适用
+    // 窨井(维护者 2026-11-16):字段与 manhole_base 的列一一对应,不展示不存在的语义。
+    MANHOLE: [
+        { label: '井深', key: 'manholeDepth' },
+        { label: '井形', key: 'manholeShape', format: (v) => codedText(v, MANHOLE_SHAPE_TEXT) },
+        { label: '材质', key: 'material' },
+        { label: '权属单位', key: 'ownershipUnit' },
+        { label: '关联管网', key: 'networkId', format: (v) => (typeof v === 'string' && v.trim() ? v.trim() : '未关联') },
+        { label: '备注', key: 'remark', wide: true },
+    ],
     WATER_PLANT: [
         { label: '水源类型', key: 'waterSourceType' },
         { label: '设计能力', key: 'designCapacity' },