import React, { useEffect, useState } from 'react'; import { PageContainer } from '@ant-design/pro-components'; import { Card, Col, Row, Spin } from 'antd'; import { ShoppingOutlined, InboxOutlined, DatabaseOutlined, DollarOutlined, RiseOutlined, } from '@ant-design/icons'; import { getStockSummary } from '@/services/api'; import type { StockSummary } from '@/types/api'; interface StatCardProps { icon: React.ReactNode; title: string; value: string | number; suffix?: string; prefix?: string; gradient?: boolean; } const StatCard: React.FC = ({ icon, title, value, suffix, prefix, gradient }) => (
{icon}
{title}
{prefix}{typeof value === 'number' ? value.toLocaleString() : value} {suffix && ( {suffix} )}
); const DashboardPage: React.FC = () => { const [summary, setSummary] = useState(null); const [loading, setLoading] = useState(true); useEffect(() => { getStockSummary() .then((res) => { if (res?.code === 0) setSummary(res.data); }) .finally(() => setLoading(false)); }, []); if (loading) { return (
); } return ( 数据总览 ), }} > } title="产品总数" value={summary?.productCount ?? 0} suffix="种" gradient /> } title="总匹数" value={summary?.totalPieces ?? 0} suffix="匹" /> } title="总盘数" value={summary?.totalRolls ?? 0} suffix="盘" /> } title="库存总值(成本)" value={summary?.totalCostValue ?? '0.00'} prefix="¥" /> } title="库存总值(销售)" value={summary?.totalSalesValue ?? '0.00'} prefix="¥" /> {/* Quick navigation section */}
快捷入口
{[ { title: '产品档案', desc: '管理产品信息', path: '/inventory/products', icon: }, { title: '库存查询', desc: '实时库存数据', path: '/inventory/stocks', icon: }, { title: '库存统计', desc: '分类统计分析', path: '/inventory/stats', icon: }, { title: 'Excel导入', desc: '批量导入产品', path: '/inventory/import', icon: }, ].map((item) => ( window.location.assign(item.path)} >
{item.icon}
{item.title}
{item.desc}
))}
); }; export default DashboardPage;