import React, { useEffect, useState } from "react"; //第三方UI库/组件 import { Form, Button, Table, Select, Input, Space, Tooltip, message } from 'antd'; import { SearchOutlined, DeleteOutlined } from '@ant-design/icons'; //类型定义 import type { ColumnsType, TablePaginationConfig } from 'antd/es/table'; //umi 相关 import { useIntl, connect } from 'umi'; //本地组件、弹窗、业务逻辑 import SupplierViewModal from './components/SupplierViewModal'; import SupplierDetailModal from './components/SupplierDetailModal'; import RegionTypeSelect from '@/components/CommonSelect/RegionTypeSelect' import AccessStatusSelect from '@/components/CommonSelect/AccessStatusSelect' //本地服务/接口 import { getRegisterPage } from './services'; //统一列表分页 import tableProps from '@/utils/tableProps' // 列表数据接口 interface Data { id: number; name: string; region: string; supplierType: string; regTime: string; status: string; } //准入状态 const statusColor = (status: string) => { if (status === '已驳回' || status === '已退出') return '#ef6969'; if (status === '已准入') return '#004f8e'; return undefined; }; interface RegistrationQueryProps { dispatch: any; } // 页面主体 const RegistrationQuery: React.FC = ({ dispatch }) => { //双语 const intl = useIntl(); //查询表单 const [form] = Form.useForm(); //列表渲染数据 const [data, setData] = useState([]); //列表加载 const [loading, setLoading] = useState(false); //列表分页 const [pagination, setPagination] = useState({ current: 1, pageSize: 10, total: 0, }); //查看是否显示状态 const [viewVisible, setViewVisible] = useState(false); //准入明细是否显示状态 const [detailVisible, setDetailVisible] = useState(false); //查看、准入明细 参数传递 const [currentRecord, setCurrentRecord] = useState(''); // 搜索 const handleSearch = () => { setPagination({ ...pagination, current: 1 }); getList(); }; // 重置 const handleReset = () => { form.resetFields(); setPagination({ ...pagination, current: 1 }); getList(); }; //列表方法 const getList = async (pageNo: number = 1, pageSize: number = 10) => { setLoading(true); try { const values = form.getFieldsValue(); const { code, data, message } = await getRegisterPage({ pageNo, pageSize, ...values }); if (code === 200) { setData(data.records); setPagination({ current: pageNo, pageSize, total: data.total }); } else { message.error(message) } } finally { setLoading(false); } }; //初始化 useEffect(() => { //列表 getList(); }, []) // 列表头部数据 const columns: ColumnsType = [ { title: '序号', dataIndex: 'index', key: 'index', width: 70, align: 'center', render: (_: any, __: any, idx: number) => (((pagination.current ?? 1) - 1) * (pagination.pageSize ?? 10)) + idx + 1, }, { title: '供应商名称', dataIndex: 'name', key: 'name', align: 'left', width: 160, ellipsis: true, render: (dom, record) => { dispatch({ type: 'globalModal/show', payload: { id: record.id, }, }); }} > {record.name} , }, { title: '境内/境外', dataIndex: 'supplierTypeCn', key: 'supplierTypeCn', align: 'center', width: 160, }, { title: '企业类型', dataIndex: 'enterpriseTypeCn', key: 'enterpriseTypeCn', align: 'center', width: 160, }, { title: '注册时间', dataIndex: 'createTime', key: 'createTime', align: 'center', ellipsis: true, width: 180, }, { title: '准入状态', dataIndex: 'accessStatusCn', key: 'accessStatusCn', width: 160, align: 'center', render: (val: string) => {val} }, { title: '操作', key: 'option', align: 'center', width: 80, render: (record) => ( { dispatch({ type: 'globalModal/show', payload: { id: record.id, }, }); }} >查看 {/* { setCurrentRecord(record.id); setDetailVisible(true); }} >准入明细 */} ), }, ]; return ( <>
getList(pagination.current!, pagination.pageSize!)} style={{ flex: 1, minHeight: 0 }} scroll={{ y: 'calc(100vh - 350px)' }} /> {/* 查看组件 */} setViewVisible(false)} /> {/* 准入明细组件 */} setDetailVisible(false)} /> ); }; export default connect()(RegistrationQuery);