nocobase/packages/client/src/schemas/table/TablePagination.tsx
SemmyWong 12f58effad
refactor: code splitting of the table component (#121)
* refactor: 表格拆分模块化

* refactor: 表格拆分模块化

* refactor: code splitting of the table component (#120)

* missing TableIndex

* refactor: 表格拆分模块化

* code format

Co-authored-by: chenos <chenlinxh@gmail.com>
2021-12-02 22:56:16 +08:00

41 lines
1.1 KiB
TypeScript

import React from 'react';
import { Pagination } from 'antd';
import { observer } from '@formily/react';
import { useTable } from './hooks/useTable';
import { useTotal } from './hooks/useTotal';
export const TablePagination = observer(() => {
const { service, pagination, setPagination, props } = useTable();
if (!pagination || Object.keys(pagination).length === 0) {
return null;
}
const { clientSidePagination } = props;
const total = useTotal();
const { page = 1 } = pagination;
return (
<div style={{ marginTop: 16 }}>
<Pagination
{...pagination}
showSizeChanger
current={page}
total={total}
onChange={(current, pageSize) => {
const page = pagination.pageSize !== pageSize ? 1 : current;
setPagination({
page,
pageSize,
});
// if (clientSidePagination) {
// return;
// }
// service.run({
// ...service.params[0],
// page,
// pageSize,
// });
}}
/>
</div>
);
});