import { statisticscontrollerRestocking } from '@/servers/api/statistics'; import { ActionType, PageContainer, ProColumns, ProFormDigit, ProFormText, ProTable, } from '@ant-design/pro-components'; import dayjs from 'dayjs'; import { useMemo, useRef, useState } from 'react'; const ListPage: React.FC = () => { const actionRef = useRef(); const [count, setCount] = useState(4); const history = useMemo( () => Array.from({ length: Math.min(!!count ? count : 5, 10) }).map((_, i) => { if (dayjs().date() > 20) i++; return dayjs().add(i, 'month').format('YYYY-MM'); }), [count], ); const [savety, setSavety] = useState({}); const columns: ProColumns[] = [ { title: '产品名称', dataIndex: 'productName', }, { title: '30天销量', dataIndex: 'last30DaysSales', hideInSearch: true, }, { title: '2*15天销量', dataIndex: 'last15DaysSales', hideInSearch: true, render(_, record) { return 2 * record.last15DaysSales; }, }, { title: '库存', dataIndex: 'totalStock', hideInSearch: true, }, ...history.map((v, i) => ({ title: v, onCell: () => ({ style: { padding: 0 } }), align: 'center' as any, hideInSearch: true, render(_, record) { const base = record.lastMonthSales; return (
{base}
{base}
{base}
); }, })), { title: '安全补充系数', hideInSearch: true, render(_, record) { return ( ); }, }, { title: '', hideInSearch: true, render(_, record) { const base = record.lastMonthSales; return (
{count * base}
{2 * count * base}
); }, }, { title: '合计', hideInSearch: true, render(_, record) { const base = record.lastMonthSales; return 3 * count * base + (savety[record.productSku] || 0); }, }, { title: '修正数', hideInSearch: true, render(_, record) { const base = record.lastMonthSales; return ( ); }, }, ]; return ( { const { data, success } = await statisticscontrollerRestocking(param); if (success) { return { total: data?.total || 0, data: data?.items || [], }; } return { data: [], }; }} columns={columns} dateFormatter="number" toolBarRender={() => [ setCount(e.target.value), value: count, }} />, ]} /> ); }; export default ListPage;