import React, { useEffect, useState } from "react"; //第三方UI库/组件 import { Form, Button, Table, Select, Input, Space, message } from 'antd'; import { SearchOutlined, DownloadOutlined, ReloadOutlined } from '@ant-design/icons'; //类型定义 import type { ColumnsType, TablePaginationConfig } from 'antd/es/table'; //umi 相关 //本地组件、弹窗、业务逻辑 import SupplierViewModal from './components/SupplierViewModal'; import SupplierDetailModal from './components/SupplierDetailModal'; import CategorySelector from '@/components/CategorySelector'; //本地服务/接口 import { getPageMy } from './services'; const { Option } = Select; //下拉数据接口 type OptionType = { label: string; value: string }; // 列表数据接口 interface Data { id: number; name: string; region: string; supplierType: string; regTime: string; status: string; } const mySupplierInquiry: React.FC = () => { //搜搜表单 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 [regionOptions, setRegionOptions] = useState([]); // 准入状态 const [storeOptions, setStoreOptions] = useState([]); // 导出 const handleExport = async () => { // const res = await getPageMyExport(); window.open( `${SERVER_BASE}/coscoSupplierBase/getPageMyExport`, '_blank', ); }; // 查询 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 getPageMy({ pageNo, pageSize, ...values }); if (code === 200) { setData(data.records); setPagination({ current: pageNo, pageSize, total: data.total }); } else { message.error(message) } } finally { setLoading(false); } }; // 初始化 useEffect(() => { // 境内/境外 下拉 setRegionOptions([ { label: '境内企业', value: 'dvs' }, { label: '境外企业', value: 'ovs' }, ]) // 准入状态下拉 setStoreOptions([ { label: '已准入', value: '1' }, { label: '退出', value: '2' }, ]) getList(); }, []); const columns: ColumnsType = [ { title: '序号', dataIndex: 'index', key: 'index', align: 'center', width: 60, render: (_: any, __: any, idx: number) => (((pagination.current ?? 1) - 1) * (pagination.pageSize ?? 10)) + idx + 1, }, { title: '供应商名称', dataIndex: 'name', key: 'name', align: 'center', }, { title: '境内/境外', dataIndex: 'supplierTypeCn', key: 'supplierTypeCn', align: 'center', }, { title: '企业类型', dataIndex: 'enterpriseTypeCn', key: 'enterpriseTypeCn', align: 'center', }, { title: '准入品类', dataIndex: 'categoryName', key: 'categoryName', align: 'center', }, { title: '准入时间', dataIndex: 'updateTime', key: 'updateTime', align: 'center', }, { title: '准入状态', dataIndex: 'accessStatusCn', key: 'accessStatusCn', align: 'center', }, { title: '操作', key: 'option', align: 'center', render: (record: any) => ( { setCurrentRecord(record.id); setViewVisible(true); }} >查看 { setCurrentRecord(record.id); setDetailVisible(true); }} >准入明细 ), }, ]; return ( <>
{/* 表格 */} getList(pagination.current!, pagination.pageSize!)} /> {/* 查看组件 */} setViewVisible(false)} /> {/* 准入明细组件 */} setDetailVisible(false)} /> ); }; export default mySupplierInquiry;