import React from 'react'; import { Card, Typography, Table, Statistic, Row, Col, Tag } from 'antd'; import { DollarOutlined, FileTextOutlined, CheckCircleOutlined } from '@ant-design/icons'; const { Title, Paragraph } = Typography; const FinancePage: React.FC = () => { // 统计数据 - 从API获取真实数据 const [stats, setStats] = React.useState([ { title: '本月总收入', value: 0, prefix: '¥', icon: , trend: '', color: '#3f8600', }, { title: '本月总支出', value: 0, prefix: '¥', icon: , trend: '', color: '#cf1322', }, { title: '待审批报销', value: 0, prefix: '¥', icon: , trend: '', color: '#1890ff', }, ]); // 财务记录数据 - 从API获取真实数据 const [dataSource, setDataSource] = React.useState([]); // 从API获取财务数据 React.useEffect(() => { // 这里可以添加从API获取真实数据的逻辑 // 例如:fetch('/api/finance-stats') 等 }, []); // 桌面端表格列 const desktopColumns = [ { title: '日期', dataIndex: 'date', key: 'date', sorter: (a: any, b: any) => a.date.localeCompare(b.date), }, { title: '类型', dataIndex: 'type', key: 'type', render: (type: string) => ( {type === '收入' ? '↑ 收入' : '↓ 支出'} ), }, { title: '类别', dataIndex: 'category', key: 'category', }, { title: '项目', dataIndex: 'project', key: 'project', }, { title: '金额', dataIndex: 'amount', key: 'amount', render: (amount: number) => `¥${amount.toLocaleString()}`, sorter: (a: any, b: any) => a.amount - b.amount, }, { title: '状态', dataIndex: 'status', key: 'status', render: (status: string) => { const colorMap: Record = { '已入账': 'green', '已付款': 'blue', '处理中': 'orange', }; return {status}; }, }, ]; // 移动端简化表格列 const mobileColumns = [ { title: '日期', dataIndex: 'date', key: 'date', width: 100, }, { title: '类型', dataIndex: 'type', key: 'type', width: 60, render: (type: string) => ( {type === '收入' ? '↑' : '↓'} ), }, { title: '金额', dataIndex: 'amount', key: 'amount', render: (amount: number) => (
¥{amount.toLocaleString()}
), }, { title: '状态', dataIndex: 'status', key: 'status', render: (status: string) => ( {status} ), }, ]; const [isMobile, setIsMobile] = React.useState(false); React.useEffect(() => { const checkMobile = () => { setIsMobile(window.innerWidth <= 768); }; checkMobile(); window.addEventListener('resize', checkMobile); return () => window.removeEventListener('resize', checkMobile); }, []); return (
财务管理 查看公司财务状况、收支明细
{/* 统计卡片 - 移动端优化 */} {stats.map((stat, index) => ( {stat.title}} value={stat.value} prefix={stat.prefix} suffix={stat.trend} valueStyle={{ color: stat.color, fontSize: isMobile ? 18 : undefined }} /> ))} {/* 财务明细表 */} ); }; export default FinancePage;