|
@@ -125,14 +125,14 @@ export function currentTypeByCode(current) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 兼容补齐:后端当前报警接口尚未返回 auditStatus 时,只对**可见的未处理报警**按详情接口补一次。
|
|
|
|
|
|
|
+ * 兼容补齐:后端当前报警接口尚未返回 auditStatus 时,对**当前报警全集**按详情接口补一次(历史/效率卡也从这份索引取)。
|
|
|
* 后端返回该字段后不会再发这些请求。
|
|
* 后端返回该字段后不会再发这些请求。
|
|
|
*/
|
|
*/
|
|
|
async function enrichCurrentAlarmAudit(current, mode, mine, alive) {
|
|
async function enrichCurrentAlarmAudit(current, mode, mine, alive) {
|
|
|
if (String(mode || '').toUpperCase() !== 'ALARM') return current
|
|
if (String(mode || '').toUpperCase() !== 'ALARM') return current
|
|
|
const sectionEvents = current && current.data && current.data.sections && current.data.sections.events
|
|
const sectionEvents = current && current.data && current.data.sections && current.data.sections.events
|
|
|
const rows = sectionEvents && Array.isArray(sectionEvents.data) ? sectionEvents.data : []
|
|
const rows = sectionEvents && Array.isArray(sectionEvents.data) ? sectionEvents.data : []
|
|
|
- const targets = rows.filter((row) => row && row.status === 'UNHANDLED' && row.auditStatus == null)
|
|
|
|
|
|
|
+ const targets = rows.filter((row) => row && row.auditStatus == null)
|
|
|
if (!targets.length) return current
|
|
if (!targets.length) return current
|
|
|
const auditByCode = new Map()
|
|
const auditByCode = new Map()
|
|
|
await Promise.all(targets.map(async (row) => {
|
|
await Promise.all(targets.map(async (row) => {
|
|
@@ -176,6 +176,32 @@ export function mergeSectionStatus(section, statuses) {
|
|
|
return merged === events ? section : { ...section, data: { ...section.data, events: merged } }
|
|
return merged === events ? section : { ...section, data: { ...section.data, events: merged } }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+function currentAuditByCode(current) {
|
|
|
|
|
+ const result = new Map()
|
|
|
|
|
+ for (const event of currentDomainEvents(current)) {
|
|
|
|
|
+ const code = eventCodeOf(event)
|
|
|
|
|
+ if (code && event.auditStatus !== undefined && event.auditStatus !== null) {
|
|
|
|
|
+ result.set(String(code), { auditStatus: event.auditStatus, auditStatusName: event.auditStatusName || '' })
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return result
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+export function mergeRowsAudit(rows, audits) {
|
|
|
|
|
+ if (!Array.isArray(rows) || !audits.size) return rows
|
|
|
|
|
+ return rows.map((row) => {
|
|
|
|
|
+ if (!row || row.auditStatus !== undefined && row.auditStatus !== null) return row
|
|
|
|
|
+ const audit = audits.get(String(eventCodeOf(row) || ''))
|
|
|
|
|
+ return audit ? { ...row, auditStatus: audit.auditStatus, auditStatusName: audit.auditStatusName } : row
|
|
|
|
|
+ })
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+export function mergeSectionAudit(section, audits) {
|
|
|
|
|
+ const events = section && section.data && section.data.events
|
|
|
|
|
+ if (!Array.isArray(events)) return section
|
|
|
|
|
+ const merged = mergeRowsAudit(events, audits)
|
|
|
|
|
+ return merged === events ? section : { ...section, data: { ...section.data, events: merged } }
|
|
|
|
|
+}
|
|
|
function mergeRowsType(rows, types) {
|
|
function mergeRowsType(rows, types) {
|
|
|
if (!Array.isArray(rows) || !types.size) return rows
|
|
if (!Array.isArray(rows) || !types.size) return rows
|
|
|
return rows.map((row) => {
|
|
return rows.map((row) => {
|
|
@@ -502,7 +528,8 @@ export const useEventStore = defineStore('eventStore', () => {
|
|
|
// 后端历史/效率快照即使暂时滞后,列表卡片也不会显示与详情相反的旧状态。
|
|
// 后端历史/效率快照即使暂时滞后,列表卡片也不会显示与详情相反的旧状态。
|
|
|
const currentStatuses = currentStatusByCode(current)
|
|
const currentStatuses = currentStatusByCode(current)
|
|
|
const currentTypes = currentTypeByCode(current)
|
|
const currentTypes = currentTypeByCode(current)
|
|
|
- const historyWithStatus = mergeSectionType(mergeSectionStatus(history, currentStatuses), currentTypes)
|
|
|
|
|
|
|
+ const currentAudits = currentAuditByCode(current)
|
|
|
|
|
+ const historyWithStatus = mergeSectionType(mergeSectionAudit(mergeSectionStatus(history, currentStatuses), currentAudits), currentTypes)
|
|
|
// 票 71 返工:把逐日趋势挂进效率分区(domain 只读 `incidentTrend` 字段)。
|
|
// 票 71 返工:把逐日趋势挂进效率分区(domain 只读 `incidentTrend` 字段)。
|
|
|
// 取失败(null)时保持缺失 ⇒ 界面说「不画」的原因,不画假线。
|
|
// 取失败(null)时保持缺失 ⇒ 界面说「不画」的原因,不画假线。
|
|
|
// **同时**用这批带 status 的行替换列表数据源:效率端点不返回 status,
|
|
// **同时**用这批带 status 的行替换列表数据源:效率端点不返回 status,
|
|
@@ -548,7 +575,7 @@ export const useEventStore = defineStore('eventStore', () => {
|
|
|
sections.value = {
|
|
sections.value = {
|
|
|
currentEvents: { ...safeCurrent, loaded: true },
|
|
currentEvents: { ...safeCurrent, loaded: true },
|
|
|
historyAnalysis: { ...historyWithStatus, loaded: true },
|
|
historyAnalysis: { ...historyWithStatus, loaded: true },
|
|
|
- responseEfficiency: { ...efficiencyWithTrend, loaded: true },
|
|
|
|
|
|
|
+ responseEfficiency: { ...mergeSectionAudit(efficiencyWithTrend, currentAudits), loaded: true },
|
|
|
eventAnalysis: { ...analysis, loaded: true },
|
|
eventAnalysis: { ...analysis, loaded: true },
|
|
|
workOrderList: { ...workOrderList, loaded: true },
|
|
workOrderList: { ...workOrderList, loaded: true },
|
|
|
}
|
|
}
|
|
@@ -572,6 +599,7 @@ export const useEventStore = defineStore('eventStore', () => {
|
|
|
const audit = audits.get(String(row.codeText || row.code))
|
|
const audit = audits.get(String(row.codeText || row.code))
|
|
|
return audit && row.auditStatus == null ? { ...row, ...audit } : row
|
|
return audit && row.auditStatus == null ? { ...row, ...audit } : row
|
|
|
})
|
|
})
|
|
|
|
|
+ const auditIndex = currentAuditByCode({ data: { sections: { events: { data: mergedRows } } } })
|
|
|
sections.value = {
|
|
sections.value = {
|
|
|
...sections.value,
|
|
...sections.value,
|
|
|
currentEvents: {
|
|
currentEvents: {
|
|
@@ -584,6 +612,8 @@ export const useEventStore = defineStore('eventStore', () => {
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
|
|
+ historyAnalysis: mergeSectionAudit(sections.value.historyAnalysis, auditIndex),
|
|
|
|
|
+ responseEfficiency: mergeSectionAudit(sections.value.responseEfficiency, auditIndex),
|
|
|
}
|
|
}
|
|
|
currentDomain.value = sections.value.currentEvents.data || null
|
|
currentDomain.value = sections.value.currentEvents.data || null
|
|
|
selectedEvent.value = refreshedEventSelection(selectedEvent.value, currentDomain.value)
|
|
selectedEvent.value = refreshedEventSelection(selectedEvent.value, currentDomain.value)
|