|
@@ -5,6 +5,7 @@
|
|
|
* point/device 沿用既有详情链,不在此重复实现。
|
|
* point/device 沿用既有详情链,不在此重复实现。
|
|
|
*/
|
|
*/
|
|
|
import { eventLevelFromBucket, eventLevelTag, eventStatusText, eventTypeText, eventNameText, formatEventTime } from './eventList.js'
|
|
import { eventLevelFromBucket, eventLevelTag, eventStatusText, eventTypeText, eventNameText, formatEventTime } from './eventList.js'
|
|
|
|
|
+import { statusDisplayTone } from './eventStatusVocab.js'
|
|
|
import { DEFAULT_TONE } from './statusTones.js'
|
|
import { DEFAULT_TONE } from './statusTones.js'
|
|
|
import { toWorkOrder, toWorkOrderTimeline, workOrderStateName } from './workOrder.js'
|
|
import { toWorkOrder, toWorkOrderTimeline, workOrderStateName } from './workOrder.js'
|
|
|
import { trackOf } from './workOrderTimeline.js'
|
|
import { trackOf } from './workOrderTimeline.js'
|
|
@@ -619,11 +620,17 @@ function normalizeEvent(identity, source) {
|
|
|
}
|
|
}
|
|
|
const family = String(identity.family || source.family || source.eventFamily || (source.alarmId || source.alarmNo ? 'ALARM' : source.warningId || source.warningNo ? 'WARNING' : '')).toUpperCase()
|
|
const family = String(identity.family || source.family || source.eventFamily || (source.alarmId || source.alarmNo ? 'ALARM' : source.warningId || source.warningNo ? 'WARNING' : '')).toUpperCase()
|
|
|
const level = eventLevelFrom(source)
|
|
const level = eventLevelFrom(source)
|
|
|
- const status = eventStatusText(source.status || source.state || mobileAlarmStatus(source.alarmStatus) || source.statusName || source.stateName || source.statusText, family)
|
|
|
|
|
|
|
+ const rawStatus = source.status || source.state || mobileAlarmStatus(source.alarmStatus) || source.statusName || source.stateName || source.statusText
|
|
|
|
|
+ const status = eventStatusText(rawStatus, family)
|
|
|
|
|
+ // 状态色走状态词表(待接收/已接收黄、处置中蓝、已处置紫、已解除绿),不再借用等级色。
|
|
|
|
|
+ const statusTone = statusDisplayTone(family, rawStatus)
|
|
|
const name = eventNameText(source.name || source.warningName || source.alarmName || source.eventName || source.deviceName || source.title) || '事件名称未提供'
|
|
const name = eventNameText(source.name || source.warningName || source.alarmName || source.eventName || source.deviceName || source.title) || '事件名称未提供'
|
|
|
// 列表 prefill 的 code 是旧内部请求键,只有 codeText 才是业务码;缺码不回退身份。
|
|
// 列表 prefill 的 code 是旧内部请求键,只有 codeText 才是业务码;缺码不回退身份。
|
|
|
const listCode = source.codeText === '编码未提供' ? '' : source.codeText
|
|
const listCode = source.codeText === '编码未提供' ? '' : source.codeText
|
|
|
const displayCode = text(source.codeText !== undefined ? listCode : source.code || source.eventCode || source.warningNo || source.alarmNo)
|
|
const displayCode = text(source.codeText !== undefined ? listCode : source.code || source.eventCode || source.warningNo || source.alarmNo)
|
|
|
|
|
+ // 报警族的处置记录/附件在不同后端版本字段不一,这里做兼容收集(预警族字段不变)。
|
|
|
|
|
+ const auditRecords = collectAuditRecords(source)
|
|
|
|
|
+ const attachments = collectAttachmentItems(source)
|
|
|
return {
|
|
return {
|
|
|
...identity,
|
|
...identity,
|
|
|
name,
|
|
name,
|
|
@@ -632,25 +639,27 @@ function normalizeEvent(identity, source) {
|
|
|
kindLabel: family === 'ALARM' ? '报警' : family === 'WARNING' ? '预警' : '事件',
|
|
kindLabel: family === 'ALARM' ? '报警' : family === 'WARNING' ? '预警' : '事件',
|
|
|
family,
|
|
family,
|
|
|
statusText: status,
|
|
statusText: status,
|
|
|
- tone: level.tone || 'neutral',
|
|
|
|
|
|
|
+ tone: statusTone || 'neutral',
|
|
|
// 抬头直接显示等级(与卡片同一张词表、同一套色),不再只写在字段里。
|
|
// 抬头直接显示等级(与卡片同一张词表、同一套色),不再只写在字段里。
|
|
|
levelLabel: level.label,
|
|
levelLabel: level.label,
|
|
|
levelTone: level.tone,
|
|
levelTone: level.tone,
|
|
|
raw: source,
|
|
raw: source,
|
|
|
// 等级带语义色(与卡片同一张词表),是摘要里唯一的等级呈现位置。
|
|
// 等级带语义色(与卡片同一张词表),是摘要里唯一的等级呈现位置。
|
|
|
- summary: summaryItems([['等级', level.label, level.tone], ['状态', status], ['当前值', withUnit(source.value ?? source.actualValue, source.unit || source.warningUnit)], ['发生时间', source.eventTime || source.createTime]]),
|
|
|
|
|
|
|
+ // 状态只在抬头徽标展示;摘要卡不再重复(等级 / 当前值 / 发生时间)。
|
|
|
|
|
+ summary: summaryItems([['等级', level.label, level.tone], ['当前值', withUnit(source.value ?? source.actualValue, source.unit || source.warningUnit)], ['发生时间', formatEventTime(source.eventTime || source.createTime)]]),
|
|
|
tabs: family === 'WARNING'
|
|
tabs: family === 'WARNING'
|
|
|
? [tab('overview', '预警信息'), tab('records', '处置记录'), tab('alarms', '关联报警'), tab('attachments', '附件')]
|
|
? [tab('overview', '预警信息'), tab('records', '处置记录'), tab('alarms', '关联报警'), tab('attachments', '附件')]
|
|
|
: [tab('overview', '报警信息'), tab('devices', '设备信息'), tab('records', '处置记录'), tab('attachments', '附件')],
|
|
: [tab('overview', '报警信息'), tab('devices', '设备信息'), tab('records', '处置记录'), tab('attachments', '附件')],
|
|
|
relatedAlarms: Array.isArray(source.alarmList) ? source.alarmList.map(relatedAlarm) : [],
|
|
relatedAlarms: Array.isArray(source.alarmList) ? source.alarmList.map(relatedAlarm) : [],
|
|
|
- stage: eventStage(family, status, source.disposalHistory),
|
|
|
|
|
|
|
+ stage: eventStage(family, rawStatus, auditRecords),
|
|
|
people: peopleItems([['发布人', source.publisherName || source.publisher], ['处置人', source.handlerName || source.handler], ['核验人', source.reviewerName || source.reviewer]]),
|
|
people: peopleItems([['发布人', source.publisherName || source.publisher], ['处置人', source.handlerName || source.handler], ['核验人', source.reviewerName || source.reviewer]]),
|
|
|
devices: deviceItems(source),
|
|
devices: deviceItems(source),
|
|
|
- attachments: attachmentItems(source.attachmentList),
|
|
|
|
|
- records: recordItems(source.disposalHistory || source.logs),
|
|
|
|
|
|
|
+ attachments,
|
|
|
|
|
+ records: recordItems(auditRecords),
|
|
|
sections: compactSections([
|
|
sections: compactSections([
|
|
|
// 等级只出现在摘要卡片那一处(带色),这里不再重复一遍纯文字等级。
|
|
// 等级只出现在摘要卡片那一处(带色),这里不再重复一遍纯文字等级。
|
|
|
- section('事件摘要', [field('事件编码', displayCode || '未提供'), field('状态', status), field('发生时间', source.eventTime || source.createTime)]),
|
|
|
|
|
|
|
+ // 状态在抬头与摘要卡各有一次,这里不再重复(否则事件编码被挤到换行)。
|
|
|
|
|
+ section('事件摘要', [field('事件编码', displayCode || '未提供', true), field('发生时间', formatEventTime(source.eventTime || source.createTime))]),
|
|
|
section('监测读数', [
|
|
section('监测读数', [
|
|
|
field('指标', eventTypeText(source.type || source.warningType || source.warningCode, source.typeName || source.warningTypeName)),
|
|
field('指标', eventTypeText(source.type || source.warningType || source.warningCode, source.typeName || source.warningTypeName)),
|
|
|
// 读数与阈值都带单位(维护者 2026-10-29:数值型指标必须有单位提示)。
|
|
// 读数与阈值都带单位(维护者 2026-10-29:数值型指标必须有单位提示)。
|
|
@@ -658,11 +667,18 @@ function normalizeEvent(identity, source) {
|
|
|
field('阈值', threshold(source)),
|
|
field('阈值', threshold(source)),
|
|
|
field('超出幅度', withUnit(source.deviationRatio, '%')),
|
|
field('超出幅度', withUnit(source.deviationRatio, '%')),
|
|
|
]),
|
|
]),
|
|
|
- section('关联信息', [field('设备', source.deviceName || source.deviceCode), field('监测点', source.monitoringPointName || source.monitoringPointCode), field('工单', source.workOrderCode || source.orderNo), field('位置', source.location || source.address || locationText(source.gisLocation), true)]),
|
|
|
|
|
|
|
+ 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('处置与附件', [
|
|
section('处置与附件', [
|
|
|
- field('处置记录', listCount(source.disposalHistory, '条')),
|
|
|
|
|
|
|
+ field('处置记录', listCount(auditRecords, '条')),
|
|
|
field('关联报警', listCount(source.alarmList, '条')),
|
|
field('关联报警', listCount(source.alarmList, '条')),
|
|
|
- field('附件', listCount(source.attachmentList, '项')),
|
|
|
|
|
|
|
+ field('附件', listCount(attachments, '项')),
|
|
|
field('督办记录', listCount(source.supervisionList, '条')),
|
|
field('督办记录', listCount(source.supervisionList, '条')),
|
|
|
]),
|
|
]),
|
|
|
]),
|
|
]),
|
|
@@ -727,7 +743,7 @@ function orderLevelText(value) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function tab(key, label) { return { key, label } }
|
|
function tab(key, label) { return { key, label } }
|
|
|
-function relatedAlarm(item) { return { id: item.alarmId || item.id || '', code: text(item.code || item.alarmNo || item.alarmCode), name: item.alarmName || item.content || item.deviceName || '关联报警', status: eventStatusText(mobileAlarmStatus(item.alarmStatus) || item.status || item.auditStatusName, 'ALARM') } }
|
|
|
|
|
|
|
+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 || '' })) }
|
|
function summaryItems(entries) { return entries.filter(([,value]) => value !== null && value !== undefined && String(value).trim() !== '').map(([label,value,tone]) => ({ label, value: String(value), tone: tone || '' })) }
|
|
|
function peopleItems(entries) { return entries.filter(([,name]) => name).map(([role,name]) => ({ role, name: String(name) })) }
|
|
function peopleItems(entries) { return entries.filter(([,name]) => name).map(([role,name]) => ({ role, name: String(name) })) }
|
|
|
function deviceItems(source) {
|
|
function deviceItems(source) {
|
|
@@ -745,19 +761,57 @@ function attachmentItems(value) {
|
|
|
}
|
|
}
|
|
|
function recordItems(value) {
|
|
function recordItems(value) {
|
|
|
return (Array.isArray(value) ? value : []).map((item) => ({
|
|
return (Array.isArray(value) ? value : []).map((item) => ({
|
|
|
- title: item.operationName || item.operationType || item.action || item.disposalStatus || '处置记录',
|
|
|
|
|
- time: item.operatedAt || item.operationTime || item.createTime || item.disposalTime || '',
|
|
|
|
|
- operator: item.operatorName || item.operator || item.createByName || item.disposalUser || '',
|
|
|
|
|
- description: item.operationDesc || item.remark || item.content || item.disposalContent || '',
|
|
|
|
|
|
|
+ title: item.operationName || item.operationType || item.action || item.disposalTypeName || item.disposalStatus || '处置记录',
|
|
|
|
|
+ time: formatEventTime(item.operatedAt || item.operationTime || item.createTime || item.create_time || item.disposalTime || ''),
|
|
|
|
|
+ operator: item.operatorName || item.operator || item.createByName || item.disposal_user_name || item.disposalUser || item.disposal_user || '',
|
|
|
|
|
+ description: item.operationDesc || item.remark || item.content || item.disposal_content || item.disposalContent || '',
|
|
|
}))
|
|
}))
|
|
|
}
|
|
}
|
|
|
|
|
+/** 处置记录来源兼容:预警 disposalHistory/logs;报警可能来自 audit 列表、工单时间线或最近操作。 */
|
|
|
|
|
+function collectAuditRecords(source) {
|
|
|
|
|
+ const list = []
|
|
|
|
|
+ const push = (value) => { if (Array.isArray(value)) list.push(...value.filter(Boolean)) }
|
|
|
|
|
+ push(source.disposalHistory)
|
|
|
|
|
+ push(source.logs)
|
|
|
|
|
+ push(source.timelineEntries)
|
|
|
|
|
+ push(source.auditList)
|
|
|
|
|
+ push(source.auditRecords)
|
|
|
|
|
+ push(source.handleRecords)
|
|
|
|
|
+ push(source.records)
|
|
|
|
|
+ const order = source.workOrderDetail
|
|
|
|
|
+ if (order && typeof order === 'object') { push(order.timelineEntries); push(order.logs) }
|
|
|
|
|
+ if (!list.length && (source.latestOperation || source.latestOperationTime)) {
|
|
|
|
|
+ list.push({ operationName: source.latestOperation || '处置记录', operatedAt: source.latestOperationTime })
|
|
|
|
|
+ }
|
|
|
|
|
+ return list
|
|
|
|
|
+}
|
|
|
|
|
+/** 附件来源兼容:预警 attachmentList;报警可能来自 attachList/attachments/equipmentImage 或关联工单维修图片。 */
|
|
|
|
|
+function collectAttachmentItems(source) {
|
|
|
|
|
+ const raw = []
|
|
|
|
|
+ const push = (value) => {
|
|
|
|
|
+ if (Array.isArray(value)) raw.push(...value)
|
|
|
|
|
+ else if (typeof value === 'string' && value.trim()) raw.push(value)
|
|
|
|
|
+ }
|
|
|
|
|
+ push(source.attachmentList)
|
|
|
|
|
+ push(source.attachList)
|
|
|
|
|
+ push(source.attachments)
|
|
|
|
|
+ push(source.equipmentImage)
|
|
|
|
|
+ const order = source.workOrderDetail
|
|
|
|
|
+ if (order && typeof order === 'object') { push(order.maintenanceBeforeImages); push(order.maintenanceAfterImages); push(order.attachmentList) }
|
|
|
|
|
+ return attachmentItems(raw)
|
|
|
|
|
+}
|
|
|
function eventStage(family, status, records) {
|
|
function eventStage(family, status, records) {
|
|
|
const labels = family === 'ALARM' ? ['产生', '确认', '处置', '关闭'] : ['发布', '接收', '处置', '核验', '解除']
|
|
const labels = family === 'ALARM' ? ['产生', '确认', '处置', '关闭'] : ['发布', '接收', '处置', '核验', '解除']
|
|
|
|
|
+ // status 既可能是后端机器码(CLOSED),也可能是已本地化的中文(已解除);两者都要落到正确阶段。
|
|
|
const normalized = String(status || '').toUpperCase()
|
|
const normalized = String(status || '').toUpperCase()
|
|
|
- let active = normalized.includes('RESOLV') || normalized.includes('CLEAR') || normalized.includes('CLOSE') ? labels.length - 1
|
|
|
|
|
- : normalized.includes('PROCESS') || normalized.includes('HANDL') ? Math.min(2, labels.length - 1)
|
|
|
|
|
- : normalized.includes('RECEIV') || normalized.includes('CONFIRM') ? 1 : 0
|
|
|
|
|
- if (Array.isArray(records) && records.length) active = Math.max(active, Math.min(2, labels.length - 1))
|
|
|
|
|
|
|
+ const terminal = /RESOLV|CLEAR|CLOSE|解除|关闭/.test(normalized)
|
|
|
|
|
+ const processing = /PROCESS|HANDL|处置中|已处置|处置/.test(normalized) && !/UNHANDL/.test(normalized)
|
|
|
|
|
+ const received = /RECEIV|CONFIRM|接收/.test(normalized)
|
|
|
|
|
+ let active = terminal ? labels.length - 1
|
|
|
|
|
+ : processing ? Math.min(2, labels.length - 1)
|
|
|
|
|
+ : received ? 1 : 0
|
|
|
|
|
+ // 记录只代表「至少推进到处置」,不能把已是终态(解除/关闭)的流程往回拉。
|
|
|
|
|
+ if (!terminal && Array.isArray(records) && records.length) active = Math.max(active, Math.min(2, labels.length - 1))
|
|
|
return labels.map((label,index) => ({ label, state: index < active ? 'done' : index === active ? 'active' : 'pending' }))
|
|
return labels.map((label,index) => ({ label, state: index < active ? 'done' : index === active ? 'active' : 'pending' }))
|
|
|
}
|
|
}
|
|
|
function workOrderStage(code) {
|
|
function workOrderStage(code) {
|