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

192 lines
5.2 KiB
TypeScript
Raw Normal View History

2025-06-24 10:52:30 +08:00
import React, { useEffect, useState } from "react";
2025-06-24 11:08:51 +08:00
import { useIntl } from 'umi';
2025-06-24 16:48:10 +08:00
import { Form, Button, Table, Space, Input } from 'antd';
2025-06-24 10:52:30 +08:00
import type { ColumnsType, TablePaginationConfig } from 'antd/es/table';
import { SearchOutlined } from '@ant-design/icons';
import { getPage } from './services';
//查看评审结果 弹窗
import ResultModal from './components/ResultModal';
2025-06-24 16:48:10 +08:00
import GroupLeaderModal from './components/GroupLeaderModal';
2025-06-24 10:52:30 +08:00
interface Data {
deptName: string;
categoryName: string;
createTime: string;
exitTime: string;
exitReason: string;
}
interface ModalInfo {
2025-06-24 16:48:10 +08:00
type: 'teamMembers' | 'groupLeader' | null;
2025-06-24 10:52:30 +08:00
visible: boolean;
record: Data | null;
}
const CooperateEnterprise: React.FC = () => {
const [searchForm] = Form.useForm();
const intl = useIntl();
const [data, setData] = useState<Data[]>([]);
const [loading, setLoading] = useState(false);
const [pagination, setPagination] = useState<TablePaginationConfig>({ current: 1, pageSize: 10, total: 0 });
const [modalInfo, setModalInfo] = useState<ModalInfo>({ type: null, visible: false, record: null });
2025-06-24 16:48:10 +08:00
const openModal = (type: 'teamMembers' | 'groupLeader', record: Data) => {
2025-06-24 10:52:30 +08:00
setModalInfo({ type, visible: true, record });
};
2025-06-24 16:48:10 +08:00
//提交关闭审核
2025-06-24 10:52:30 +08:00
const closeModal = () => {
setModalInfo({ type: null, visible: false, record: null });
};
2025-06-24 16:48:10 +08:00
//提交审核
const submitModal = () => {
closeModal();
handleReset();
};
2025-06-24 10:52:30 +08:00
// 列表数据
const getList = async (params: { pageNo: number; pageSize: number; parentCode: string; }) => {
setLoading(true);
try {
2025-06-24 16:48:10 +08:00
const { code, data } = await getPage({...params });
2025-06-24 10:52:30 +08:00
if (code === 200) {
setData(data.records);
setPagination({ current: params.pageNo, pageSize: params.pageSize, total: data.total });
}
} catch (error) {
console.error('Failed to fetch data:', error);
} finally {
setLoading(false);
}
};
const handleReset = () => {
searchForm.resetFields();
getList({ pageNo: 1, pageSize: pagination.pageSize ?? 10, parentCode: '' });
};
const handleSearch = (values: any) => {
const { parentCode } = values;
getList({
pageNo: 1,
pageSize: pagination.pageSize ?? 10,
parentCode: parentCode || ''
});
};
useEffect(() => {
getList({ pageNo: 1, pageSize: 10, parentCode: '' });
}, []);
const columns: ColumnsType<Data> = [
{
title: '序号',
dataIndex: 'index',
key: 'index',
width: 80,
align: 'center',
render: (_: any, __: any, index: number) => index + 1,
},
{
title: '准入工作',
dataIndex: 'accessWorkName',
key: 'accessWorkName',
},
{
title: '发起单位',
dataIndex: 'deptId',
key: 'deptId',
},
{
title: '准入部门',
dataIndex: 'deptId',
key: 'deptId',
},
{
title: '品类',
2025-06-24 16:48:10 +08:00
dataIndex: 'categoryName',
key: 'categoryName',
2025-06-24 10:52:30 +08:00
},
{
title: '准入方式',
dataIndex: 'accessTypeText',
key: 'accessTypeText',
},
{
title: '评审时间',
dataIndex: 'createTime',
key: 'createTime',
},
{
title: '评审状态',
dataIndex: 'reviewStatusText',
key: 'reviewStatusText',
},
{
title: '操作',
2025-06-24 16:48:10 +08:00
render: (_: any, record: any) => {
const showAudit = (
(['未开始', '进行中'].includes(record.reviewStatusText) && record.isLeader === '0') ||
(['结果汇总中'].includes(record.reviewStatusText) && record.isLeader === '1')
);
const type = ['未开始', '进行中'].includes(record.reviewStatusText)? 'teamMembers': 'groupLeader';
return (
2025-06-24 10:52:30 +08:00
<Space>
2025-06-24 16:48:10 +08:00
{showAudit && <a onClick={() => openModal(type, record)}></a>}
</Space>
)
},
2025-06-24 10:52:30 +08:00
},
];
return (
<>
<Form
form={searchForm}
layout="inline"
onFinish={handleSearch}
style={{ marginBottom: 16 }}
>
<Form.Item name="parentCode" label="准入工作">
<Input placeholder="请输入准入工作" />
</Form.Item>
<Form.Item>
<Button type="primary" htmlType="submit" icon={<SearchOutlined />}>
</Button>
</Form.Item>
<Form.Item>
<Button onClick={handleReset}></Button>
</Form.Item>
</Form>
<Table
rowKey="id"
className="custom-table"
columns={columns}
dataSource={data}
pagination={pagination}
loading={loading}
onChange={(pagination) => getList({ pageNo: pagination.current!, pageSize: pagination.pageSize!, parentCode: '', })}
/>
2025-06-24 16:48:10 +08:00
{ modalInfo.type && modalInfo.type === 'teamMembers' && (
<ResultModal
visible={modalInfo.visible}
record={modalInfo.record}
onCancel={closeModal}
onSubmit={submitModal}
/>
)}
{ modalInfo.type && modalInfo.type === 'groupLeader' && (
<GroupLeaderModal
visible={modalInfo.visible}
record={modalInfo.record}
onCancel={closeModal}
onSubmit={submitModal}
/>
)}
2025-06-24 10:52:30 +08:00
</>
);
};
2025-06-24 11:08:51 +08:00
export default CooperateEnterprise;