import { logisticscontrollerGetservicelist, logisticscontrollerSyncservices, logisticscontrollerToggleactive, } from '@/servers/api/logistics'; import { ActionType, PageContainer, ProColumns, ProFormSwitch, ProTable, } from '@ant-design/pro-components'; import { App, Button } from 'antd'; import { useRef } from 'react'; const ListPage: React.FC = () => { const actionRef = useRef(); const { message } = App.useApp(); const columns: ProColumns[] = [ { title: '服务商 ID', dataIndex: 'id', hideInSearch: true, }, { title: '运营商名称', dataIndex: 'carrier_name', }, { title: '服务商名称', dataIndex: 'service_name', hideInSearch: true, }, { title: '启用', dataIndex: 'isActive', valueType: 'switch', render(_, record) { return ( { try { const { success } = await logisticscontrollerToggleactive({ id: record.id, isActive: value, }); if (!success) { throw new Error('启动失败'); } actionRef.current?.reload(); } catch (e: any) { message.error(e?.message || '启动失败'); } }, }} /> ); }, }, ]; return ( [ , ]} request={async (values) => { console.log(values); const { data, success } = await logisticscontrollerGetservicelist( values, ); if (success) { return { total: data?.total || 0, data: data?.items || [], }; } return { data: [], }; }} columns={columns} /> ); }; export default ListPage;