fix: 修复图表页面设置分页无效 (#1257)
Co-authored-by: sealday <zhanglin@daoyoucloud.com> Reviewed-on: daoyoucloud/tachybase#1257 Reviewed-by: sealday <zhanglin@daoyoucloud.com> Co-authored-by: wjh <wwwjh0710@163.com> Co-committed-by: wjh <wwwjh0710@163.com>
This commit is contained in:
parent
2db816a872
commit
304daf4ac0
@ -8,7 +8,7 @@ export class Table extends AntdChart {
|
|||||||
super({ name: 'table', title: 'Table', Component: AntdTable });
|
super({ name: 'table', title: 'Table', Component: AntdTable });
|
||||||
}
|
}
|
||||||
|
|
||||||
getProps({ data, fieldProps, general, advanced }: RenderProps) {
|
getProps({ data, fieldProps, general, advanced, ctx }: RenderProps) {
|
||||||
const columns = data.length
|
const columns = data.length
|
||||||
? Object.keys(data[0]).map((item) => ({
|
? Object.keys(data[0]).map((item) => ({
|
||||||
title: fieldProps[item]?.label || item,
|
title: fieldProps[item]?.label || item,
|
||||||
@ -33,7 +33,7 @@ export class Table extends AntdChart {
|
|||||||
item._key = index;
|
item._key = index;
|
||||||
return item;
|
return item;
|
||||||
});
|
});
|
||||||
const pageSize = advanced?.pagination?.pageSize || 10;
|
const pageSize = ctx.config?.pageSize || advanced?.pagination?.pageSize || 10;
|
||||||
return {
|
return {
|
||||||
// bordered: true,
|
// bordered: true,
|
||||||
size: 'middle',
|
size: 'middle',
|
||||||
@ -42,6 +42,9 @@ export class Table extends AntdChart {
|
|||||||
? false
|
? false
|
||||||
: {
|
: {
|
||||||
pageSize,
|
pageSize,
|
||||||
|
onShowSizeChange: (curr, size) => {
|
||||||
|
ctx.config.setPageSize(size);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
dataSource,
|
dataSource,
|
||||||
columns,
|
columns,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { createContext, useContext } from 'react';
|
import React, { createContext, useContext, useState } from 'react';
|
||||||
import {
|
import {
|
||||||
CollectionManagerProvider,
|
CollectionManagerProvider,
|
||||||
DEFAULT_DATA_SOURCE_KEY,
|
DEFAULT_DATA_SOURCE_KEY,
|
||||||
@ -72,12 +72,14 @@ export const ChartRendererContext = createContext<
|
|||||||
ChartRendererContext.displayName = 'ChartRendererContext';
|
ChartRendererContext.displayName = 'ChartRendererContext';
|
||||||
|
|
||||||
export const ChartRendererProvider: React.FC<ChartRendererProps> = (props) => {
|
export const ChartRendererProvider: React.FC<ChartRendererProps> = (props) => {
|
||||||
const { query, config, collection, transform, dataSource = DEFAULT_DATA_SOURCE_KEY } = props;
|
const { query, config: propsConfig, collection, transform, dataSource = DEFAULT_DATA_SOURCE_KEY } = props;
|
||||||
const { addChart } = useContext(ChartDataContext);
|
const { addChart } = useContext(ChartDataContext);
|
||||||
const { ready, form, enabled } = useContext(ChartFilterContext);
|
const { ready, form, enabled } = useContext(ChartFilterContext);
|
||||||
const { getFilter, hasFilter, appendFilter } = useChartFilter();
|
const { getFilter, hasFilter, appendFilter } = useChartFilter();
|
||||||
const schema = useFieldSchema();
|
const schema = useFieldSchema();
|
||||||
const api = useAPIClient();
|
const api = useAPIClient();
|
||||||
|
const [pageSize, setPageSize] = useState(10);
|
||||||
|
const config = { pageSize, setPageSize, ...propsConfig };
|
||||||
const service = useRequest(
|
const service = useRequest(
|
||||||
(dataSource, collection, query, manual) =>
|
(dataSource, collection, query, manual) =>
|
||||||
new Promise((resolve, reject) => {
|
new Promise((resolve, reject) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user