import React, { useEffect, useState } from 'react'; import { Table, Form, Select, Button, message, Space } from 'antd'; import { SearchOutlined, DeleteOutlined } from '@ant-design/icons'; import type { ColumnsType } from 'antd/es/table'; //接口 import { getApprovePage } from './services'; //组件 import ViewModal from './components/ViewModal'; //统一列表分页 import tableProps from '@/utils/tableProps' const { Option } = Select; interface SupplierEntryReviewRecord { id: string; accessWorkName: string; // 准入工作 deptId: string; // 准入部门ID accessTypeText: string; // 准入方式 reviewStatusText: string; // 流程状态 categoryName: string; // 品类名称 startTime: string; // 申请时间 endTime: string; createTime: string; // 创建时间 updateTime: string; // 更新时间 [key: string]: any; // 允许有其它字段 } interface ModalInfo { visible: boolean; record: string | null; } const deptOptions = [ { label: '全部', value: '' }, { label: '采购部', value: 'DEPT001' }, { label: '业务部', value: 'DEPT002' }, ]; const SupplierEntryReview: React.FC = () => { const [form] = Form.useForm(); const [data, setData] = useState([]); const [pagination, setPagination] = useState({ current: 1, pageSize: 10, total: 0 }); const [loading, setLoading] = useState(false); const [modalInfo, setModalInfo] = useState({ visible: false, record: null }); // 查询数据 const fetchData = async (params = {}) => { setLoading(true); try { const res = await getApprovePage({ pageNo: pagination.current, pageSize: pagination.pageSize, ...form.getFieldsValue(), ...params, }); if (res.code === 200) { setData(res.data.records); setPagination({ ...pagination, current: res.data.current, total: res.data.total, pageSize: res.data.size, }); } else { setData([]); setPagination({ ...pagination, total: 0 }); } } catch (err) { message.error('获取数据失败'); } finally { setLoading(false); } }; useEffect(() => { fetchData({ pageNo: 1 }); }, []); // 表格分页切换 const handleTableChange = (pag: any) => { setPagination({ ...pagination, current: pag.current, pageSize: pag.pageSize, }); fetchData({ pageNo: pag.current, pageSize: pag.pageSize, }); }; // 搜索 const handleSearch = () => { setPagination({ ...pagination, current: 1 }); fetchData({ pageNo: 1 }); }; // 重置 const handleReset = () => { form.resetFields(); setPagination({ ...pagination, current: 1 }); fetchData({ pageNo: 1 }); }; const openModal = (record: string) => { setModalInfo({ visible: true, record }); }; const closeModal = () => { setModalInfo({ visible: false, record: null }); }; const columns: ColumnsType = [ { title: '序号', dataIndex: 'index', width: 60, align: 'center', render: (_: any, __: any, idx: number) => (((pagination.current ?? 1) - 1) * (pagination.pageSize ?? 10)) + idx + 1, }, { title: '准入工作', dataIndex: 'accessWorkName', align: 'center', ellipsis: true, width: 120, }, { title: '准入部门', dataIndex: 'deptId', align: 'center', width: 120, }, { title: '准入方式', dataIndex: 'accessTypeText', align: 'center', ellipsis: true, width: 120, }, { title: '准入品类', dataIndex: 'categoryNameList', width: 120, align: 'center', render: (_: any, record: any) => { return ( <> {record.categoryNameList && record.categoryNameList.map((item: string) => { return
{`${item}`}
})} ) }, }, { title: '开始时间', dataIndex: 'createTime', align: 'center', ellipsis: true, width: 180, }, { title: '结束时间', dataIndex: 'lastUpdateTime', align: 'center', ellipsis: true, width: 180, }, { title: '流程状态', dataIndex: 'reviewStatusText', align: 'center', width: 120, }, { title: '审核', dataIndex: 'approveStatusText', align: 'center', width: 120, }, { title: '操作', width: 120, fixed: 'right', render: (_: any, record: any) => { return ( openModal(record.id)}>查看 ) }, }, ]; return (
); }; export default SupplierEntryReview;