diff --git a/apps/web-antd/src/api/aiot/edge/index.ts b/apps/web-antd/src/api/aiot/edge/index.ts index 3abc1091d..aa3169355 100644 --- a/apps/web-antd/src/api/aiot/edge/index.ts +++ b/apps/web-antd/src/api/aiot/edge/index.ts @@ -31,26 +31,34 @@ export namespace AiotEdgeApi { } // ==================== 边缘设备 API ==================== +// 数据源:WVP 数据库 wvp_ai_edge_device 表 +// 路径经 vite proxy: /admin-api/aiot/device/* → rewrite → /api/ai/* → WVP:18080 + +/** 获取全部边缘设备列表 */ +export function getDeviceList() { + return wvpRequestClient.get( + '/aiot/device/device/list', + ); +} /** 分页查询边缘设备列表 */ export function getDevicePage(params: PageParam) { return wvpRequestClient.get>( - '/api/ai/device/page', + '/aiot/device/device/page', { params }, ); } /** 获取设备详情 */ export function getDevice(deviceId: string) { - return wvpRequestClient.get( - '/api/ai/device/get', - { params: { deviceId } }, - ); + return wvpRequestClient.get('/aiot/device/device/get', { + params: { deviceId }, + }); } /** 获取设备统计 */ export function getDeviceStatistics() { return wvpRequestClient.get( - '/api/ai/device/statistics', + '/aiot/device/device/statistics', ); } diff --git a/apps/web-antd/src/views/aiot/edge/node/data.ts b/apps/web-antd/src/views/aiot/edge/node/data.ts index a9c352b58..148103876 100644 --- a/apps/web-antd/src/views/aiot/edge/node/data.ts +++ b/apps/web-antd/src/views/aiot/edge/node/data.ts @@ -1,77 +1,16 @@ -import type { VbenFormSchema } from '#/adapter/form'; -import type { VxeTableGridOptions } from '#/adapter/vxe-table'; +/** 设备状态配置 */ +export const STATUS_CONFIG: Record = { + online: { color: 'success', label: '在线' }, + offline: { color: 'default', label: '离线' }, +}; -/** 设备状态选项 */ -export const DEVICE_STATUS_OPTIONS = [ - { label: '在线', value: 'online' }, - { label: '离线', value: 'offline' }, - { label: '异常', value: 'error' }, -]; - -/** 边缘设备搜索表单 */ -export function useEdgeGridFormSchema(): VbenFormSchema[] { - return [ - { - fieldName: 'status', - label: '设备状态', - component: 'Select', - componentProps: { - options: DEVICE_STATUS_OPTIONS, - placeholder: '请选择设备状态', - allowClear: true, - }, - }, - ]; -} - -/** 边缘设备列表字段 */ -export function useEdgeGridColumns(): VxeTableGridOptions['columns'] { - return [ - { - field: 'deviceId', - title: '设备ID', - minWidth: 160, - }, - { - field: 'deviceName', - title: '设备名称', - minWidth: 150, - }, - { - field: 'status', - title: '状态', - minWidth: 90, - slots: { default: 'status' }, - }, - { - field: 'lastHeartbeat', - title: '最后心跳', - minWidth: 170, - formatter: 'formatDateTime', - }, - { - field: 'uptimeSeconds', - title: '运行时长', - minWidth: 100, - slots: { default: 'uptime' }, - }, - { - field: 'framesProcessed', - title: '处理帧数', - minWidth: 100, - slots: { default: 'frames' }, - }, - { - field: 'alertsGenerated', - title: '告警数', - minWidth: 90, - slots: { default: 'alerts' }, - }, - { - field: 'updatedAt', - title: '更新时间', - minWidth: 170, - formatter: 'formatDateTime', - }, - ]; +/** 格式化运行时长 */ +export function formatUptime(seconds?: number): string { + if (seconds == null) return '-'; + const d = Math.floor(seconds / 86400); + const h = Math.floor((seconds % 86400) / 3600); + const m = Math.floor((seconds % 3600) / 60); + if (d > 0) return `${d}天 ${h}小时`; + if (h > 0) return `${h}小时 ${m}分钟`; + return `${m}分钟`; } diff --git a/apps/web-antd/src/views/aiot/edge/node/index.vue b/apps/web-antd/src/views/aiot/edge/node/index.vue index 7eed61c47..47626fc1e 100644 --- a/apps/web-antd/src/views/aiot/edge/node/index.vue +++ b/apps/web-antd/src/views/aiot/edge/node/index.vue @@ -1,92 +1,134 @@ + +