import React, { useCallback } from 'react'; import { Card, Typography, Button, Table, Tag, Space, Modal, Form, Input, Select, DatePicker, InputNumber, message, Row, Col, Statistic } from 'antd'; import { PlusOutlined, SearchOutlined, ShoppingOutlined } from '@ant-design/icons'; import useFormDraft from '../hooks/useFormDraft'; const { Title, Paragraph } = Typography; const { RangePicker } = DatePicker; const ProcurementPage: React.FC = () => { const [loading, setLoading] = React.useState(false); const [modalVisible, setModalVisible] = React.useState(false); const [form] = Form.useForm(); // 表单草稿保护 const { save: saveDraft, restore: restoreDraft, clear: clearDraft, hasDraft } = useFormDraft({ form, storageKey: 'procurement_create', }) const handleFormChange = useCallback(() => { saveDraft() }, [saveDraft]) const columns = [ { title: '采购单号', dataIndex: 'code', key: 'code', width: 140 }, { title: '采购日期', dataIndex: 'date', key: 'date', width: 120 }, { title: '供应商', dataIndex: 'supplier', key: 'supplier' }, { title: '物料名称', dataIndex: 'material', key: 'material' }, { title: '数量', dataIndex: 'quantity', key: 'quantity', width: 80 }, { title: '单价', dataIndex: 'unitPrice', key: 'unitPrice', width: 100, render: (v: number) => `¥${v}` }, { title: '总金额', dataIndex: 'amount', key: 'amount', width: 120, render: (v: number) => `¥${v?.toLocaleString()}` }, { title: '状态', dataIndex: 'status', key: 'status', width: 100, render: (v: string) => { const colors: Record = { pending: 'default', approved: 'processing', received: 'success', rejected: 'error' }; const texts: Record = { pending: '待审批', approved: '已批准', received: '已入库', rejected: '已拒绝' }; return {texts[v]}; } }, { title: '操作', key: 'action', width: 150, render: () => ( ) } ]; const data = [ { key: '1', code: 'PO20260318001', date: '2026-03-18', supplier: '老挝电力设备公司', material: '电缆 3x120', quantity: 1000, unitPrice: 45, amount: 45000, status: 'pending' }, { key: '2', code: 'PO20260317002', date: '2026-03-17', supplier: '万象建材供应商', material: '钢管 DN50', quantity: 200, unitPrice: 120, amount: 24000, status: 'approved' }, { key: '3', code: 'PO20260316003', date: '2026-03-16', supplier: '沙湾五金店', material: '螺栓 M12', quantity: 500, unitPrice: 5, amount: 2500, status: 'received' }, ]; const handleSubmit = () => { message.success('采购申请已提交'); clearDraft() setModalVisible(false); }; return (
采购管理 管理采购订单和物料入库
} /> { if (form.isFieldsTouched()) { Modal.confirm({ title: '确认关闭', content: '表单数据尚未保存,关闭后可通过草稿恢复。确定关闭吗?', okText: '关闭', cancelText: '继续编辑', onOk: () => { saveDraft() setModalVisible(false) }, }) } else { setModalVisible(false) } }} onOk={handleSubmit} width={600} maskClosable={false} >
); }; export default ProcurementPage;