diff --git a/software/api-server/src/routes/cabinets.rs b/software/api-server/src/routes/cabinets.rs index ba7439a..119eb70 100644 --- a/software/api-server/src/routes/cabinets.rs +++ b/software/api-server/src/routes/cabinets.rs @@ -346,6 +346,10 @@ pub struct CabinetOption { pub id: i64, pub name: Option, pub abstract_id: String, + pub imei: Option, + pub iccid: Option, + pub address: Option, + pub status: i8, } /// 仓板下拉选项 @@ -372,14 +376,14 @@ pub async fn list_cabinet_options( let rows = if let Some(pid) = params.project_id { sqlx::query_as::<_, CabinetOption>( - "SELECT id, name, abstract_id FROM cabinets WHERE project_id = ? ORDER BY id" + "SELECT id, name, abstract_id, imei, iccid, address, status FROM cabinets WHERE project_id = ? ORDER BY id" ) .bind(pid) .fetch_all(&state.mysql) .await? } else { sqlx::query_as::<_, CabinetOption>( - "SELECT id, name, abstract_id FROM cabinets ORDER BY id" + "SELECT id, name, abstract_id, imei, iccid, address, status FROM cabinets ORDER BY id" ) .fetch_all(&state.mysql) .await? diff --git a/software/web/src/api/devices.ts b/software/web/src/api/devices.ts index 8c5d9b8..d0516d2 100644 --- a/software/web/src/api/devices.ts +++ b/software/web/src/api/devices.ts @@ -20,6 +20,7 @@ export interface Cabinet { project_id?: number; abstract_id: string; imei: string; + iccid?: string; auth_str?: string; name?: string; address?: string; diff --git a/software/web/src/pages/devices/CabinetGrid.tsx b/software/web/src/pages/devices/CabinetGrid.tsx index 8ae88c8..64a56de 100644 --- a/software/web/src/pages/devices/CabinetGrid.tsx +++ b/software/web/src/pages/devices/CabinetGrid.tsx @@ -10,15 +10,15 @@ import { Spin, Empty, } from '@arco-design/web-react'; -import { IconLocation } from '@arco-design/web-react/icon'; +import { IconLocation, IconPoweroff, IconCheckCircle, IconInfoCircle } from '@arco-design/web-react/icon'; import type { Cabinet } from '@/api/devices'; /** 柜子状态映射 */ -const STATUS_MAP: Record = { - 0: { label: '离线', color: 'gray' }, - 1: { label: '在线', color: 'green' }, - 2: { label: '充电中', color: 'blue' }, - 3: { label: '故障', color: 'red' }, +const STATUS_MAP: Record = { + 0: { label: '离线', color: 'gray', icon: }, + 1: { label: '在线', color: 'green', icon: }, + 2: { label: '充电中', color: 'blue', icon: }, + 3: { label: '故障', color: 'red', icon: }, }; interface CabinetGridProps { @@ -38,7 +38,7 @@ export default function CabinetGrid({ cabinets, loading }: CabinetGridProps) { ) : (
{cabinets.map((cab) => { - const st = STATUS_MAP[cab.status] || { label: '未知', color: 'gray' }; + const st = STATUS_MAP[cab.status] || { label: '未知', color: 'gray', icon: }; return (
- {/* 标题行 */} + {/* 标题行:名称 + 状态图标 */}
- {cab.name || cab.abstract_id} - {st.label} + + {cab.name || cab.abstract_id} + +
+ {st.icon} + {st.label} +
- {/* 信息网格 */} -
-
IMEI: {cab.imei?.slice(-6) || '-'}
-
绑定码: {cab.auth_str || '-'}
-
柜板: 6
-
通道: 36
+ {/* IMEI 和 ICCID */} +
+
IMEI: {cab.imei || '-'}
+
ICCID: {cab.iccid || '-'}
{/* 通道状态 */} @@ -72,7 +75,7 @@ export default function CabinetGrid({ cabinets, loading }: CabinetGridProps) { {/* 地址 */} {cab.address && (
- + {cab.address}
)}