فهرست منبع

fix(cockpit): 共享详情摘要两列与状态去重,修复长值横向溢出

ChenJZ 3 ساعت پیش
والد
کامیت
cf26ded99e

+ 2 - 1
src/modules/cockpit/components/EntityDetailDrawer.vue

@@ -163,7 +163,8 @@ const view = computed(() => entityDetailView(store.detail))
 
 .entity-drawer__body {
     min-height: 0;
-    overflow: auto;
+    overflow-y: auto;
+    overflow-x: hidden;
     padding-right: 2px;
 }
 

+ 9 - 4
src/modules/cockpit/components/EntityDetailSections.vue

@@ -145,11 +145,16 @@ function locateDevice(code) {
 </script>
 <style scoped>
 .entity-sections { display: grid; gap: 8px; min-width: 0; font-size: calc(12.5 * var(--u, 1px)); }
-.entity-sections__summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 6px; }
+/* 摘要卡固定两列:窄抽屉里不再挤成三列;落单的最后一张(总数为奇数)独占整行。 */
+.entity-sections__summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
+.entity-sections__summary > div:last-child:nth-child(odd) { grid-column: 1 / -1; }
+/* 网格子项允许收缩,长值才能折行而不是把容器撑出横向滚动。 */
+.entity-sections__summary > div,
+.entity-sections__grid > div { min-width: 0; }
 .entity-sections__summary > div,
 .entity-sections__group { padding: 9px 10px; border: 1px solid rgba(1, 171, 234, .18); border-left-width: 2px; border-left-color: rgba(1, 171, 234, .42); border-radius: 8px; background: linear-gradient(180deg, rgba(0, 35, 96, .32), rgba(0, 16, 52, .26)); }
 .entity-sections__summary span { display: block; color: var(--muted); font-size: calc(10.5 * var(--u, 1px)); letter-spacing: .04em; }
