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 1b727d556b..33e75767e7 100644 --- a/packages/core/client/src/schema-component/antd/list/List.tsx +++ b/packages/core/client/src/schema-component/antd/list/List.tsx @@ -28,6 +28,7 @@ const InternalList = (props) => { const fieldSchema = useFieldSchema(); const Designer = useDesigner(); const meta = service?.data?.meta; + const { pageSize, count, hasNext, page } = meta || {}; const field = useField(); const [schemaMap] = useState(new Map()); const { wrapSSR, componentCls, hashId } = useStyles(); @@ -63,7 +64,51 @@ const InternalList = (props) => { }, [run, params], ); - + const usePagination = () => { + if (!count) { + return { + onChange: onPaginationChange, + total: count || field.value?.length < pageSize || !hasNext ? pageSize * page : pageSize * page + 1, + pageSize: pageSize || 10, + current: page || 1, + showSizeChanger: true, + pageSizeOptions, + simple: true, + className: css` + .ant-pagination-simple-pager { + display: none !important; + } + `, + itemRender: (_, type, originalElement) => { + if (type === 'prev') { + return ( +
+ {originalElement}
{page}
+
+ ); + } else { + return originalElement; + } + }, + }; + } + return { + onChange: onPaginationChange, + total: count || 0, + pageSize: pageSize || 10, + current: page || 1, + showSizeChanger: true, + pageSizeOptions, + }; + }; + const paginationProps = usePagination(); return wrapSSR( {
{field.value?.length