浏览代码

fix(cockpit): 去重报警审核结果并为工单状态加徽标

ChenJZ 1 天之前
父节点
当前提交
2064ad4d2a

+ 6 - 0
src/modules/cockpit/components/EntityDetailSections.vue

@@ -27,6 +27,10 @@
                         <div v-if="item.pairs" class="entity-sections__pairs">
                             <div v-for="(pair, index) in item.pairs" :key="index" class="entity-sections__pair"><span>{{ pair[0] }}</span><b>{{ pair[1] }}</b></div>
                         </div>
+                        <div v-else-if="item.orderState" class="entity-sections__order">
+                            <span class="entity-sections__order-code">{{ item.value }}</span>
+                            <b class="entity-sections__tag" :data-tone="item.tone">{{ item.orderState }}</b>
+                        </div>
                         <template v-else>
                             {{ item.value }}<button v-if="item.action" type="button" class="entity-sections__locate entity-sections__action" :data-action="item.action.kind" @click.stop="runAction(item.action)">{{ ACTION_TEXT[item.action.kind] || '查看' }}</button>
                         </template>
@@ -227,6 +231,8 @@ function openRelation(item) {
 .entity-sections__tag[data-tone='lv4'] { border-color: rgba(53, 219, 146, .6); background: rgba(53, 219, 146, .14); color: #b8f2d4; }
 .entity-sections__tag[data-tone='handled'] { border-color: rgba(169, 112, 255, .65); background: rgba(169, 112, 255, .16); color: #dcc9ff; }
 .entity-sections__tag[data-tone='neutral'] { border-color: rgba(86, 128, 176, .5); background: rgba(86, 128, 176, .12); color: #c4d5e8; }
+.entity-sections__order { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
+.entity-sections__order-code { color: var(--text); font-family: var(--num, monospace); overflow-wrap: anywhere; }
 
 /* 流程节点 */
 .entity-sections__stage { display: flex; margin: 0; padding: 4px 0 8px; list-style: none; }

+ 11 - 1
src/modules/cockpit/components/EquipmentDetailSections.vue

@@ -235,7 +235,10 @@
                         <dl class="equipment-section__detail" data-history-detail>
                             <div v-for="row in eventDetailRows(event)" :key="row.label" class="equipment-section__detail-row" :data-detail-row="row.label">
                                 <dt>{{ row.label }}</dt>
-                                <dd :data-tone="row.tone || undefined" :class="{ 'equipment-section__detail-value--tone': row.tone }">{{ row.value }}</dd>
+                                <dd :data-tone="row.tone || undefined" :class="{ 'equipment-section__detail-value--tone': row.tone }">
+                                    <template v-if="row.badge"><span class="equipment-section__order-code">{{ row.value }}</span><span class="equipment-section__order-state" :data-tone="row.tone">{{ row.badge }}</span></template>
+                                    <template v-else>{{ row.value }}</template>
+                                </dd>
                             </div>
                         </dl>
                     </details>
@@ -1345,6 +1348,13 @@ function isPlaceholder(text) {
     font-size: var(--fs-caption, 10.5px);
     overflow-wrap: anywhere;
 }
+.equipment-section__order-code { margin-right: calc(5 * var(--u, 1px)); font-family: var(--num, monospace); overflow-wrap: anywhere; }
+.equipment-section__order-state { display: inline-block; padding: 0 calc(6 * var(--u, 1px)); border: 1px solid rgba(1, 171, 234, .4); border-radius: 9px; background: rgba(1, 171, 234, .12); color: var(--cyan-hi); font-weight: 700; }
+.equipment-section__order-state[data-tone='lv1'] { border-color: rgba(255,59,82,.65); background: rgba(255,59,82,.14); color: #ffc2c9; }
+.equipment-section__order-state[data-tone='lv2'] { border-color: rgba(255,176,32,.65); background: rgba(255,176,32,.14); color: #ffdc91; }
+.equipment-section__order-state[data-tone='lv3'] { border-color: rgba(1,171,234,.65); background: rgba(1,171,234,.14); color: #b7e4ff; }
+.equipment-section__order-state[data-tone='lv4'] { border-color: rgba(53,219,146,.6); background: rgba(53,219,146,.14); color: #b8f2d4; }
+.equipment-section__order-state[data-tone='neutral'] { border-color: rgba(86,128,176,.5); background: rgba(86,128,176,.12); color: #c4d5e8; }
 
 .equipment-section__item-name {
     color: var(--text, #d7ecff);

+ 4 - 3
src/modules/cockpit/domain/entityDetail.js

@@ -927,9 +927,10 @@ function normalizeEvent(identity, source) {
         sections: compactSections([
             // 等级只出现在摘要卡片那一处(带色),这里不再重复一遍纯文字等级。
             // 状态在抬头与摘要卡各有一次,这里不再重复(否则事件编码被挤到换行)。
-            section('事件摘要', [field('事件编码', displayCode || '未提供', true), field('发生时间', formatEventTime(source.eventTime || source.createTime)), field('审核结果', audit ? audit.label : ''), field('关联工单', source.orderNo
-                ? `${source.orderNo} · ${orderState}`
-                : '')]),
+            section('事件摘要', [field('事件编码', displayCode || '未提供', true), field('发生时间', formatEventTime(source.eventTime || source.createTime)), field('关联工单', source.orderNo || '', true, {
+                orderState: source.orderNo ? orderState : '',
+                tone: source.orderNo ? workOrderTone(source.orderStatus) : '',
+            })]),
             section('监测读数', [
                 field('指标', eventTypeText(source.type || source.warningType || source.warningCode, source.typeName || source.warningTypeName)),
                 // 读数与阈值都带单位(维护者 2026-10-29:数值型指标必须有单位提示)。

+ 19 - 4
src/modules/cockpit/domain/equipmentDetailView.js

@@ -444,6 +444,7 @@ export function eventRows(data, workOrders = []) {
             auditStatusText: audit ? audit.label : '',
             workOrderCode: linkedOrder ? linkedOrder.code : '',
             workOrderStateName: linkedOrder ? linkedOrder.stateName : '',
+            workOrderStateCode: linkedOrder ? linkedOrder.stateCode : null,
             eventTime: event.eventTime || '',
             quantity: quantityText(event.value, event.unit),
             location: event.location || '',
@@ -667,12 +668,18 @@ function detailRow(label, value, keepEmpty = false, tone = '') {
 /** 一条预警/报警 → 展开后的详情行(时间、状态、来源、关联设备都在,缺值给占位符)。 */
 export function eventDetailRows(row) {
     const current = row || {}
+    const orderRow = current.workOrderCode
+        ? {
+            label: '关联工单',
+            value: current.workOrderCode,
+            badge: current.workOrderStateName || '状态未发布',
+            tone: workOrderStateTone(current.workOrderStateCode),
+        }
+        : null
     return detailRowList([
         detailRow(TIME_LABELS.event, formatEventTime(current.eventTime), true),
-        detailRow(current.family === 'ALARM' ? '审核结果' : '状态', current.status, true),
-        detailRow('关联工单', current.workOrderCode
-            ? `${current.workOrderCode} · ${current.workOrderStateName || '状态未发布'}`
-            : ''),
+        ...(current.family === 'ALARM' ? [] : [detailRow('状态', current.status, true)]),
+        orderRow,
         // 维护者 2026-11-13:原「来源」改为「预警描述 / 报警描述」,内容含简单描述与实际值、阈值。
         detailRow(current.family === 'ALARM' ? '报警描述' : '预警描述', current.descriptionText, true),
         detailRow('关联设备', current.deviceName || current.deviceCode, true),
@@ -732,6 +739,14 @@ function detailRowList(rows) {
     return rows.filter(Boolean)
 }
 
+/** 工单状态码 → 详情行的徽标色键(与管理端/工单列表同语义)。 */
+function workOrderStateTone(code) {
+    if (code === 5) return 'lv4'
+    if (code === 7) return 'lv1'
+    if (code === 6) return 'lv2'
+    return code === null || code === undefined || code === '' ? 'neutral' : 'lv3'
+}
+
 /** 聚合分区 → 设备编码(判定"已加载的这份是不是当前这台设备")。 */
 export function aggregateDeviceCode(aggregate) {
     const data = (aggregate && aggregate.data) || null

+ 1 - 2
src/modules/cockpit/domain/eventDetail.js

@@ -100,12 +100,11 @@ export function eventDetailView(event) {
         ...eventLocationView(current),
         monitoringPointCode: current.monitoringPointCode || '',
         monitoringPointName: current.monitoringPointName || '',
-        summary: [level.label, audit ? audit.label : statusOf(current) || PLACEHOLDER, orderText, valueText(current.value, current.unit)].filter(Boolean).join(' · '),
+        summary: [level.label, alarm ? '' : statusOf(current) || PLACEHOLDER, orderText, valueText(current.value, current.unit)].filter(Boolean).join(' · '),
         identityItems: [
             { label: '事件编码', value: current.codeText || '编码未提供', mono: true },
             { label: '设备', value: current.deviceName || current.deviceCode || PLACEHOLDER },
             { label: '监测点', value: current.monitoringPointName || current.monitoringPointCode || PLACEHOLDER },
-            ...(audit ? [{ label: '审核结果', value: audit.label }] : []),
             ...(orderText ? [{ label: '关联工单', value: orderText }] : []),
         ],
         readingItems: [