mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 03:48:13 +08:00
fix: CRUD2 加载更多时接口page传参始终为1 (#6298)
This commit is contained in:
parent
0cbd4857c3
commit
00c4a216d5
@ -399,7 +399,11 @@ export const CRUDStore = ServiceStore.named('CRUDStore')
|
||||
|
||||
function changePage(page: number, perPage?: number | string) {
|
||||
self.page = page;
|
||||
perPage && (self.perPage = parseInt(perPage as string, 10));
|
||||
perPage && changePerPage(perPage);
|
||||
}
|
||||
|
||||
function changePerPage(perPage: number | string) {
|
||||
self.perPage = parseInt(perPage as string, 10);
|
||||
}
|
||||
|
||||
function selectAction(action: ActionObject) {
|
||||
@ -611,6 +615,7 @@ export const CRUDStore = ServiceStore.named('CRUDStore')
|
||||
updateQuery,
|
||||
fetchInitData,
|
||||
changePage,
|
||||
changePerPage,
|
||||
selectAction,
|
||||
saveRemote,
|
||||
setFilterTogglable,
|
||||
|
@ -413,6 +413,9 @@ export default class CRUD2 extends React.Component<CRUD2Props, any> {
|
||||
* 加载更多动作处理器
|
||||
*/
|
||||
handleLoadMore() {
|
||||
const {store, perPage} = this.props;
|
||||
|
||||
store.changePage(store.page + 1, perPage);
|
||||
this.getData(undefined, undefined, undefined, true);
|
||||
}
|
||||
|
||||
@ -500,7 +503,8 @@ export default class CRUD2 extends React.Component<CRUD2Props, any> {
|
||||
loadDataOnce,
|
||||
loadDataOnceFetchOnFilter,
|
||||
source,
|
||||
columns
|
||||
columns,
|
||||
perPage
|
||||
} = this.props;
|
||||
|
||||
// reload 需要清空用户选择
|
||||
@ -518,7 +522,14 @@ export default class CRUD2 extends React.Component<CRUD2Props, any> {
|
||||
this.lastQuery = store.query;
|
||||
const loadDataMode = loadMore ?? loadType === 'more';
|
||||
|
||||
const data = createObject(store.data, store.query);
|
||||
const data: Record<string, any> = createObject(store.data, store.query);
|
||||
|
||||
// handleLoadMore 是在事件触发后才执行,首次加载并不走到 handleLoadMore
|
||||
// 所以加载更多模式下,首次加载也需要使用设置的 perPage,避免前后 perPage 不一致导致的问题
|
||||
if (loadDataMode && perPage) {
|
||||
store.changePerPage(perPage);
|
||||
}
|
||||
|
||||
isEffectiveApi(api, data)
|
||||
? store
|
||||
.fetchInitData(api, data, {
|
||||
|
Loading…
Reference in New Issue
Block a user