Files
fe_supplier_frontend/src/pages/supplier/admission/SupplierEntryReview/index.tsx

246 lines
6.5 KiB
TypeScript
Raw Normal View History

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
const statusColorMap: Record<string, string> = {
'未开始': 'default',
'进行中': 'processing',
2025-06-24 16:48:10 +08:00
'已完成': 'success',
2025-06-24 10:52:30 +08:00
};
2025-06-24 16:48:10 +08:00
const methodOptions = [
{ label: '全部', value: '' },
{ label: '线上准入', value: '线上准入' },
{ label: '线下准入', value: '线下准入' },
];
const statusOptions = [
{ label: '全部', value: '' },
{ label: '未开始', value: '未开始' },
{ label: '进行中', value: '进行中' },
{ label: '已完成', value: '已完成' },
];
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',
},
{
title: '准入品类',
dataIndex: 'categoryName',
align: 'center',
ellipsis: true,
},
{
title: '开始时间',
dataIndex: 'startTime',
align: 'center',
},
{
title: '结束时间',
dataIndex: 'endTime',
align: 'center',
},
{
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
console.log(record, 'record');
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>
</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;