From efac16c6a9f0797f1e4eb8f50de2449e2acc43ed Mon Sep 17 00:00:00 2001 From: Zhichao Gu Date: Fri, 6 Sep 2024 23:38:12 +0800 Subject: [PATCH] feat: change all pageSize options to 5/10/20/50/100/200 (#5020) * fix: change all pageSize options to 5/10/20/50/100/200 * fix: reset pageSize options same as list options 5/10/20/50/100/200 * fix: reset table pageSize options same as list options 5/10/20/50/100/200 * fix: list set pageSizeOption as 5/10/20/50/100/200,showSizeChanger * fix: gridcard set pageSizeOption but showSizeChanger not set --- .../src/modules/blocks/data-blocks/list/listBlockSettings.ts | 3 ++- .../data-blocks/table-selector/tableSelectorBlockSettings.ts | 1 + .../modules/blocks/data-blocks/table/tableBlockSettings.tsx | 1 + .../client/src/schema-component/antd/grid-card/GridCard.tsx | 1 + .../client/src/schema-component/antd/list/List.Designer.tsx | 3 ++- packages/core/client/src/schema-component/antd/list/List.tsx | 4 ++++ .../core/client/src/schema-component/antd/table-v2/Table.tsx | 4 ++++ .../src/schema-component/antd/table-v2/TableBlockDesigner.tsx | 1 + .../schema-component/antd/table-v2/TableSelectorDesigner.tsx | 1 + .../src/schema-component/antd/table/Table.Void.Designer.tsx | 1 + .../client/src/schema-component/antd/table/Table.Void.tsx | 3 +++ .../src/client/deplicated/AuditLogsDesigner.tsx | 1 + 12 files changed, 22 insertions(+), 2 deletions(-) diff --git a/packages/core/client/src/modules/blocks/data-blocks/list/listBlockSettings.ts b/packages/core/client/src/modules/blocks/data-blocks/list/listBlockSettings.ts index 9a572040c3..8c0f8d5e63 100644 --- a/packages/core/client/src/modules/blocks/data-blocks/list/listBlockSettings.ts +++ b/packages/core/client/src/modules/blocks/data-blocks/list/listBlockSettings.ts @@ -187,11 +187,12 @@ export const listBlockSettings = new SchemaSettings({ title: t('Records per page'), value: field.decoratorProps?.params?.pageSize || 20, options: [ + { label: '5', value: 5 }, { label: '10', value: 10 }, { label: '20', value: 20 }, { label: '50', value: 50 }, - { label: '80', value: 80 }, { label: '100', value: 100 }, + { label: '200', value: 200 }, ], onChange: (pageSize) => { _.set(fieldSchema, 'x-decorator-props.params.pageSize', pageSize); diff --git a/packages/core/client/src/modules/blocks/data-blocks/table-selector/tableSelectorBlockSettings.ts b/packages/core/client/src/modules/blocks/data-blocks/table-selector/tableSelectorBlockSettings.ts index 1cf878c705..6be42ae99b 100644 --- a/packages/core/client/src/modules/blocks/data-blocks/table-selector/tableSelectorBlockSettings.ts +++ b/packages/core/client/src/modules/blocks/data-blocks/table-selector/tableSelectorBlockSettings.ts @@ -251,6 +251,7 @@ export const tableSelectorBlockSettings = new SchemaSettings({ title: t('Records per page'), value: field.decoratorProps?.params?.pageSize || 20, options: [ + { label: '5', value: 5 }, { label: '10', value: 10 }, { label: '20', value: 20 }, { label: '50', value: 50 }, diff --git a/packages/core/client/src/modules/blocks/data-blocks/table/tableBlockSettings.tsx b/packages/core/client/src/modules/blocks/data-blocks/table/tableBlockSettings.tsx index f7d70ff2b1..ec735aa1ad 100644 --- a/packages/core/client/src/modules/blocks/data-blocks/table/tableBlockSettings.tsx +++ b/packages/core/client/src/modules/blocks/data-blocks/table/tableBlockSettings.tsx @@ -164,6 +164,7 @@ export const tableBlockSettings = new SchemaSettings({ title: t('Records per page'), value: field.decoratorProps?.params?.pageSize || 20, options: [ + { label: '5', value: 5 }, { label: '10', value: 10 }, { label: '20', value: 20 }, { label: '50', value: 50 }, diff --git a/packages/core/client/src/schema-component/antd/grid-card/GridCard.tsx b/packages/core/client/src/schema-component/antd/grid-card/GridCard.tsx index 01d5dd4aee..05777e75e7 100644 --- a/packages/core/client/src/schema-component/antd/grid-card/GridCard.tsx +++ b/packages/core/client/src/schema-component/antd/grid-card/GridCard.tsx @@ -89,6 +89,7 @@ const usePaginationProps = () => { pageSize: pageSize || 10, current: page || 1, pageSizeOptions, + showSizeChanger: true, }; } else { return { diff --git a/packages/core/client/src/schema-component/antd/list/List.Designer.tsx b/packages/core/client/src/schema-component/antd/list/List.Designer.tsx index 8042c7a1af..6933bd1c89 100644 --- a/packages/core/client/src/schema-component/antd/list/List.Designer.tsx +++ b/packages/core/client/src/schema-component/antd/list/List.Designer.tsx @@ -170,11 +170,12 @@ export const ListDesigner = () => { title={t('Records per page')} value={field.decoratorProps?.params?.pageSize || 20} options={[ + { label: '5', value: 5 }, { label: '10', value: 10 }, { label: '20', value: 20 }, { label: '50', value: 50 }, - { label: '80', value: 80 }, { label: '100', value: 100 }, + { label: '200', value: 200 }, ]} onChange={(pageSize) => { _.set(fieldSchema, 'x-decorator-props.params.pageSize', pageSize); diff --git a/packages/core/client/src/schema-component/antd/list/List.tsx b/packages/core/client/src/schema-component/antd/list/List.tsx index 4d74afcc22..53355e9d2c 100644 --- a/packages/core/client/src/schema-component/antd/list/List.tsx +++ b/packages/core/client/src/schema-component/antd/list/List.tsx @@ -51,6 +51,8 @@ const InternalList = (props) => { [fieldSchema.properties, schemaMap], ); + const pageSizeOptions = [5, 10, 20, 50, 100, 200]; + const onPaginationChange: PaginationProps['onChange'] = useCallback( (page, pageSize) => { run({ @@ -97,6 +99,8 @@ const InternalList = (props) => { total: meta?.count || 0, pageSize: meta?.pageSize || 10, current: meta?.page || 1, + showSizeChanger: true, + pageSizeOptions, } } loading={service?.loading} 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 569c3001b6..95c2a3216c 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 @@ -261,6 +261,8 @@ const TableIndex = (props) => { ); }; +const pageSizeOptions = [5, 10, 20, 50, 100, 200]; + const usePaginationProps = (pagination1, pagination2) => { const { t } = useTranslation(); const field: any = useField(); @@ -279,12 +281,14 @@ const usePaginationProps = (pagination1, pagination2) => { const result = useMemo(() => { if (totalCount) { return { + pageSizeOptions, showTotal, showSizeChanger: true, ...pagination, }; } else { return { + pageSizeOptions, showTotal: false, simple: true, showTitle: false, diff --git a/packages/core/client/src/schema-component/antd/table-v2/TableBlockDesigner.tsx b/packages/core/client/src/schema-component/antd/table-v2/TableBlockDesigner.tsx index 83a75537e8..9d04b52971 100644 --- a/packages/core/client/src/schema-component/antd/table-v2/TableBlockDesigner.tsx +++ b/packages/core/client/src/schema-component/antd/table-v2/TableBlockDesigner.tsx @@ -282,6 +282,7 @@ export const TableBlockDesigner = () => { title={t('Records per page')} value={field.decoratorProps?.params?.pageSize || 20} options={[ + { label: '5', value: 5 }, { label: '10', value: 10 }, { label: '20', value: 20 }, { label: '50', value: 50 }, diff --git a/packages/core/client/src/schema-component/antd/table-v2/TableSelectorDesigner.tsx b/packages/core/client/src/schema-component/antd/table-v2/TableSelectorDesigner.tsx index cb8562f354..951e3d92ed 100644 --- a/packages/core/client/src/schema-component/antd/table-v2/TableSelectorDesigner.tsx +++ b/packages/core/client/src/schema-component/antd/table-v2/TableSelectorDesigner.tsx @@ -237,6 +237,7 @@ export const TableSelectorDesigner = () => { title={t('Records per page')} value={field.decoratorProps?.params?.pageSize || 20} options={[ + { label: '5', value: 5 }, { label: '10', value: 10 }, { label: '20', value: 20 }, { label: '50', value: 50 }, diff --git a/packages/core/client/src/schema-component/antd/table/Table.Void.Designer.tsx b/packages/core/client/src/schema-component/antd/table/Table.Void.Designer.tsx index 22adb1b741..45d32c3597 100644 --- a/packages/core/client/src/schema-component/antd/table/Table.Void.Designer.tsx +++ b/packages/core/client/src/schema-component/antd/table/Table.Void.Designer.tsx @@ -194,6 +194,7 @@ export const TableVoidDesigner = () => { title={'每页显示'} value={field.decoratorProps.request.params?.pageSize || 20} options={[ + { label: '5', value: 5 }, { label: '10', value: 10 }, { label: '20', value: 20 }, { label: '50', value: 50 }, diff --git a/packages/core/client/src/schema-component/antd/table/Table.Void.tsx b/packages/core/client/src/schema-component/antd/table/Table.Void.tsx index b61d56f17e..cd4fa12c4c 100644 --- a/packages/core/client/src/schema-component/antd/table/Table.Void.tsx +++ b/packages/core/client/src/schema-component/antd/table/Table.Void.tsx @@ -26,6 +26,8 @@ type TableVoidProps = TableProps & { ) => Result & { state?: any; setState?: any }; }; +const pageSizeOptions = [5, 10, 20, 50, 100, 200]; + const usePaginationProps = (props: TableProps & { request?: any }, service): TablePaginationConfig | false => { if (props.pagination === false) { return false; @@ -41,6 +43,7 @@ const usePaginationProps = (props: TableProps & { request?: any }, service) pagination.pageSize = pageSize; } return { + pageSizeOptions, showSizeChanger: true, ...pagination, onChange(page, pageSize) { diff --git a/packages/plugins/@nocobase/plugin-audit-logs/src/client/deplicated/AuditLogsDesigner.tsx b/packages/plugins/@nocobase/plugin-audit-logs/src/client/deplicated/AuditLogsDesigner.tsx index 5d1e4a0162..6f87350ae8 100644 --- a/packages/plugins/@nocobase/plugin-audit-logs/src/client/deplicated/AuditLogsDesigner.tsx +++ b/packages/plugins/@nocobase/plugin-audit-logs/src/client/deplicated/AuditLogsDesigner.tsx @@ -54,6 +54,7 @@ export const AuditLogsDesigner = () => { title={t('Records per page')} value={field.decoratorProps?.params?.pageSize || 20} options={[ + { label: '5', value: 5 }, { label: '10', value: 10 }, { label: '20', value: 20 }, { label: '50', value: 50 },