47 lines
1.6 KiB
TypeScript
Raw Normal View History

import { PlusOutlined } from '@ant-design/icons';
import { ProColumns, ProTable } from '@ant-design/pro-components';
import { Button, Tag } from 'antd';
import { listStockChecks } from '@/services/api';
import type { StockCheck } from '@/types/api';
const STATUS_MAP: Record<number, { text: string; color: string }> = {
0: { text: '草稿', color: 'default' },
1: { text: '进行中', color: 'processing' },
2: { text: '已完成', color: 'success' },
};
const columns: ProColumns<StockCheck>[] = [
{ title: '盘点单号', dataIndex: 'checkNo' },
{ title: '盘点日期', dataIndex: 'checkDate', valueType: 'date', search: false },
{ title: '盘点人', dataIndex: 'checker', search: false },
{
title: '状态',
dataIndex: 'status',
search: false,
render: (_, record) => {
const s = STATUS_MAP[record.status] ?? STATUS_MAP[0];
return <Tag color={s.color}>{s.text}</Tag>;
},
},
{ title: '创建时间', dataIndex: 'createdAt', valueType: 'dateTime', search: false },
{ title: '操作', valueType: 'option', render: () => [<a key="view"></a>] },
];
const ChecksPage: React.FC = () => (
<ProTable<StockCheck>
headerTitle="库存盘点"
rowKey="checkId"
columns={columns}
search={false}
request={async (params) => {
const res = await listStockChecks({ page: params.current, pageSize: params.pageSize });
return { data: res?.data?.list || [], total: res?.data?.total || 0, success: res?.code === 0 };
}}
toolBarRender={() => [
<Button key="add" type="primary" icon={<PlusOutlined />}></Button>,
]}
/>
);
export default ChecksPage;