add a
This commit is contained in:
1 parent
bc93fb4d61
commit
89fe9988fc
12 files changed
+586
-22
No files matched your search
+32
-8
@@ -6,7 +6,7 @@
|
||||
<!-- ===== 左侧面板 ===== -->
|
||||
<div class="left-panel panel-box">
|
||||
<StatusSummary
|
||||
:devices="mqtt.devices"
|
||||
:devices="overviewDevices"
|
||||
:weeklyLabels="weeklyLabels"
|
||||
:weeklyProduce="weeklyProduceTotal"
|
||||
:todayIdx="todayIdx"
|
||||
@@ -68,6 +68,11 @@
|
||||
| 最近消息:{{ mqtt.lastMessageTopic }} @ {{ mqtt.lastMessageAt }}
|
||||
</template>
|
||||
<span v-if="mqtt.error" class="mqtt-err"> | {{ mqtt.error }}</span>
|
||||
<template v-if="laser.enabled">
|
||||
| 激光魔盒:{{ laser.syncing ? '同步中' : '已同步' }}
|
||||
<template v-if="laser.lastSyncAt"> @ {{ laser.lastSyncAt }}</template>
|
||||
<span v-if="laser.error" class="mqtt-err"> | {{ laser.error }}</span>
|
||||
</template>
|
||||
</div>
|
||||
<div v-if="mqtt.lastRouteHint" class="mqtt-hint">{{ mqtt.lastRouteHint }}</div>
|
||||
</div>
|
||||
@@ -83,23 +88,42 @@ import PowerCard from '../components/PowerCard.vue'
|
||||
import StatusSummary from '../components/StatusSummary.vue'
|
||||
import AlarmPanel from '../components/AlarmPanel.vue'
|
||||
import { mqttRuntime } from '../services/mqttDeviceStore.js'
|
||||
import { getWeeklyInfo } from '../utils/weekLabels.js'
|
||||
import { laserBoxRuntime } from '../services/laserBoxSync.js'
|
||||
import { getLast7DaysChartInfo } from '../utils/weekLabels.js'
|
||||
import { getDeviceStatus } from '../composables/useDeviceStatus.js'
|
||||
|
||||
const router = useRouter()
|
||||
const mqtt = mqttRuntime
|
||||
const laser = laserBoxRuntime
|
||||
|
||||
// 按类型过滤
|
||||
const laserDevices = computed(() => mqttRuntime.devices.filter(d => d.type === 'laser'))
|
||||
/**
|
||||
* A 类数据源:已配置魔盒 URL 时**只**用 HTTP 列表(即使暂时为空也不回退 MQTT)。
|
||||
* 未配置魔盒时才展示 MQTT 中的 `type === 'laser'`。
|
||||
*/
|
||||
const laserListForUi = computed(() => {
|
||||
if (laser.enabled) return laser.devices
|
||||
return mqttRuntime.devices.filter((d) => d.type === 'laser')
|
||||
})
|
||||
|
||||
const overviewDevices = computed(() => [
|
||||
...laserListForUi.value,
|
||||
...mqttRuntime.devices.filter((d) => d.type !== 'laser')
|
||||
])
|
||||
|
||||
const laserDevices = computed(() => laserListForUi.value)
|
||||
const cncDevices = computed(() => mqttRuntime.devices.filter(d => d.type === 'cnc'))
|
||||
const powerDevices = computed(() => mqttRuntime.devices.filter(d => d.type === 'power'))
|
||||
|
||||
// 周报表
|
||||
const { labels: weeklyLabels, todayIdx } = getWeeklyInfo()
|
||||
// 左侧柱图横轴:近 7 日(含今天);最后一根高亮为今天(todayIdx === 6)
|
||||
const { labels: weeklyLabels, todayIdx } = getLast7DaysChartInfo()
|
||||
|
||||
/**
|
||||
* 各设备 `weeklyStats.produce` 按索引 0…6 与上面对齐。
|
||||
* 注意:B/C 若 MQTT 上游仍按「自然周」传 7 个数,与近 7 日日历可能错位,宜在采集端改为按日或滚动窗口。
|
||||
*/
|
||||
const weeklyProduceTotal = computed(() => {
|
||||
const totals = [0, 0, 0, 0, 0, 0, 0]
|
||||
mqttRuntime.devices.forEach(d => {
|
||||
overviewDevices.value.forEach((d) => {
|
||||
if (d.weeklyStats?.produce) {
|
||||
d.weeklyStats.produce.forEach((v, i) => {
|
||||
if (i <= todayIdx) totals[i] += v
|
||||
@@ -113,7 +137,7 @@ const weeklyProduceTotal = computed(() => {
|
||||
const alarms = computed(() => {
|
||||
const arr = []
|
||||
const now = new Date()
|
||||
mqttRuntime.devices.forEach(d => {
|
||||
overviewDevices.value.forEach(d => {
|
||||
if (!d.online || !d.machineData) return
|
||||
const status = getDeviceStatus(d)
|
||||
if (status.key !== 'alarm') return
|
||||
|
||||
Reference in new issue
Block a user