diff --git a/packages/core/actions/src/actions/list.ts b/packages/core/actions/src/actions/list.ts
index 570b4950fa..5e42b26765 100644
--- a/packages/core/actions/src/actions/list.ts
+++ b/packages/core/actions/src/actions/list.ts
@@ -38,7 +38,7 @@ function findArgs(ctx: Context) {
}
async function listWithPagination(ctx: Context) {
- const { page = DEFAULT_PAGE, pageSize = DEFAULT_PER_PAGE } = ctx.action.params;
+ const { page = DEFAULT_PAGE, pageSize = DEFAULT_PER_PAGE, simplePaginate } = ctx.action.params;
const repository = getRepositoryFromParams(ctx);
@@ -54,15 +54,24 @@ async function listWithPagination(ctx: Context) {
}
});
- const [rows, count] = await repository.findAndCount(options);
+ if (simplePaginate) {
+ const rows = await repository.find(options);
+ ctx.body = {
+ rows,
+ page: Number(page),
+ pageSize: Number(pageSize),
+ };
+ } else {
+ const [rows, count] = await repository.findAndCount(options);
- ctx.body = {
- count,
- rows,
- page: Number(page),
- pageSize: Number(pageSize),
- totalPage: totalPage(count, pageSize),
- };
+ ctx.body = {
+ count,
+ rows,
+ page: Number(page),
+ pageSize: Number(pageSize),
+ totalPage: totalPage(count, pageSize),
+ };
+ }
}
async function listWithNonPaged(ctx: Context) {
diff --git a/packages/core/client/src/block-provider/TableBlockProvider.tsx b/packages/core/client/src/block-provider/TableBlockProvider.tsx
index b96b8666dc..c389c55922 100644
--- a/packages/core/client/src/block-provider/TableBlockProvider.tsx
+++ b/packages/core/client/src/block-provider/TableBlockProvider.tsx
@@ -147,7 +147,7 @@ export const TableBlockProvider = withDynamicSchemaProps((props) => {
const fieldSchema = useFieldSchema();
const { getCollection, getCollectionField } = useCollectionManager_deprecated(props.dataSource);
const collection = getCollection(props.collection, props.dataSource);
- const { treeTable } = fieldSchema?.['x-decorator-props'] || {};
+ const { treeTable, pagingMode } = fieldSchema?.['x-decorator-props'] || {};
const { params, parseVariableLoading } = useTableBlockParamsCompat(props);
let childrenColumnName = 'children';
@@ -166,6 +166,11 @@ export const TableBlockProvider = withDynamicSchemaProps((props) => {
params['tree'] = true;
}
}
+ if (pagingMode === 'simplePaginate') {
+ params['simplePaginate'] = true;
+ } else {
+ delete params?.['simplePaginate'];
+ }
const form = useMemo(() => createForm(), [treeTable]);
// 在解析变量的时候不渲染,避免因为重复请求数据导致的资源浪费
diff --git a/packages/core/client/src/locale/zh-CN.json b/packages/core/client/src/locale/zh-CN.json
index 9162e64e24..7989b4fb44 100644
--- a/packages/core/client/src/locale/zh-CN.json
+++ b/packages/core/client/src/locale/zh-CN.json
@@ -966,6 +966,8 @@
"Search": "搜索",
"Clear default value": "清除默认值",
"Open in new window": "新窗口打开",
+ "Paging mode": "分页模式",
+ "Simple Paginate": "简单分页",
"Sorry, the page you visited does not exist.": "抱歉,你访问的页面不存在。",
"Set Template Engine": "设置模板引擎"
}
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..0ae847cd1e 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
@@ -25,6 +25,7 @@ import { setDefaultSortingRulesSchemaSettingsItem } from '../../../../schema-set
import { setTheDataScopeSchemaSettingsItem } from '../../../../schema-settings/setTheDataScopeSchemaSettingsItem';
import { useBlockTemplateContext } from '../../../../schema-templates/BlockTemplateProvider';
import { setDataLoadingModeSettingsItem } from '../details-multi/setDataLoadingModeSettingsItem';
+import { SchemaSettingsPagingMode } from '../../../../schema-settings/SchemaSettingsPagingMode';
export const tableBlockSettings = new SchemaSettings({
name: 'blockSettings:table',
@@ -186,6 +187,10 @@ export const tableBlockSettings = new SchemaSettings({
};
},
},
+ {
+ name: 'pagingMode',
+ Component: SchemaSettingsPagingMode,
+ },
{
name: 'ConnectDataBlocks',
Component: SchemaSettingsConnectDataBlocks,
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 d69cfa61ff..9a06f3cf28 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
@@ -264,6 +264,7 @@ const TableIndex = (props) => {
const usePaginationProps = (pagination1, pagination2) => {
const { t } = useTranslation();
const field: any = useField();
+ const { token } = useToken();
const pagination = useMemo(
() => ({ ...pagination1, ...pagination2 }),
[JSON.stringify({ ...pagination1, ...pagination2 })],
@@ -285,7 +286,7 @@ const usePaginationProps = (pagination1, pagination2) => {
} else {
return {
showTotal: false,
- simple: { readOnly: true },
+ simple: true,
showTitle: false,
showSizeChanger: true,
hideOnSinglePage: false,
@@ -296,6 +297,24 @@ const usePaginationProps = (pagination1, pagination2) => {
display: none !important;
}
`,
+ itemRender: (_, type, originalElement) => {
+ if (type === 'prev') {
+ return (
+
+ {originalElement}
{current}
+
+ );
+ } else {
+ return originalElement;
+ }
+ },
};
}
}, [pagination, t, showTotal]);
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 1f68749e1c..93467f244b 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
@@ -30,7 +30,7 @@ import {
} from '../../../schema-settings';
import { SchemaSettingsBlockHeightItem } from '../../../schema-settings/SchemaSettingsBlockHeightItem';
import { SchemaSettingsBlockTitleItem } from '../../../schema-settings/SchemaSettingsBlockTitleItem';
-
+import { SchemaSettingsPagingMode } from '../../../schema-settings/SchemaSettingsPagingMode';
import { SchemaSettingsConnectDataBlocks } from '../../../schema-settings/SchemaSettingsConnectDataBlocks';
import { SchemaSettingsDataScope } from '../../../schema-settings/SchemaSettingsDataScope';
import { SchemaSettingsTemplate } from '../../../schema-settings/SchemaSettingsTemplate';
@@ -303,6 +303,7 @@ export const TableBlockDesigner = () => {
});
}}
/>
+
{supportTemplate && }
{supportTemplate && (
diff --git a/packages/core/client/src/schema-component/antd/table-v2/__tests__/Table.settings.test.tsx b/packages/core/client/src/schema-component/antd/table-v2/__tests__/Table.settings.test.tsx
index 729a7cc4f8..92d16a9924 100644
--- a/packages/core/client/src/schema-component/antd/table-v2/__tests__/Table.settings.test.tsx
+++ b/packages/core/client/src/schema-component/antd/table-v2/__tests__/Table.settings.test.tsx
@@ -219,6 +219,10 @@ describe('Table.settings', () => {
},
],
},
+ {
+ title: 'Paging mode',
+ type: 'select',
+ },
{
title: 'Save as template',
type: 'modal',
diff --git a/packages/core/client/src/schema-settings/SchemaSettingsPagingMode.tsx b/packages/core/client/src/schema-settings/SchemaSettingsPagingMode.tsx
new file mode 100644
index 0000000000..35fe1b6c01
--- /dev/null
+++ b/packages/core/client/src/schema-settings/SchemaSettingsPagingMode.tsx
@@ -0,0 +1,61 @@
+/**
+ * This file is part of the NocoBase (R) project.
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
+ * Authors: NocoBase Team.
+ *
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
+ * For more information, please refer to: https://www.nocobase.com/agreement.
+ */
+
+import { Field } from '@formily/core';
+import { useField, useFieldSchema } from '@formily/react';
+import React from 'react';
+import { useTranslation } from 'react-i18next';
+import { useTableBlockContext } from '../block-provider';
+import { useDesignable } from '../schema-component/hooks/useDesignable';
+import { SchemaSettingsSelectItem } from './SchemaSettings';
+
+export function SchemaSettingsPagingMode() {
+ const field = useField();
+ const fieldSchema = useFieldSchema();
+ const { t } = useTranslation();
+ const { dn } = useDesignable();
+ const { service } = useTableBlockContext();
+ const options = [
+ {
+ value: 'default',
+ label: t('Default'),
+ },
+ {
+ value: 'simplePaginate',
+ label: t('Simple Paginate'),
+ },
+ ];
+
+ return (
+ {
+ fieldSchema['x-decorator-props'].pagingMode = pagingMode;
+ const params = { ...service.params?.[0] };
+ if (pagingMode === 'simplePaginate') {
+ params['simplePaginate'] = true;
+ } else {
+ delete params['simplePaginate'];
+ }
+ service.run({ params });
+ field.decoratorProps.pagingMode = pagingMode;
+ dn.emit('patch', {
+ schema: {
+ ['x-uid']: fieldSchema['x-uid'],
+ 'x-decorator-props': fieldSchema['x-decorator-props'],
+ },
+ });
+ dn.refresh();
+ }}
+ />
+ );
+}
diff --git a/packages/core/client/src/schema-settings/index.ts b/packages/core/client/src/schema-settings/index.ts
index 1a67832736..1e13637e86 100644
--- a/packages/core/client/src/schema-settings/index.ts
+++ b/packages/core/client/src/schema-settings/index.ts
@@ -21,6 +21,7 @@ export * from './SchemaSettingsSortingRule';
export * from './SchemaSettingsTemplate';
export * from './SchemaSettingsBlockHeightItem';
export * from './setDefaultSortingRulesSchemaSettingsItem';
+export * from './SchemaSettingsPagingMode';
export * from './setTheDataScopeSchemaSettingsItem';
export * from './SchemaSettingsRenderEngine';
export * from './hooks/useGetAriaLabelOfDesigner';
diff --git a/packages/core/data-source-manager/src/default-actions/list.ts b/packages/core/data-source-manager/src/default-actions/list.ts
index 4be722639f..310cdbef7c 100644
--- a/packages/core/data-source-manager/src/default-actions/list.ts
+++ b/packages/core/data-source-manager/src/default-actions/list.ts
@@ -38,7 +38,7 @@ function findArgs(ctx: Context) {
}
async function listWithPagination(ctx: Context) {
- const { page = 1, pageSize = 50 } = ctx.action.params;
+ const { page = 1, pageSize = 50, simplePaginate } = ctx.action.params;
const repository = ctx.getCurrentRepository();
@@ -54,15 +54,24 @@ async function listWithPagination(ctx: Context) {
}
});
- const [rows, count] = await repository.findAndCount(options);
+ if (simplePaginate) {
+ const rows = await repository.find(options);
+ ctx.body = {
+ rows,
+ page: Number(page),
+ pageSize: Number(pageSize),
+ };
+ } else {
+ const [rows, count] = await repository.findAndCount(options);
- ctx.body = {
- count,
- rows,
- page: Number(page),
- pageSize: Number(pageSize),
- totalPage: totalPage(count, pageSize),
- };
+ ctx.body = {
+ count,
+ rows,
+ page: Number(page),
+ pageSize: Number(pageSize),
+ totalPage: totalPage(count, pageSize),
+ };
+ }
}
async function listWithNonPaged(ctx: Context) {