实现思路:
- 通过 Protable 绑定的 actionRef 属性可以拿到 pageInfo 信息,这里面有总条数,当前页数,当前条数
interface PageInfo {
current: number;
pageSize: number;
total: number;
};
interface ActionType {
reload: (resetPageIndex?: boolean) => void;
reloadAndRest?: () => void;
reset?: () => void;
clearSelected?: () => void;
setPageInfo: (info: Partial<PageInfo>) => void;
pageInfo: PageInfo;
}
export const currentTableSource = (actionRef: React.MutableRefObject<ActionType>) => {
if (!actionRef?.current?.pageInfo) { return; };
const { total, current, pageSize } = actionRef.current?.pageInfo;
if (current > 1 && total - ((current - 1) * pageSize) === 1) {
actionRef.current.setPageInfo({
current: current == 1 ? 1 : current - 1,
});
} else {
actionRef.current.reload();
}
};