From 4c287ca69094658634b9e31021157c629eb17539 Mon Sep 17 00:00:00 2001 From: 16337 <1633794139@qq.com> Date: Wed, 18 Mar 2026 17:31:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=80=A7=E8=83=BD=EF=BC=9A=E7=9C=8B=E6=9D=BF?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E5=8D=95=E6=AC=A1=E8=AF=B7=E6=B1=82=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=EF=BC=8C=E4=BB=8E5=E4=B8=AA=E5=B9=B6=E5=8F=91?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=E4=BC=98=E5=8C=96=E4=B8=BA1=E4=B8=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.6 (1M context) --- apps/web-antd/src/api/aiot/alarm/index.ts | 17 ++++++++++++ .../src/views/aiot/alarm/summary/index.vue | 26 ++++++------------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/apps/web-antd/src/api/aiot/alarm/index.ts b/apps/web-antd/src/api/aiot/alarm/index.ts index c31650774..8822e6a94 100644 --- a/apps/web-antd/src/api/aiot/alarm/index.ts +++ b/apps/web-antd/src/api/aiot/alarm/index.ts @@ -98,6 +98,15 @@ export namespace AiotAlarmApi { hour: number; count: number; } + + /** 看板聚合数据 */ + export interface DashboardData { + statistics: AlertStatistics; + trend: TrendItem[]; + deviceTop: DeviceTopItem[]; + hourDistribution: HourDistItem[]; + recentAlerts: Alert[]; + } } // ==================== 告警管理 API ==================== @@ -133,6 +142,14 @@ export function deleteAlert(id: number | string) { return requestClient.delete(`/aiot/alarm/alert/delete?id=${id}`); } +/** 获取看板聚合数据(单次请求) */ +export function getAlertDashboard(trendDays: number = 7) { + return requestClient.get( + '/aiot/alarm/alert/dashboard', + { params: { trendDays } }, + ); +} + /** 获取告警统计 */ export function getAlertStatistics(startTime?: string, endTime?: string) { return requestClient.get( diff --git a/apps/web-antd/src/views/aiot/alarm/summary/index.vue b/apps/web-antd/src/views/aiot/alarm/summary/index.vue index e3551d44d..9ac2bc705 100644 --- a/apps/web-antd/src/views/aiot/alarm/summary/index.vue +++ b/apps/web-antd/src/views/aiot/alarm/summary/index.vue @@ -23,11 +23,8 @@ import { } from 'ant-design-vue'; import { - getAlertDeviceTop, - getAlertHourDistribution, - getAlertStatistics, + getAlertDashboard, getAlertTrend, - getRecentAlerts, } from '#/api/aiot/alarm'; import { @@ -94,23 +91,16 @@ const STATUS_NAMES: Record = { ignored: '已忽略', }; -/** 加载全部数据 */ +/** 加载全部数据(单次请求) */ async function loadAll() { loading.value = true; try { - const [statsRes, trendRes, deviceRes, hourRes, alertsRes] = - await Promise.all([ - getAlertStatistics(), - getAlertTrend(trendDays.value), - getAlertDeviceTop(10, 7), - getAlertHourDistribution(7), - getRecentAlerts(10), - ]); - stats.value = statsRes; - trendData.value = trendRes; - deviceTopData.value = deviceRes; - hourDistData.value = hourRes; - recentAlerts.value = alertsRes?.list || []; + const data = await getAlertDashboard(trendDays.value); + stats.value = data.statistics; + trendData.value = data.trend; + deviceTopData.value = data.deviceTop; + hourDistData.value = data.hourDistribution; + recentAlerts.value = data.recentAlerts || []; } finally { loading.value = false; await nextTick();