|
@@ -94,22 +94,40 @@ function initialSections() {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-/** 当前事件分区是本次请求里最新的一份状态事实;历史/效率行只借用它的 status 字段。 */
|
|
|
|
|
-function currentStatusByCode(current) {
|
|
|
|
|
|
|
+const currentDomainEvents = (current) => {
|
|
|
|
|
+ const data = current && current.data
|
|
|
|
|
+ if (!data) return []
|
|
|
|
|
+ if (Array.isArray(data.events)) return data.events
|
|
|
|
|
+ const sectionEvents = data.sections && data.sections.events && data.sections.events.data
|
|
|
|
|
+ return Array.isArray(sectionEvents) ? sectionEvents : []
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+const eventCodeOf = (event) => event && (event.codeText || event.code || event.eventCode || event.eventNo)
|
|
|
|
|
+
|
|
|
|
|
+export function currentStatusByCode(current) {
|
|
|
const result = new Map()
|
|
const result = new Map()
|
|
|
- const events = current && current.data && Array.isArray(current.data.events) ? current.data.events : []
|
|
|
|
|
- for (const event of events) {
|
|
|
|
|
- const code = event && (event.eventCode || event.eventNo)
|
|
|
|
|
|
|
+ for (const event of currentDomainEvents(current)) {
|
|
|
|
|
+ const code = eventCodeOf(event)
|
|
|
if (code && event.status) result.set(String(code), event.status)
|
|
if (code && event.status) result.set(String(code), event.status)
|
|
|
}
|
|
}
|
|
|
return result
|
|
return result
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+export function currentTypeByCode(current) {
|
|
|
|
|
+ const result = new Map()
|
|
|
|
|
+ for (const event of currentDomainEvents(current)) {
|
|
|
|
|
+ const code = eventCodeOf(event)
|
|
|
|
|
+ const type = event.type || event.eventType
|
|
|
|
|
+ if (code && type) result.set(String(code), type)
|
|
|
|
|
+ }
|
|
|
|
|
+ return result
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
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) => {
|
|
|
if (!row) return row
|
|
if (!row) return row
|
|
|
- const status = statuses.get(String(row.eventCode || row.eventNo || ''))
|
|
|
|
|
|
|
+ const status = statuses.get(String(eventCodeOf(row) || ''))
|
|
|
return status && status !== row.status ? { ...row, status } : row
|
|
return status && status !== row.status ? { ...row, status } : row
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
@@ -121,6 +139,25 @@ 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 mergeRowsType(rows, types) {
|
|
|
|
|
+ if (!Array.isArray(rows) || !types.size) return rows
|
|
|
|
|
+ return rows.map((row) => {
|
|
|
|
|
+ if (!row) return row
|
|
|
|
|
+ const type = types.get(String(eventCodeOf(row) || ''))
|
|
|
|
|
+ if (!type) return row
|
|
|
|
|
+ const next = { ...row, type }
|
|
|
|
|
+ if (Object.prototype.hasOwnProperty.call(row, 'eventType')) next.eventType = type
|
|
|
|
|
+ return next
|
|
|
|
|
+ })
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+export function mergeSectionType(section, types) {
|
|
|
|
|
+ const events = section && section.data && section.data.events
|
|
|
|
|
+ if (!Array.isArray(events)) return section
|
|
|
|
|
+ const merged = mergeRowsType(events, types)
|
|
|
|
|
+ return merged === events ? section : { ...section, data: { ...section.data, events: merged } }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
export const useEventStore = defineStore('eventStore', () => {
|
|
export const useEventStore = defineStore('eventStore', () => {
|
|
|
/** 当前切换状态:`WARNING`(预警)或 `ALARM`(报警)。默认预警(`/events/current` 的 mode 必填)。 */
|
|
/** 当前切换状态:`WARNING`(预警)或 `ALARM`(报警)。默认预警(`/events/current` 的 mode 必填)。 */
|
|
|
const mode = ref(EVENT_FAMILY.WARNING)
|
|
const mode = ref(EVENT_FAMILY.WARNING)
|
|
@@ -425,14 +462,15 @@ export const useEventStore = defineStore('eventStore', () => {
|
|
|
// 当前事件分区本次刚取到;历史/效率行只借用它的 status。
|
|
// 当前事件分区本次刚取到;历史/效率行只借用它的 status。
|
|
|
// 后端历史/效率快照即使暂时滞后,列表卡片也不会显示与详情相反的旧状态。
|
|
// 后端历史/效率快照即使暂时滞后,列表卡片也不会显示与详情相反的旧状态。
|
|
|
const currentStatuses = currentStatusByCode(current)
|
|
const currentStatuses = currentStatusByCode(current)
|
|
|
- const historyWithStatus = mergeSectionStatus(history, currentStatuses)
|
|
|
|
|
|
|
+ const currentTypes = currentTypeByCode(current)
|
|
|
|
|
+ const historyWithStatus = mergeSectionType(mergeSectionStatus(history, currentStatuses), currentTypes)
|
|
|
// 票 71 返工:把逐日趋势挂进效率分区(domain 只读 `incidentTrend` 字段)。
|
|
// 票 71 返工:把逐日趋势挂进效率分区(domain 只读 `incidentTrend` 字段)。
|
|
|
// 取失败(null)时保持缺失 ⇒ 界面说「不画」的原因,不画假线。
|
|
// 取失败(null)时保持缺失 ⇒ 界面说「不画」的原因,不画假线。
|
|
|
// **同时**用这批带 status 的行替换列表数据源:效率端点不返回 status,
|
|
// **同时**用这批带 status 的行替换列表数据源:效率端点不返回 status,
|
|
|
// 用它画列表会把每条都写成「状态未发布」(维护者 2026-10-29 第 1 条反馈)。
|
|
// 用它画列表会把每条都写成「状态未发布」(维护者 2026-10-29 第 1 条反馈)。
|
|
|
const trend = incidentTrend && incidentTrend.days ? incidentTrend : null
|
|
const trend = incidentTrend && incidentTrend.days ? incidentTrend : null
|
|
|
const trendRows = trend && Array.isArray(incidentTrend.rows)
|
|
const trendRows = trend && Array.isArray(incidentTrend.rows)
|
|
|
- ? mergeRowsStatus(incidentTrend.rows, currentStatuses)
|
|
|
|
|
|
|
+ ? mergeRowsType(mergeRowsStatus(incidentTrend.rows, currentStatuses), currentTypes)
|
|
|
: null
|
|
: null
|
|
|
const efficiencyWithTrend = efficiency && efficiency.data
|
|
const efficiencyWithTrend = efficiency && efficiency.data
|
|
|
? {
|
|
? {
|