2025-06-24 16:48:10 +08:00
|
|
|
import React, { useEffect, useState } from 'react';
|
2025-06-27 10:41:33 +08:00
|
|
|
import { Table, Form, Select, Button, Tag, message, Space } from 'antd';
|
2025-06-24 10:52:30 +08:00
|
|
|
import { SearchOutlined, ReloadOutlined } from '@ant-design/icons';
|
2025-06-24 16:48:10 +08:00
|
|
|
import { getApprovePage } from './services';
|
|
|
|
import type { ColumnsType } from 'antd/es/table';
|
2025-06-27 10:41:33 +08:00
|
|
|
import ViewModal from './components/ViewModal';
|
2025-07-02 16:18:03 +08:00
|
|
|
const { Option } = Select;
|
2025-06-24 16:48:10 +08:00
|
|
|
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; // 允许有其它字段
|
|
|
|
}
|
2025-07-02 16:18:03 +08:00
|
|
|
|
2025-06-27 10:41:33 +08:00
|
|
|
interface ModalInfo {
|
|
|
|
visible: boolean;
|
|
|
|
record: string | null;
|
|
|
|
}
|
2025-06-24 10:52:30 +08:00
|
|
|
|
|
|
|
|
2025-06-24 16:48:10 +08:00
|
|
|
const deptOptions = [
|
|
|
|
{ label: '全部', value: '' },
|
|
|
|
{ label: '采购部', value: 'DEPT001' },
|
|
|
|
{ label: '业务部', value: 'DEPT002' },
|
|
|
|
];
|
|
|
|
|
2025-06-24 10:52:30 +08:00
|
|
|
|
|
|
|
const SupplierEntryReview: React.FC = () => {
|
2025-06-24 16:48:10 +08:00
|
|
|
const [form] = Form.useForm();
|
|
|
|
const [data, setData] = useState<any[]>([]);
|
|
|
|
const [pagination, setPagination] = useState({ current: 1, pageSize: 10, total: 0 });
|
|
|
|
const [loading, setLoading] = useState(false);
|
2025-07-02 16:18:03 +08:00
|
|
|
const [modalInfo, setModalInfo] = useState<ModalInfo>({ visible: false, record: null });
|
2025-06-24 16:48:10 +08:00
|
|
|
// 查询数据
|
|
|
|
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 });
|
|
|
|
};
|
2025-06-27 10:41:33 +08:00
|
|
|
const openModal = (record: string) => {
|
2025-07-02 16:18:03 +08:00
|
|
|
setModalInfo({ visible: true, record });
|
2025-06-27 10:41:33 +08:00
|
|
|
};
|
|
|
|
const closeModal = () => {
|
2025-07-02 16:18:03 +08:00
|
|
|
setModalInfo({ visible: false, record: null });
|
2025-06-27 10:41:33 +08:00
|
|
|
};
|
2025-07-02 16:18:03 +08:00
|
|
|
const columns: ColumnsType<SupplierEntryReviewRecord> = [
|
2025-06-27 10:41:33 +08:00
|
|
|
{
|
|
|
|
title: '序号',
|
|
|
|
dataIndex: 'index',
|
|
|
|
width: 48,
|
|
|
|
align: 'center',
|
2025-07-02 16:18:03 +08:00
|
|
|
render: (_: any, __: any, idx: number) => (((pagination.current ?? 1) - 1) * (pagination.pageSize ?? 10)) + idx + 1,
|
2025-06-27 10:41:33 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: '准入工作',
|
|
|
|
dataIndex: 'accessWorkName',
|
|
|
|
align: 'center',
|
|
|
|
ellipsis: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: '准入部门',
|
|
|
|
dataIndex: 'deptId',
|
|
|
|
align: 'center',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: '准入方式',
|
|
|
|
dataIndex: 'accessTypeText',
|
|
|
|
align: 'center',
|
2025-07-09 15:30:30 +08:00
|
|
|
ellipsis: true,
|
2025-06-27 10:41:33 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: '准入品类',
|
2025-07-09 15:30:30 +08:00
|
|
|
dataIndex: 'categoryNameList',
|
2025-06-27 10:41:33 +08:00
|
|
|
align: 'center',
|
2025-07-09 15:30:30 +08:00
|
|
|
render: (_: any, record: any) => {
|
|
|
|
return (
|
|
|
|
<>
|
2025-07-10 09:31:22 +08:00
|
|
|
{record.categoryNameList && record.categoryNameList.map((item:string) => {
|
2025-07-09 15:30:30 +08:00
|
|
|
return <div>{`${item}`}</div>
|
|
|
|
})}
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
},
|
2025-06-27 10:41:33 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: '开始时间',
|
|
|
|
dataIndex: 'startTime',
|
|
|
|
align: 'center',
|
2025-07-09 15:30:30 +08:00
|
|
|
ellipsis: true,
|
2025-06-27 10:41:33 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: '结束时间',
|
|
|
|
dataIndex: 'endTime',
|
|
|
|
align: 'center',
|
2025-07-09 15:30:30 +08:00
|
|
|
ellipsis: true,
|
2025-06-27 10:41:33 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: '流程状态',
|
|
|
|
dataIndex: 'reviewStatusText',
|
|
|
|
align: 'center',
|
|
|
|
},
|
2025-07-02 16:18:03 +08:00
|
|
|
{
|
|
|
|
title: '审核',
|
|
|
|
dataIndex: 'approveStatusText',
|
|
|
|
align: 'center',
|
|
|
|
},
|
2025-06-27 10:41:33 +08:00
|
|
|
{
|
|
|
|
title: '操作',
|
|
|
|
width: 120,
|
|
|
|
render: (_: any, record: any) => {
|
2025-07-02 16:18:03 +08:00
|
|
|
return (
|
|
|
|
<Space>
|
|
|
|
<a onClick={() => openModal(record.id)}>查看</a>
|
|
|
|
</Space>
|
|
|
|
)
|
|
|
|
|
2025-06-27 10:41:33 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
];
|
2025-06-24 10:52:30 +08:00
|
|
|
return (
|
|
|
|
<div>
|
2025-06-24 16:48:10 +08:00
|
|
|
<Form
|
|
|
|
form={form}
|
|
|
|
layout="inline"
|
|
|
|
style={{ marginBottom: 16 }}
|
|
|
|
onFinish={handleSearch}
|
|
|
|
>
|
2025-07-02 16:18:03 +08:00
|
|
|
<Form.Item name="accessType" label="准入方式">
|
|
|
|
<Select style={{ width: 150 }} placeholder="请选择准入方式" allowClear >
|
|
|
|
<Option value="online">线上准入</Option>
|
|
|
|
<Option value="offline">线下准入</Option>
|
2025-07-09 15:30:30 +08:00
|
|
|
<Option value="scattered">零星采购/应急采购/个人供应商</Option>
|
2025-07-02 16:18:03 +08:00
|
|
|
</Select>
|
2025-06-24 16:48:10 +08:00
|
|
|
</Form.Item>
|
|
|
|
<Form.Item name="deptId" label="准入部门">
|
2025-07-02 16:18:03 +08:00
|
|
|
<Select options={deptOptions} allowClear style={{ width: 120 }} placeholder="请选择准入部门" />
|
2025-06-24 16:48:10 +08:00
|
|
|
</Form.Item>
|
2025-07-02 16:18:03 +08:00
|
|
|
|
|
|
|
<Form.Item name="approveStatus" label="流程状态">
|
|
|
|
<Select style={{ width: 150 }} placeholder="请选择状态" allowClear>
|
|
|
|
<Option value="0">未开始</Option>
|
|
|
|
<Option value="1">进行中</Option>
|
|
|
|
<Option value="2">结果汇总中</Option>
|
|
|
|
<Option value="3">已完成</Option>
|
|
|
|
</Select>
|
2025-06-24 16:48:10 +08:00
|
|
|
</Form.Item>
|
|
|
|
<Form.Item>
|
|
|
|
<Button type="primary" htmlType="submit" icon={<SearchOutlined />} style={{ marginRight: 8 }}>
|
|
|
|
查询
|
|
|
|
</Button>
|
|
|
|
<Button onClick={handleReset} icon={<ReloadOutlined />}>
|
|
|
|
重置
|
|
|
|
</Button>
|
|
|
|
</Form.Item>
|
|
|
|
</Form>
|
|
|
|
|
|
|
|
<Table
|
2025-06-24 10:52:30 +08:00
|
|
|
columns={columns}
|
2025-06-24 16:48:10 +08:00
|
|
|
dataSource={data}
|
2025-06-24 10:52:30 +08:00
|
|
|
rowKey="id"
|
2025-06-24 16:48:10 +08:00
|
|
|
loading={loading}
|
2025-06-24 10:52:30 +08:00
|
|
|
pagination={{
|
2025-06-24 16:48:10 +08:00
|
|
|
current: pagination.current,
|
|
|
|
pageSize: pagination.pageSize,
|
|
|
|
total: pagination.total,
|
2025-06-24 10:52:30 +08:00
|
|
|
showQuickJumper: true,
|
|
|
|
showSizeChanger: true,
|
|
|
|
}}
|
2025-06-24 16:48:10 +08:00
|
|
|
onChange={handleTableChange}
|
2025-06-24 10:52:30 +08:00
|
|
|
/>
|
2025-07-02 16:18:03 +08:00
|
|
|
<ViewModal
|
|
|
|
visible={modalInfo.visible}
|
|
|
|
record={modalInfo.record}
|
|
|
|
onCancel={closeModal}
|
|
|
|
/>
|
2025-06-24 10:52:30 +08:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default SupplierEntryReview;
|