|
|
@@ -117,6 +117,7 @@ export function entityDetailView(detail) {
|
|
|
sections: Array.isArray(current.sections) ? current.sections : [],
|
|
|
people: Array.isArray(current.people) ? current.people : [],
|
|
|
devices: Array.isArray(current.devices) ? current.devices : [],
|
|
|
+ relations: Array.isArray(current.relations) ? current.relations : [],
|
|
|
sectionMap: current.sectionMap && typeof current.sectionMap === 'object' ? current.sectionMap : {},
|
|
|
attachments: Array.isArray(current.attachments) ? current.attachments : [],
|
|
|
maintenanceImages: Array.isArray(current.maintenanceImages) ? current.maintenanceImages : [],
|
|
|
@@ -746,6 +747,7 @@ function normalizeEvent(identity, source) {
|
|
|
// 报警族的处置记录/附件在不同后端版本字段不一,这里做兼容收集(预警族字段不变)。
|
|
|
const auditRecords = collectAuditRecords(source)
|
|
|
const attachments = collectAttachmentItems(source)
|
|
|
+ const relations = eventRelations(family, source)
|
|
|
return {
|
|
|
...identity,
|
|
|
name,
|
|
|
@@ -759,16 +761,19 @@ function normalizeEvent(identity, source) {
|
|
|
levelLabel: level.label,
|
|
|
levelTone: level.tone,
|
|
|
raw: source,
|
|
|
- // 等级带语义色(与卡片同一张词表),是摘要里唯一的等级呈现位置。
|
|
|
- // 状态只在抬头徽标展示;摘要卡不再重复(等级 / 当前值 / 发生时间)。
|
|
|
- summary: summaryItems([['等级', level.label, level.tone], ['当前值', withUnit(source.value ?? source.actualValue, source.unit || source.warningUnit)], ['发生时间', formatEventTime(source.eventTime || source.createTime)]]),
|
|
|
+ // 等级已移到状态徽标右侧;摘要卡不再重复(保留当前值 / 发生时间)。
|
|
|
+ summary: summaryItems([['当前值', withUnit(source.value ?? source.actualValue, source.unit || source.warningUnit)], ['发生时间', formatEventTime(source.eventTime || source.createTime)]]),
|
|
|
tabs: family === 'WARNING'
|
|
|
- ? [tab('overview', '预警信息'), tab('records', '处置记录'), tab('alarms', '关联报警'), tab('attachments', '附件')]
|
|
|
- : [tab('overview', '报警信息'), tab('devices', '设备信息'), tab('records', '处置记录'), tab('attachments', '附件')],
|
|
|
+ ? [tab('overview', '预警信息'), tab('records', '处置记录'), tab('relations', '关联信息'), tab('attachments', '附件')]
|
|
|
+ : [tab('overview', '报警信息'), tab('relations', '关联信息'), tab('records', '处置记录'), tab('attachments', '附件')],
|
|
|
relatedAlarms: Array.isArray(source.alarmList) ? source.alarmList.map(relatedAlarm) : [],
|
|
|
stage: eventStage(family, rawStatus, auditRecords),
|
|
|
- people: peopleItems([['发布人', source.publisherName], ['处置人', source.handlerName], ['核验人', source.reviewerName]]),
|
|
|
+ // 报警的「相关人员」即使后端暂未回填姓名也要有指标位;预警沿用原口径。
|
|
|
+ people: family === 'ALARM'
|
|
|
+ ? alarmPeople(source, auditRecords)
|
|
|
+ : peopleItems([['发布人', source.publisherName], ['处置人', source.handlerName], ['核验人', source.reviewerName]]),
|
|
|
devices: deviceItems(source),
|
|
|
+ relations,
|
|
|
attachments,
|
|
|
records: recordItems(auditRecords),
|
|
|
sections: compactSections([
|
|
|
@@ -782,14 +787,6 @@ function normalizeEvent(identity, source) {
|
|
|
field('阈值', threshold(source)),
|
|
|
field('超出幅度', withUnit(source.deviationRatio, '%')),
|
|
|
]),
|
|
|
- section('关联信息', [
|
|
|
- field('设备名称', source.deviceName),
|
|
|
- field('监测点', source.monitoringPointName || source.monitoringPointCode),
|
|
|
- // 设备编码单独整行:长编码不换行、也不截断成省略号。
|
|
|
- field('设备编码', source.deviceCode || source.monitoringPointCode, true),
|
|
|
- field('工单', source.workOrderCode || source.orderNo),
|
|
|
- field('位置', source.location || source.address || locationText(source.gisLocation), true),
|
|
|
- ]),
|
|
|
section('处置与附件', [
|
|
|
field('处置记录', listCount(auditRecords, '条')),
|
|
|
field('关联报警', listCount(source.alarmList, '条')),
|
|
|
@@ -800,6 +797,99 @@ function normalizeEvent(identity, source) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+function alarmPeople(source, records) {
|
|
|
+ const latest = latestOperator(records)
|
|
|
+ const handler = text(source.receiveUserName || source.handlerName || source.receiverName || latest)
|
|
|
+ const verifier = text(source.verifyUserName || source.reviewerName)
|
|
|
+ return [
|
|
|
+ { role: '处置人', name: handler || '未提供' },
|
|
|
+ { role: '核验人', name: verifier || '未提供' },
|
|
|
+ ]
|
|
|
+}
|
|
|
+
|
|
|
+function latestOperator(records) {
|
|
|
+ const list = Array.isArray(records) ? records : records ? [records] : []
|
|
|
+ const hit = list.find((item) => item && text(item.operatorName || item.operator))
|
|
|
+ return hit ? text(hit.operatorName || hit.operator) : ''
|
|
|
+}
|
|
|
+
|
|
|
+/** 关联信息:只列当前数据真实带出的设备 / 预警 / 报警 / 工单,不猜不补。 */
|
|
|
+function eventRelations(family, source) {
|
|
|
+ const list = []
|
|
|
+ const device = deviceRelation(source)
|
|
|
+ if (device) list.push(device)
|
|
|
+ if (family === 'WARNING' && Array.isArray(source.alarmList)) {
|
|
|
+ source.alarmList.map(relatedAlarm).forEach((item) => {
|
|
|
+ const relation = alarmRelation(item)
|
|
|
+ if (relation) list.push(relation)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (family === 'ALARM') {
|
|
|
+ const warning = warningRelation(source)
|
|
|
+ if (warning) list.push(warning)
|
|
|
+ }
|
|
|
+ const workOrder = workOrderRelation(source)
|
|
|
+ if (workOrder) list.push(workOrder)
|
|
|
+ return list
|
|
|
+}
|
|
|
+
|
|
|
+function deviceRelation(source) {
|
|
|
+ const name = text(source.deviceName || source.monitoringPointName)
|
|
|
+ const code = text(source.deviceCode || source.monitoringPointCode)
|
|
|
+ if (!name && !code) return null
|
|
|
+ return {
|
|
|
+ kind: 'device',
|
|
|
+ kindLabel: '设备',
|
|
|
+ code,
|
|
|
+ name: name || code,
|
|
|
+ status: '',
|
|
|
+ meta: [text(source.deviceTypeName), text(source.deviceLocation || source.location || source.address)].filter(Boolean).join(' · '),
|
|
|
+ locateCode: code,
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function alarmRelation(item) {
|
|
|
+ const code = text(item && (item.code || item.alarmNo))
|
|
|
+ const name = text(item && (item.name || item.alarmContent || item.alarmName))
|
|
|
+ if (!code && !name) return null
|
|
|
+ return {
|
|
|
+ kind: 'alarm',
|
|
|
+ kindLabel: '报警',
|
|
|
+ code,
|
|
|
+ name: name || code,
|
|
|
+ status: text(item && (item.status || item.alarmStatusName)) || '',
|
|
|
+ meta: '',
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function warningRelation(source) {
|
|
|
+ const code = text(source.warningNo || source.warningId || source.warningCode)
|
|
|
+ const name = text(source.warningName || source.warningTypeName || source.warningContent)
|
|
|
+ if (!code && !name) return null
|
|
|
+ return {
|
|
|
+ kind: 'warning',
|
|
|
+ kindLabel: '预警',
|
|
|
+ code,
|
|
|
+ name: name || code,
|
|
|
+ status: eventStatusText(source.warningStatus || source.status, 'WARNING'),
|
|
|
+ meta: '',
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function workOrderRelation(source) {
|
|
|
+ const code = text(source.orderNo || source.workOrderCode || source.workOrderNo)
|
|
|
+ const name = text(source.orderDesc || source.workOrderDesc || source.orderTitle)
|
|
|
+ if (!code && !name) return null
|
|
|
+ return {
|
|
|
+ kind: 'work-order',
|
|
|
+ kindLabel: '工单',
|
|
|
+ code,
|
|
|
+ name: name || code,
|
|
|
+ status: text(source.orderStatusName || source.workOrderStateName),
|
|
|
+ meta: '',
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
function normalizeWorkOrder(identity, source) {
|
|
|
const detailSource = source && source.order ? source : { order: source, logs: source.logs || [] }
|
|
|
const raw = { ...(detailSource.order || {}) }
|
|
|
@@ -821,6 +911,19 @@ function normalizeWorkOrder(identity, source) {
|
|
|
track = trackOf(toWorkOrderTimeline(source))
|
|
|
}
|
|
|
const stateText = order.stateName || workOrderStateName(order.stateCode)
|
|
|
+ const relations = []
|
|
|
+ const device = deviceRelation(order)
|
|
|
+ if (device) relations.push(device)
|
|
|
+ if (order.code) {
|
|
|
+ relations.push({
|
|
|
+ kind: 'work-order',
|
|
|
+ kindLabel: '工单',
|
|
|
+ code: order.code,
|
|
|
+ name: order.description || order.code,
|
|
|
+ status: stateText,
|
|
|
+ meta: order.orderLevel === null ? '' : `优先级 ${orderLevelText(order.orderLevel)}`,
|
|
|
+ })
|
|
|
+ }
|
|
|
return {
|
|
|
...identity,
|
|
|
name: order.description || order.code || '工单名称未提供',
|
|
|
@@ -829,17 +932,21 @@ function normalizeWorkOrder(identity, source) {
|
|
|
kindLabel: '工单',
|
|
|
statusText: stateText,
|
|
|
tone: workOrderTone(order.stateCode),
|
|
|
+ // 优先级作为等级徽标放在状态右侧,与报警/预警的等级徽标同一位置。
|
|
|
+ levelLabel: order.orderLevel === null ? '' : `优先级 ${orderLevelText(order.orderLevel)}`,
|
|
|
+ levelTone: orderLevelTone(order.orderLevel),
|
|
|
order,
|
|
|
track,
|
|
|
raw: source,
|
|
|
- // 抬头已有状态徽标;顶部指标卡不再重复工单号/状态/优先级(维护者 2026-12-01)。
|
|
|
+ // 抬头已有状态/优先级徽标;顶部指标卡不再重复工单号或优先级(维护者 2026-12-01)。
|
|
|
summary: [],
|
|
|
- tabs: [tab('overview', '工单信息'), tab('flow', '处理流程'), tab('devices', '设备信息'), tab('attachments', '附件')],
|
|
|
+ tabs: [tab('overview', '工单信息'), tab('flow', '处理流程'), tab('relations', '关联信息'), tab('attachments', '附件')],
|
|
|
stage: workOrderStage(order.stateCode),
|
|
|
// 相关人员与「处置内容」里的处置人/核验人重复;工单详情不再单独出这一栏。
|
|
|
people: [],
|
|
|
- // 设备信息统一放「设备信息」页签,概览不再重复一份。
|
|
|
+ // 设备信息统一在「关联信息」页签,概览不再重复一份。
|
|
|
devices: order.deviceCode || order.deviceName ? [{ name: order.deviceName || order.deviceCode, code: order.deviceCode, type: order.deviceTypeName, location: order.deviceLocation }] : [],
|
|
|
+ relations,
|
|
|
// 附件页签保留完整清单;处理流程页签另外按维修前/后分组展示。
|
|
|
attachments: attachmentItems([
|
|
|
...order.maintenanceBeforeImages,
|
|
|
@@ -852,8 +959,8 @@ function normalizeWorkOrder(identity, source) {
|
|
|
].filter((group) => group.images.length),
|
|
|
records: recordItems(timelineRaw),
|
|
|
sections: compactSections([
|
|
|
- // 只保留工单号与优先级;状态只由左上角徽标展示。
|
|
|
- section('工单摘要', [field('工单号', order.code || '未提供'), field('优先级', orderLevelText(order.orderLevel))]),
|
|
|
+ // 工单号在摘要;状态和优先级只由左上角徽标展示。
|
|
|
+ section('工单摘要', [field('工单号', order.code || '未提供')]),
|
|
|
// 与设备详情同口径:ISO 带时区串统一 yyyy-MM-dd HH:mm:ss(维护者 2026-11-23)。
|
|
|
section('时间信息', [field('创建时间', formatEventTime(order.createTime)), field('计划完成', formatEventTime(order.planFinishTime)), field('实际完成', formatEventTime(order.realFinishTime))]),
|
|
|
section('处置内容', [field('处置人', order.receiveUserName), field('核验人', order.verifyUserName), field('故障描述', order.description, true), field('处置结果', order.repairResult, true)]),
|
|
|
@@ -869,6 +976,11 @@ function orderLevelText(value) {
|
|
|
return { '0': '紧急', '1': '一般', '2': '低' }[code] || code
|
|
|
}
|
|
|
|
|
|
+/** 工单优先级色:0 紧急红 / 1 一般黄 / 2 低蓝;认不出回中性。 */
|
|
|
+function orderLevelTone(value) {
|
|
|
+ return { '0': 'lv1', '1': 'lv2', '2': 'lv3' }[String(value ?? '').trim()] || 'neutral'
|
|
|
+}
|
|
|
+
|
|
|
function tab(key, label) { return { key, label } }
|
|
|
function relatedAlarm(item) { const code = text(item.code || item.alarmNo || item.alarm_no || item.alarmCode || item.alarmId || item.alarm_id || item.id); const name = item.alarmName || item.alarm_name || item.content || item.alarmContent || item.alarm_content || item.deviceName || item.device_name || item.title || (code ? `报警 ${code}` : '关联报警'); return { id: item.alarmId || item.alarm_id || item.id || '', code, name, status: eventStatusText(mobileAlarmStatus(item.alarmStatus ?? item.alarm_status) || item.status || item.auditStatusName || item.alarmStatusName, 'ALARM') } }
|
|
|
function summaryItems(entries) { return entries.filter(([,value]) => value !== null && value !== undefined && String(value).trim() !== '').map(([label,value,tone]) => ({ label, value: String(value), tone: tone || '' })) }
|
|
|
@@ -897,7 +1009,10 @@ function recordItems(value) {
|
|
|
/** 处置记录来源兼容:预警 disposalHistory/logs;报警可能来自 audit 列表、工单时间线或最近操作。 */
|
|
|
function collectAuditRecords(source) {
|
|
|
const list = []
|
|
|
- const push = (value) => { if (Array.isArray(value)) list.push(...value.filter(Boolean)) }
|
|
|
+ const push = (value) => {
|
|
|
+ if (Array.isArray(value)) list.push(...value.filter(Boolean))
|
|
|
+ else if (value && typeof value === 'object') list.push(value)
|
|
|
+ }
|
|
|
push(source.disposalHistory)
|
|
|
push(source.logs)
|
|
|
push(source.timelineEntries)
|
|
|
@@ -983,9 +1098,5 @@ function threshold(source) {
|
|
|
function positive(value, fallback) { const n = Number(value); return Number.isFinite(n) && n > 0 ? Math.floor(n) : fallback }
|
|
|
function nonNegative(value, fallback) { const n = Number(value); return Number.isFinite(n) && n >= 0 ? Math.floor(n) : fallback }
|
|
|
function listCount(value, unit) { return Array.isArray(value) ? `${value.length} ${unit}` : '' }
|
|
|
-function locationText(value) {
|
|
|
- if (!value || typeof value !== 'object') return ''
|
|
|
- return value.location || value.address || [value.longitude, value.latitude].filter((item) => item !== undefined && item !== null).join(', ')
|
|
|
-}
|
|
|
function matchesId(row, id) { return !!row && [row.id, row.code, row.workOrderCode, row.warningNo, row.alarmId, row.facilityCode, row.resourceId].some((value) => String(value ?? '').trim() === id) }
|
|
|
function workOrderTone(code) { if (code === 5) return 'lv4'; if (code === 7) return 'lv1'; if (code === 6) return 'lv2'; return 'lv3' }
|