From ca88638edf84f16d8dfe4bc059854e14582f281b Mon Sep 17 00:00:00 2001 From: Dunqing Date: Thu, 13 Apr 2023 14:14:26 +0800 Subject: [PATCH] fix: cannot display data when remove last page and the page only just one item (#1685) * fix: cannot display data when remove last page and the page only just one item * fix: hidden pagination when pageSize = totalSize --- .../core/client/src/block-provider/hooks/index.ts | 12 +++++++++++- .../src/schema-component/antd/table-v2/Table.tsx | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/core/client/src/block-provider/hooks/index.ts b/packages/core/client/src/block-provider/hooks/index.ts index df3c74e4a..98e67709c 100644 --- a/packages/core/client/src/block-provider/hooks/index.ts +++ b/packages/core/client/src/block-provider/hooks/index.ts @@ -718,7 +718,17 @@ export const useDestroyActionProps = () => { await resource.destroy({ filterByTk, }); - service?.refresh?.(); + + const { count = 0, page = 0, pageSize = 0 } = service?.data?.meta || {}; + if (count % pageSize === 1) { + service.run({ + ...service?.params?.[0], + page: page - 1, + }); + } else { + service?.refresh?.(); + } + if (block !== 'TableField') { __parent?.service?.refresh?.(); setVisible?.(false); diff --git a/packages/core/client/src/schema-component/antd/table-v2/Table.tsx b/packages/core/client/src/schema-component/antd/table-v2/Table.tsx index 0ccb7bab0..9bb8aae86 100644 --- a/packages/core/client/src/schema-component/antd/table-v2/Table.tsx +++ b/packages/core/client/src/schema-component/antd/table-v2/Table.tsx @@ -131,7 +131,7 @@ const usePaginationProps = (pagination1, pagination2) => { ...pagination1, ...pagination2, }; - return result.total < result.pageSize ? false : result; + return result.total <= result.pageSize ? false : result; }; const useValidator = (validator: (value: any) => string) => {