/** * 柜子卡片网格组件 * - 展示柜子列表(卡片形式) * - 点击跳转到柜子详情 */ import { useNavigate } from 'react-router-dom'; import { Card, Grid, Tag, Spin, Empty, } from '@arco-design/web-react'; import { IconDesktop } from '@arco-design/web-react/icon'; import type { Cabinet } from '@/api/devices'; const Row = Grid.Row; const Col = Grid.Col; /** 柜子状态映射 */ const STATUS_MAP: Record = { 0: { label: '离线', color: 'gray' }, 1: { label: '在线', color: 'green' }, 2: { label: '充电中', color: 'blue' }, 3: { label: '故障', color: 'red' }, }; interface CabinetGridProps { cabinets: Cabinet[]; loading: boolean; } export default function CabinetGrid({ cabinets, loading }: CabinetGridProps) { const navigate = useNavigate(); return ( <> {loading ? (
) : cabinets.length === 0 ? ( ) : ( {cabinets.map((cab) => { const st = STATUS_MAP[cab.status] || { label: '未知', color: 'gray' }; return ( navigate(`/devices/cabinet/${cab.id}`)} style={{ cursor: 'pointer' }} >
{cab.abstract_id}
{cab.name || cab.imei}
{st.label}
); })}
)} ); }