const SupplierList = ({ supplierId, handleSupplierId }) => {
const { t } = useTranslation();
const [data, setData] = useState(null);
const [page, setPage] = useState(
useStore().getState().page?.supplierListPage || 1
);
const [total, setTotal] = useState(1);
const [searchParams, setSearchParams] = useState({});
const { saveSupplierListPage } = usePageActions();
console.log("supplierId:", supplierId);
useEffect(() => {
const params: any = {
page,
limit: 12,
...searchParams,
};
fetchErpURL(params).then(res => {
unstable_batchedUpdates(() => {
setData(res.list)
setTotal(res.total)
})
}).catch(e => {
})
}, [page, searchParams])
const changePage = (page) => {
setPage(page);
saveSupplierListPage(page);
};
const onPagination = (lastPage) => {
setData(null);
changePage(lastPage);
};
const supplierColumns = [
{
title: "供应商",
dataIndex: 'orgName',
},
];
return <Table
columns={supplierColumns}
dataSource={data}
rowKey='sid'
pagination={{
size: 'default',
current: page,
onChange: onPagination,
total,
pageSize: 12,
}}
rowClassName={(record) => {
return record.sid === supplierId ? styles['split-row-select-active'] : '';
}}
onRow={(record) => {
return {
onClick: () => {
if (record.sid === supplierId) {
handleSupplierId(0)
} else {
handleSupplierId(record.sid)
}
},
};
}}
/>
}
const SupplierListMemo = React.memo(SupplierList);
<SupplierListMemo supplierId={supplierId} handleSupplierId={handleSupplierId} />