更新A样式

This commit is contained in:
zhougf committed 2026-04-18 15:51:00 +08:00
1 parent 89fe9988fc
commit be8de4c00a
7 files changed
+259 -81

No files matched your search

+45 -15
View File
@@ -133,30 +133,60 @@ const weeklyProduceTotal = computed(() => {
return totals
})
// 报警汇总
/** 魔盒报警行上的发生时间(不同版本字段名不一,尽量兼容) */
function laserAlarmOccurAt(a) {
const raw =
a?.AlarmTime ??
a?.alarmTime ??
a?.CreateTime ??
a?.createTime ??
a?.OccurTime ??
a?.occurTime ??
a?.Time ??
a?.time
if (raw == null || raw === '') return null
const d = new Date(raw)
return Number.isNaN(d.getTime()) ? null : d
}
// 报警汇总:B/C 仍为「设备处于报警态」一条;A 类(魔盒)为近 1 小时 alarm/v2 多条,不按 AlarmCount 标设备报警态
const alarms = computed(() => {
const arr = []
const rows = []
const now = new Date()
overviewDevices.value.forEach(d => {
overviewDevices.value.forEach((d) => {
if (!d.online || !d.machineData) return
if (d.type === 'laser') return
const status = getDeviceStatus(d)
if (status.key !== 'alarm') return
let msg = ''
if (d.type === 'cnc') {
const a = d.machineData.alarm
msg = a?.length ? a[0] : 'CNC系统报警'
} else if (d.type === 'laser') {
const nc = d.machineData.CutSystemState?.NcState
msg = nc?.AlarmMsg || `报警 ${nc?.AlarmCount || 0} 个`
}
arr.push({
const a = d.machineData.alarm
const msg = a?.length ? a[0] : 'CNC系统报警'
rows.push({
at: now.getTime(),
time: now.toLocaleTimeString('zh-CN', { hour12: false }),
device: d.type === 'cnc' ? `CNC-${d.name}` : d.name,
device: `CNC-${d.name}`,
message: msg
})
})
return arr
laserListForUi.value.forEach((d) => {
if (!d.online || d.type !== 'laser') return
const list = d._laser?.alarmsLastHour
if (!Array.isArray(list) || !list.length) return
list.forEach((a) => {
const at = laserAlarmOccurAt(a) || now
const msg = a?.AlarmDesc || a?.alarmDesc || a?.message || a?.msg || ''
rows.push({
at: at.getTime(),
time: at.toLocaleTimeString('zh-CN', { hour12: false }),
device: d.name,
message: msg || '报警'
})
})
})
rows.sort((x, y) => y.at - x.at)
return rows.map(({ at: _t, ...rest }) => rest)
})
function goDetail(id) {