import React, { useState, useEffect } from 'react'; import { Table, Button, Input, Select, message, Card } from 'antd'; import { PlusOutlined, EditOutlined, DeleteOutlined, SearchOutlined, UserOutlined, PhoneOutlined, MailOutlined, HomeOutlined } from '@ant-design/icons'; import { useNavigate } from 'react-router-dom'; import { suppliersDataSource, Supplier } from '@/services/suppliersDataSource'; const { Option } = Select; const { Search } = Input; const Suppliers: React.FC = () => { const navigate = useNavigate(); const [suppliers, setSuppliers] = useState([]); const [loading, setLoading] = useState(false); const [filters, setFilters] = useState({ category: '', status: '', search: '', }); useEffect(() => { fetchSuppliers(); }, [filters]); const fetchSuppliers = async () => { setLoading(true); try { const data = await suppliersDataSource.fetchSuppliers(); setSuppliers(data); } catch (error) { message.error('Failed to load suppliers'); } finally { setLoading(false); } }; const handleAddSupplier = () => { message.info('添加供应商功能开发中'); }; const handleEditSupplier = (id: string) => { navigate(`/suppliers/${id}`); }; const handleDeleteSupplier = (id: string) => { message.success('供应商已删除'); fetchSuppliers(); }; const columns = [ { title: '供应商名称', dataIndex: 'name', key: 'name', }, { title: '联系人', dataIndex: 'contactName', key: 'contactName', }, { title: '邮箱', dataIndex: 'email', key: 'email', }, { title: '电话', dataIndex: 'phone', key: 'phone', }, { title: '类别', dataIndex: 'category', key: 'category', }, { title: '状态', dataIndex: 'status', key: 'status', render: (status: string) => { const statusMap: Record = { active: '活跃', inactive: '非活跃', pending: '待审核', }; return statusMap[status] || status; }, }, { title: '评分', dataIndex: 'rating', key: 'rating', }, { title: '交货期(天)', dataIndex: 'leadTime', key: 'leadTime', }, { title: '最小订单量', dataIndex: 'minOrder', key: 'minOrder', }, { title: '操作', key: 'action', render: (_: any, record: Supplier) => (
), }, ]; return (

供应商管理

setFilters({ ...filters, search: e.target.value })} />
); }; export default Suppliers;