|
@@ -35,6 +35,7 @@ import { usePointLocateStore } from './pointLocateStore.js'
|
|
|
import { EVENT_RANGES } from '../domain/warningResponsePanels.js'
|
|
import { EVENT_RANGES } from '../domain/warningResponsePanels.js'
|
|
|
import { eventTimeWindow, historyWindows } from '../domain/eventRange.js'
|
|
import { eventTimeWindow, historyWindows } from '../domain/eventRange.js'
|
|
|
import { fetchEventAnalysis, fetchEventHistory, fetchHandlingEfficiency, fetchIncidentTrend } from '../services/warningResponseApi.js'
|
|
import { fetchEventAnalysis, fetchEventHistory, fetchHandlingEfficiency, fetchIncidentTrend } from '../services/warningResponseApi.js'
|
|
|
|
|
+import { fetchAlarmAuditStatus } from '../services/entityDetailApi.js'
|
|
|
import { fetchWorkOrderList } from '../services/detailApi.js'
|
|
import { fetchWorkOrderList } from '../services/detailApi.js'
|
|
|
import { PAGE_SIZE, serverPageView } from '../domain/pagination.js'
|
|
import { PAGE_SIZE, serverPageView } from '../domain/pagination.js'
|
|
|
import { createViewMemo } from '../domain/panelViewCache.js'
|
|
import { createViewMemo } from '../domain/panelViewCache.js'
|
|
@@ -123,6 +124,42 @@ export function currentTypeByCode(current) {
|
|
|
return result
|
|
return result
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * 兼容补齐:后端当前报警接口尚未返回 auditStatus 时,只对**可见的未处理报警**按详情接口补一次。
|
|
|
|
|
+ * 后端返回该字段后不会再发这些请求。
|
|
|
|
|
+ */
|
|
|
|
|
+async function enrichCurrentAlarmAudit(current, mode, mine, alive) {
|
|
|
|
|
+ if (String(mode || '').toUpperCase() !== 'ALARM') return current
|
|
|
|
|
+ const sectionEvents = current && current.data && current.data.sections && current.data.sections.events
|
|
|
|
|
+ const rows = sectionEvents && Array.isArray(sectionEvents.data) ? sectionEvents.data : []
|
|
|
|
|
+ const targets = rows.filter((row) => row && row.status === 'UNHANDLED' && row.auditStatus == null)
|
|
|
|
|
+ if (!targets.length) return current
|
|
|
|
|
+ const auditByCode = new Map()
|
|
|
|
|
+ await Promise.all(targets.map(async (row) => {
|
|
|
|
|
+ const code = row.codeText || row.code
|
|
|
|
|
+ const audit = await fetchAlarmAuditStatus(code)
|
|
|
|
|
+ if (audit.auditStatus !== null) auditByCode.set(String(code), audit)
|
|
|
|
|
+ }))
|
|
|
|
|
+ if (mine !== undefined && !alive()) return current
|
|
|
|
|
+ if (!auditByCode.size) return current
|
|
|
|
|
+ return {
|
|
|
|
|
+ ...current,
|
|
|
|
|
+ data: {
|
|
|
|
|
+ ...current.data,
|
|
|
|
|
+ sections: {
|
|
|
|
|
+ ...current.data.sections,
|
|
|
|
|
+ events: {
|
|
|
|
|
+ ...sectionEvents,
|
|
|
|
|
+ data: rows.map((row) => {
|
|
|
|
|
+ const audit = auditByCode.get(String(row.codeText || row.code))
|
|
|
|
|
+ return audit ? { ...row, auditStatus: audit.auditStatus, auditStatusName: audit.auditStatusName } : row
|
|
|
|
|
+ }),
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
export function mergeRowsStatus(rows, statuses) {
|
|
export function mergeRowsStatus(rows, statuses) {
|
|
|
if (!Array.isArray(rows) || !statuses.size) return rows
|
|
if (!Array.isArray(rows) || !statuses.size) return rows
|
|
|
return rows.map((row) => {
|
|
return rows.map((row) => {
|
|
@@ -518,8 +555,41 @@ export const useEventStore = defineStore('eventStore', () => {
|
|
|
currentDomain.value = safeCurrent.data || null
|
|
currentDomain.value = safeCurrent.data || null
|
|
|
selectedEvent.value = refreshedEventSelection(selectedEvent.value, currentDomain.value)
|
|
selectedEvent.value = refreshedEventSelection(selectedEvent.value, currentDomain.value)
|
|
|
loading.value = false
|
|
loading.value = false
|
|
|
- return sections.value
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // 兼容补齐放到首屏之后:后端当前报警接口未回 auditStatus 时,
|
|
|
|
|
+ // 详情接口补数不得阻塞当前列表(否则整块会一直停在“正在取数”)。
|
|
|
|
|
+ if (String(active.mode || mode.value).toUpperCase() === 'ALARM') {
|
|
|
|
|
+ void enrichCurrentAlarmAudit(current, active.mode, mine, () => true).then((enriched) => {
|
|
|
|
|
+ if (mode.value !== 'ALARM' || !enriched || enriched === current) return
|
|
|
|
|
+ const latest = sections.value.currentEvents
|
|
|
|
|
+ const rows = latest && latest.data && latest.data.sections && latest.data.sections.events
|
|
|
|
|
+ ? latest.data.sections.events.data : []
|
|
|
|
|
+ const audits = new Map((enriched.data && enriched.data.sections && enriched.data.sections.events
|
|
|
|
|
+ ? enriched.data.sections.events.data : [])
|
|
|
|
|
+ .filter((row) => row && row.auditStatus != null)
|
|
|
|
|
+ .map((row) => [String(row.codeText || row.code), { auditStatus: row.auditStatus, auditStatusName: row.auditStatusName }]))
|
|
|
|
|
+ if (!audits.size || !Array.isArray(rows)) return
|
|
|
|
|
+ const mergedRows = rows.map((row) => {
|
|
|
|
|
+ const audit = audits.get(String(row.codeText || row.code))
|
|
|
|
|
+ return audit && row.auditStatus == null ? { ...row, ...audit } : row
|
|
|
|
|
+ })
|
|
|
|
|
+ sections.value = {
|
|
|
|
|
+ ...sections.value,
|
|
|
|
|
+ currentEvents: {
|
|
|
|
|
+ ...latest,
|
|
|
|
|
+ data: {
|
|
|
|
|
+ ...latest.data,
|
|
|
|
|
+ sections: {
|
|
|
|
|
+ ...latest.data.sections,
|
|
|
|
|
+ events: { ...latest.data.sections.events, data: mergedRows },
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ }
|
|
|
|
|
+ currentDomain.value = sections.value.currentEvents.data || null
|
|
|
|
|
+ selectedEvent.value = refreshedEventSelection(selectedEvent.value, currentDomain.value)
|
|
|
|
|
+ }).catch(() => {})
|
|
|
|
|
+ }
|
|
|
|
|
+ return sections.value }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 已落定的一页若越界则夹回并补取一次(与 `loadPage` 同一判据)。
|
|
* 已落定的一页若越界则夹回并补取一次(与 `loadPage` 同一判据)。
|