修复 crud 有可能会重复请求的问题

This commit is contained in:
liaoxuezhi 2021-03-27 17:20:32 +08:00
parent 21ed82dc1d
commit 4371c686be
2 changed files with 27 additions and 1 deletions

View File

@ -520,7 +520,18 @@ export default class CRUD extends React.Component<CRUDProps, any> {
} else if (
props.api &&
nextProps.api &&
isApiOutdated(props.api, nextProps.api, props.data, nextProps.data)
isApiOutdated(
props.api,
nextProps.api,
store.fetchCtxOf(props.data, {
pageField: props.pageField,
perPageField: props.perPageField
}),
store.fetchCtxOf(nextProps.data, {
pageField: nextProps.pageField,
perPageField: nextProps.perPageField
})
)
) {
this.dataInvalid = true;
}

View File

@ -73,6 +73,21 @@ export const CRUDStore = ServiceStore.named('CRUDStore')
get selectedItemsAsArray() {
return self.selectedItems.concat();
},
fetchCtxOf(
data: any,
options: {
pageField?: string;
perPageField?: string;
}
) {
return createObject(data, {
...self.query,
[options.pageField || 'page']: self.page,
[options.perPageField || 'perPage']: self.perPage,
...data
});
}
}))
.actions(self => {