-.entity-sections__summary .entity-sections__value { display: block; margin-top: 2px; color: var(--text-strong, #eaf6ff); font-size: calc(13 * var(--u, 1px)); font-weight: 700; }
+.entity-sections__summary .entity-sections__value { display: block; margin-top: 2px; color: var(--text-strong, #eaf6ff); font-size: calc(13 * var(--u, 1px)); font-weight: 700; overflow-wrap: anywhere; }
 /* 关键修正:状态/等级徽标必须是 inline-block,不能被 .summary b 的块级规则拉满整行。 */
 .entity-sections__summary .entity-sections__tag { display: inline-block; margin-top: 3px; }
 
@@ -189,8 +194,8 @@ function locateDevice(code) {
 .entity-sections__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px 12px; margin: 0; }
 .entity-sections__grid .is-wide { grid-column: 1 / -1; }
 .entity-sections__grid dt { color: var(--muted); font-size: calc(10.5 * var(--u, 1px)); }
-.entity-sections dd { margin: 1px 0 0; color: var(--text); font-size: calc(12.5 * var(--u, 1px)); line-height: 1.45; overflow-wrap: break-word; }
-.entity-sections__grid .is-wide dd { overflow-wrap: anywhere; }
+/* 所有详情消费方共用:字段值在任意位置折行,长编码不会把容器撑出横向滚动。 */
+.entity-sections dd { margin: 1px 0 0; color: var(--text); font-size: calc(12.5 * var(--u, 1px)); line-height: 1.45; overflow-wrap: anywhere; }
 .entity-sections__note { display: block; margin-top: 1px; color: var(--muted); font-size: calc(10 * var(--u, 1px)); }
 
 /* 相关人员:按处置顺序横向排列,箭头表达先后关系。 */

+ 4 - 0
src/modules/cockpit/components/PipeEnhancement.vue

@@ -69,6 +69,9 @@
                 </div>
                 <div v-show="sideTab === 'detail'" class="pipe-enhancement__asset-pane" data-side-panel="detail">
                     <AssetDetailPanel :context="assetContext">
+                        <template v-if="assetKind === 'facility' && assetFacility?.detail" #actions>
+                            <StatusTag :tone="assetFacility.detail.tone" :label="assetFacility.detail.statusText || '状态未发布'" data-asset-facility-status />
+                        </template>
                         <template v-if="assetKind === 'device'">
                             <div class="pipe-enhancement__device-status-card" data-enhancement-device-status-card>
                                 <DeviceStateTags data-enhancement-device-status :device-code="deviceState.selected.code"
@@ -114,6 +117,7 @@ import EquipmentDetailSections from './EquipmentDetailSections.vue'
 import EntityDetailSections from './EntityDetailSections.vue'
 import DeviceStateTags from './DeviceStateTags.vue'
 import AssetDetailPanel from './AssetDetailPanel.vue'
+import StatusTag from './StatusTag.vue'
 import { ASSET_KIND } from '../domain/assetDetail.js'
 import { resolveAssetKind } from '../domain/assetDetailKind.js'
 

+ 8 - 7
src/modules/cockpit/domain/entityDetail.js

@@ -137,6 +137,7 @@ function normalizeAsset(identity, source) {
     const location = text(source.address || source.location || source.position)
     const fields = assetFields(category, attributes)
     const kindLabel = emergency ? '应急对象' : '设施'
+    const noun = emergency ? '对象' : '设施'
     return {
         ...identity, category, name, title: name, displayCode,
         kindLabel,
@@ -145,16 +146,15 @@ function normalizeAsset(identity, source) {
         statusText: status, tone: emergency ? 'neutral' : facilityStatusTone(source.status), raw: source,
         categoryText: facilityCategoryText(category),
         coordinates: source.coordinates || null,
-        summary: assetSummary(category, attributes, status, location),
+        summary: assetSummary(category, attributes, location),
         tabs: [tab('overview', '基本信息'), tab('business', '业务详情'), tab('related', '关联信息')],
         people: assetPeople(attributes),
         devices: assetDevices(attributes),
         attachments: assetAttachments(attributes),
         sections: compactSections([
             section('基本信息', [
-                ...(hasCodeColumn ? [field('设施编码', displayCode || '未提供')] : []),
-                field('设施类别', facilityCategoryText(category)),
-                field('运行状态', status),
+                ...(hasCodeColumn ? [field(`${noun}编码`, displayCode || '未提供', true)] : []),
+                field(`${noun}类别`, facilityCategoryText(category)),
                 field('数据更新时间', formatEventTime(source.updatedAt)),
             ]),
             section('位置与归属', [field('位置描述', location, true), field('所属片区', source.districtName), field('坐标', coordinatesText(source.coordinates), true)]),
@@ -261,7 +261,7 @@ const SUMMARY_LABELS_BY_CATEGORY = {
     WATER_FIRE_HYDRANT: { ownershipUnit: '产权单位' },
 }
 
-function assetSummary(category, a, status, location) {
+function assetSummary(category, attributes, location) {
     // 摘要只挑"一眼要看的读数",键与明细同源;单位统一由 METRIC_UNITS 提供。
     const byCategory = {
         WATER_PLANT: ['currentCapacity', 'designCapacity', 'treatmentProcess'],
@@ -281,12 +281,13 @@ function assetSummary(category, a, status, location) {
     const labels = { ...SUMMARY_LABELS, ...SUMMARY_LABELS_BY_CATEGORY[category] }
     const rows = (byCategory[category] || []).map((key) => {
         const unit = unitOf(category, key)
-        const raw = assetFieldValue(key, a)
+        const raw = assetFieldValue(key, attributes)
         // 只有真有单位时才拼单位;纯文本字段(材质/负责人…)原样。
         const value = unit ? withUnitText(raw, unit) : raw
         return [labels[key] || SUMMARY_LABELS[key] || key, value]
     })
-    return summaryItems([['状态', status], ...rows, ['位置', location]])
+    // 状态只在抬头徽标出现;摘要卡不再重复(与预警详情同一口径)。
+    return summaryItems([...rows, ['位置', location]])
 }
 function assetPeople(a) { return peopleItems([['负责人', a.principal], ['维护人', a.maintainer], ['整改人', a.rectifyPerson], ['联系电话', a.contactPhone || a.maintainerPhone]]) }
 function assetAttachments(a) { return attachmentItems(a.images || a.image) }

+ 41 - 0
tests/entityDetailAssetFields.test.js

@@ -34,6 +34,21 @@ function businessFields(view) {
     return view.sections.find((group) => group.title === '业务详情').fields
 }
 
+test('资产摘要不再有「状态」卡、基本信息不再有「运行状态」行;抬头状态仍在', () => {
+    const view = assetView({
+        category: 'HAZARD',
+        id: 'h1',
+        code: 'YH-1',
+        name: '322322',
+        status: '待核查',
+        attributes: { reportTime: '2026-11-13T17:57:10' },
+    })
+    assert.equal(view.status, '待核查')
+    assert.equal(view.summary.some((item) => item.label === '状态'), false)
+    const basic = view.sections.find((group) => group.title === '基本信息')
+    assert.equal(basic.fields.some((item) => item.label === '运行状态'), false)
+})
+
 test('防护目标没有业务编码列:不生成编码字段,抬头不拼接「编码未提供」', () => {
     const view = assetView({
         category: 'PROTECTION_TARGET',
@@ -48,6 +63,32 @@ test('防护目标没有业务编码列:不生成编码字段,抬头不拼
     assert.equal(basic.fields.some((item) => item.label === '设施编码'), false)
 })
 
+test('应急对象基本信息用「对象编码/对象类别」,编码整行;设施编码同样整行', () => {
+    const resource = assetView({
+        category: 'EMERGENCY_RESOURCE',
+        id: 'e1',
+        code: '41010500002000000004/34020000001310000007',
+        name: '过道1',
+        attributes: { installTime: '2026-10-26T00:00:00' },
+    })
+    const basic = resource.sections.find((group) => group.title === '基本信息')
+    assert.equal(basic.fields.some((item) => item.label === '设施编码' || item.label === '设施类别'), false)
+    const code = basic.fields.find((item) => item.label === '对象编码')
+    assert.equal(code.value, '41010500002000000004/34020000001310000007')
+    assert.equal(code.wide, true)
+    assert.equal(basic.fields.find((item) => item.label === '对象类别').value, '应急资源')
+
+    const pipe = assetView({
+        category: 'PIPE_NETWORK',
+        id: 'p1',
+        code: 'GD-41010500002000000004',
+        name: '测试管线',
+        attributes: { buildDate: '2020-05-01' },
+    })
+    const pipeBasic = pipe.sections.find((group) => group.title === '基本信息')
+    assert.equal(pipeBasic.fields.find((item) => item.label === '设施编码').wide, true)
+})
+
 test('时间戳统一为 yyyy-MM-dd HH:mm:ss:评估时间、数据更新时间(摘要与明细同源)', () => {
     const view = assetView({
         category: 'PROTECTION_TARGET',