import { ordercontrollerGetordersales } from '@/servers/api/order'; import { sitecontrollerAll } from '@/servers/api/site'; import { ActionType, PageContainer, ProColumns, ProFormSwitch, ProTable, } from '@ant-design/pro-components'; import { Button } from 'antd'; import dayjs from 'dayjs'; import { saveAs } from 'file-saver'; import { useRef, useState } from 'react'; import * as XLSX from 'xlsx'; const ListPage: React.FC = () => { const actionRef = useRef(); const formRef = useRef(); const [total, setTotal] = useState(0); const [isSource, setIsSource] = useState(false); const [yooneTotal, setYooneTotal] = useState({}); const columns: ProColumns[] = [ { title: '时间段', dataIndex: 'dateRange', valueType: 'dateTimeRange', hideInTable: true, formItemProps: { rules: [ { required: true, message: '请选择时间段', }, ], }, }, { title: '排除套装', dataIndex: 'exceptPackage', valueType: 'switch', hideInTable: true, }, { title: '产品名称', dataIndex: 'name', }, { title: '站点', dataIndex: 'siteId', valueType: 'select', request: async () => { const { data = [] } = await sitecontrollerAll(); return data.map((item) => ({ label: item.siteName, value: item.id, })); }, hideInTable: true, }, // { // title: '分类', // dataIndex: 'categoryName', // hideInSearch: true, // hideInTable: isSource, // }, { title: '数量', dataIndex: 'totalQuantity', hideInSearch: true, }, { title: '一单订单数', dataIndex: 'firstOrderCount', hideInSearch: true, render(_, record) { if (isSource) return record.firstOrderCount; return `${record.firstOrderCount}(${record.firstOrderYOONEBoxCount})`; }, }, { title: '两单订单数', dataIndex: 'secondOrderCount', hideInSearch: true, render(_, record) { if (isSource) return record.secondOrderCount; return `${record.secondOrderCount}(${record.secondOrderYOONEBoxCount})`; }, }, { title: '三单订单数', dataIndex: 'thirdOrderCount', hideInSearch: true, render(_, record) { if (isSource) return record.thirdOrderCount; return `${record.thirdOrderCount}(${record.thirdOrderYOONEBoxCount})`; }, }, { title: '三单以上订单数', dataIndex: 'moreThirdOrderCount', hideInSearch: true, render(_, record) { if (isSource) return record.moreThirdOrderCount; return `${record.moreThirdOrderCount}(${record.moreThirdOrderYOONEBoxCount})`; }, }, { title: '订单数', dataIndex: 'totalOrders', hideInSearch: true, }, ]; return ( { const [startDate, endDate] = dateRange.values(); const { data, success } = await ordercontrollerGetordersales({ startDate, endDate, ...param, }); if (success) { setTotal(data?.totalQuantity || 0); setYooneTotal({ yoone3Quantity: data?.yoone3Quantity || 0, yoone6Quantity: data?.yoone6Quantity || 0, yoone9Quantity: data?.yoone9Quantity || 0, yoone12Quantity: data?.yoone12Quantity || 0, yoone12QuantityNew: data?.yoone12QuantityNew || 0, yoone15Quantity: data?.yoone15Quantity || 0, yoone18Quantity: data?.yoone18Quantity || 0, zexQuantity: data?.zexQuantity || 0, }); return { total: data?.total || 0, data: data?.items || [], }; } setTotal(0); setYooneTotal({}); return { data: [], }; }} columns={columns} dateFormatter="number" footer={() => `总计: ${total}`} toolBarRender={() => [ , setIsSource(!isSource), }} />, ]} />
YOONE:{' '} {(yooneTotal.yoone3Quantity || 0) + (yooneTotal.yoone6Quantity || 0) + (yooneTotal.yoone9Quantity || 0) + (yooneTotal.yoone12Quantity || 0) + (yooneTotal.yoone15Quantity || 0) + (yooneTotal.yoone18Quantity || 0) + (yooneTotal.zexQuantity || 0) }
YOONE 3MG: {yooneTotal.yoone3Quantity || 0}
YOONE 6MG: {yooneTotal.yoone6Quantity || 0}
YOONE 9MG: {yooneTotal.yoone9Quantity || 0}
YOONE 12MG新: {yooneTotal.yoone12QuantityNew || 0}
YOONE 12MG白: {(yooneTotal.yoone12Quantity || 0) - (yooneTotal.yoone12QuantityNew || 0)}
YOONE 15MG: {yooneTotal.yoone15Quantity || 0}
YOONE 18MG: {yooneTotal.yoone18Quantity || 0}
ZEX: {yooneTotal.zexQuantity || 0}
); }; export default ListPage;