Files
fe_supplier_frontend/src/pages/supplier/informationRetrieval/registrationQuery/index.tsx

252 lines
7.6 KiB
TypeScript
Raw Normal View History

2025-06-24 10:52:30 +08:00
import React, { useEffect, useState } from "react";
//第三方UI库/组件
import { Form, Button, Table, Select, Input, Space, Tooltip, message } from 'antd';
2025-07-10 15:38:05 +08:00
import { SearchOutlined, DeleteOutlined } from '@ant-design/icons';
2025-06-24 10:52:30 +08:00
//类型定义
import type { ColumnsType, TablePaginationConfig } from 'antd/es/table';
//umi 相关
2025-07-09 14:01:45 +08:00
import { useIntl, connect } from 'umi';
2025-06-24 10:52:30 +08:00
//本地组件、弹窗、业务逻辑
import SupplierViewModal from './components/SupplierViewModal';
import SupplierDetailModal from './components/SupplierDetailModal';
//本地服务/接口
2025-07-02 16:18:03 +08:00
import { getRegisterPage } from './services';
2025-07-10 15:38:05 +08:00
//统一列表分页
import tableProps from '@/utils/tableProps'
2025-06-24 10:52:30 +08:00
// 列表数据接口
interface Data {
id: number;
name: string;
region: string;
supplierType: string;
regTime: string;
status: string;
}
//下拉数据接口
type OptionType = { label: string; value: string };
//准入状态
const statusColor = (status: string) => {
if (status === '已驳回' || status === '已退出') return 'red';
if (status === '已准入') return 'green';
return undefined;
};
2025-07-09 14:01:45 +08:00
interface RegistrationQueryProps {
dispatch: any;
}
2025-06-24 10:52:30 +08:00
// 页面主体
2025-07-09 14:01:45 +08:00
const RegistrationQuery: React.FC<RegistrationQueryProps> = ({ dispatch }) => {
2025-06-24 10:52:30 +08:00
//双语
const intl = useIntl();
//查询表单
const [form] = Form.useForm();
//列表渲染数据
const [data, setData] = useState<Data[]>([]);
//列表加载
const [loading, setLoading] = useState(false);
//列表分页
const [pagination, setPagination] = useState<TablePaginationConfig>({ current: 1, pageSize: 10, total: 0, });
//查看是否显示状态
const [viewVisible, setViewVisible] = useState(false);
//准入明细是否显示状态
const [detailVisible, setDetailVisible] = useState(false);
//查看、准入明细 参数传递
2025-07-03 10:24:33 +08:00
const [currentRecord, setCurrentRecord] = useState('');
2025-06-24 10:52:30 +08:00
// 境内/境外下拉数据
const [regionOptions, setRegionOptions] = useState<OptionType[]>([]);
//状态 下拉数据
const [statusOptions, setStatusOptions] = useState<OptionType[]>([]);
// 搜索
const handleSearch = () => {
setPagination({ ...pagination, current: 1 });
getList();
};
// 重置
const handleReset = () => {
form.resetFields();
setPagination({ ...pagination, current: 1 });
getList();
};
//列表方法
2025-07-02 16:18:03 +08:00
const getList = async (pageNo: number = 1, pageSize: number = 10) => {
2025-06-24 10:52:30 +08:00
setLoading(true);
try {
2025-07-02 16:18:03 +08:00
const values = form.getFieldsValue();
const { code, data, message } = await getRegisterPage({ pageNo, pageSize, ...values });
2025-06-24 10:52:30 +08:00
if (code === 200) {
2025-07-02 16:18:03 +08:00
setData(data.records);
setPagination({ current: pageNo, pageSize, total: data.total });
2025-06-24 10:52:30 +08:00
} else {
2025-07-10 15:38:05 +08:00
message.error(message)
2025-06-24 10:52:30 +08:00
}
} finally {
setLoading(false);
}
};
//初始化
useEffect(() => {
// 境内/境外 下拉
2025-07-02 16:18:03 +08:00
setRegionOptions([
{ label: '境内企业', value: 'dvs' },
{ label: '境外企业', value: 'ovs' },
2025-07-09 16:34:10 +08:00
{ label: '个人', value: 'pe' },
2025-07-02 16:18:03 +08:00
])
//状态 下拉
setStatusOptions([
{ label: '未准入', value: '0' },
2025-07-10 09:31:22 +08:00
{ label: '已准入', value: '1' },
2025-07-02 16:18:03 +08:00
{ label: '退出', value: '2' },
])
2025-06-24 10:52:30 +08:00
//列表
getList();
}, [])
// 列表头部数据
const columns: ColumnsType<Data> = [
{
title: '序号',
dataIndex: 'index',
key: 'index',
width: 70,
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-24 10:52:30 +08:00
},
{
title: '供应商名称',
dataIndex: 'name',
key: 'name',
align: 'left',
2025-07-15 09:07:43 +08:00
width: 160,
2025-06-24 10:52:30 +08:00
ellipsis: true,
2025-07-10 15:38:05 +08:00
render: (dom, record) =>
2025-06-24 10:52:30 +08:00
<Tooltip title={record.name}>
2025-07-10 15:38:05 +08:00
<a
2025-07-09 14:01:45 +08:00
onClick={() => {
dispatch({
type: 'globalModal/show',
payload: {
id: record.id,
},
});
}}
>
2025-06-24 10:52:30 +08:00
{record.name}
2025-07-09 14:01:45 +08:00
</a>
2025-06-24 10:52:30 +08:00
</Tooltip>,
},
{
title: '境内/境外',
2025-07-02 16:18:03 +08:00
dataIndex: 'supplierTypeCn',
key: 'supplierTypeCn',
2025-06-24 10:52:30 +08:00
align: 'center',
2025-07-10 15:38:05 +08:00
width: 160,
2025-06-24 10:52:30 +08:00
},
{
title: '供应商分类',
2025-07-02 16:18:03 +08:00
dataIndex: 'enterpriseTypeCn',
key: 'enterpriseTypeCn',
2025-06-24 10:52:30 +08:00
align: 'center',
2025-07-10 15:38:05 +08:00
width: 160,
2025-06-24 10:52:30 +08:00
},
{
title: '注册时间',
2025-07-02 16:18:03 +08:00
dataIndex: 'createTime',
key: 'createTime',
2025-06-24 10:52:30 +08:00
align: 'center',
2025-07-02 16:18:03 +08:00
ellipsis: true,
2025-07-10 15:38:05 +08:00
width: 180,
2025-06-24 10:52:30 +08:00
},
{
2025-07-15 17:04:54 +08:00
title: '准入状态',
2025-07-02 16:18:03 +08:00
dataIndex: 'accessStatusCn',
key: 'accessStatusCn',
2025-07-10 15:38:05 +08:00
width: 160,
2025-06-24 10:52:30 +08:00
align: 'center',
render: (val: string) =>
<span style={{
color: statusColor(val) || (val === '未准入' ? '#aaa' : undefined),
}}>{val}</span>
},
{
title: '操作',
key: 'option',
align: 'center',
2025-07-10 15:38:05 +08:00
width: 160,
2025-06-24 10:52:30 +08:00
render: (record) => (
<Space>
<a
style={{ color: '#1677ff' }}
2025-07-03 10:24:33 +08:00
onClick={() => { setCurrentRecord(record.id); setViewVisible(true); }}
2025-06-24 10:52:30 +08:00
></a>
<a
style={{ color: '#1677ff' }}
2025-07-03 10:24:33 +08:00
onClick={() => { setCurrentRecord(record.id); setDetailVisible(true); }}
2025-06-24 10:52:30 +08:00
></a>
</Space>
),
},
];
return (
<>
2025-07-10 15:38:05 +08:00
<div className="common-container">
<div className="filter-action-row">
<Form
form={form}
layout="inline"
onFinish={handleSearch}
style={{ marginBottom: 16 }}
>
<Form.Item name="name" label="供应商名称">
<Input placeholder="请输入供应商名称关键字" style={{ width: 220 }} allowClear maxLength={20} />
</Form.Item>
<Form.Item name="supplierType" label="境内/境外">
<Select style={{ width: 160 }} placeholder="请选择境内/境外" allowClear>
{regionOptions.map(opt => (
<Select.Option key={opt.value} value={opt.value}>{opt.label}</Select.Option>
))}
</Select>
</Form.Item>
2025-07-15 17:04:54 +08:00
<Form.Item name="accessStatus" label="准入状态">
2025-07-10 15:38:05 +08:00
<Select style={{ width: 160 }} placeholder="请选择状态" allowClear>
{statusOptions.map(opt => (
<Select.Option key={opt.value} value={opt.value}>{opt.label}</Select.Option>
))}
</Select>
</Form.Item>
<Form.Item>
<Button className="buttonSubmit" type="primary" htmlType="submit" icon={<SearchOutlined />}></Button>
</Form.Item>
<Form.Item>
<Button className="buttonReset" icon={<DeleteOutlined />} onClick={handleReset} ></Button>
</Form.Item>
</Form>
</div>
<Table
rowKey="id"
columns={columns}
dataSource={data}
loading={loading}
pagination={{...tableProps.pagination, total: pagination.total }}
onChange={(pagination) => getList(pagination.current!, pagination.pageSize!)}
style={{ flex: 1, minHeight: 0 }}
scroll={{ y: 'calc(100vh - 350px)' }}
/>
{/* 查看组件 */}
<SupplierViewModal
visible={viewVisible}
record={currentRecord}
onCancel={() => setViewVisible(false)}
/>
{/* 准入明细组件 */}
<SupplierDetailModal
visible={detailVisible}
record={currentRecord}
onCancel={() => setDetailVisible(false)}
/>
</div>
2025-06-24 10:52:30 +08:00
</>
);
};
2025-07-09 14:01:45 +08:00
export default connect()(RegistrationQuery);