🔄 fix(tables): keep current page after edits & auto-fallback when page becomes empty
Includes ChannelsTable, RedemptionsTable and UsersTable: • Refactor `refresh(page = activePage)` in all three tables so data reloads the requested (or current) page instead of forcing page 1. • On single-row deletion (and bulk deletion in ChannelsTable): – Refresh current page immediately. – If the refreshed page has no data and `activePage > 1`, automatically load the previous page to avoid blank views. • RedemptionsTable: corrected prior bug where `refresh` used `activePage - 1`. • Misc: removed outdated inline comments and aligned search / reset flows. Result: smoother UX—users stay on their working page, and pagination gracefully adjusts after deletions.
This commit is contained in:
@@ -247,9 +247,15 @@ const UsersTable = () => {
|
||||
title: t('确定是否要注销此用户?'),
|
||||
content: t('相当于删除用户,此修改将不可逆'),
|
||||
onOk: () => {
|
||||
manageUser(record.id, 'delete', record).then(() => {
|
||||
removeRecord(record.id);
|
||||
});
|
||||
(async () => {
|
||||
await manageUser(record.id, 'delete', record);
|
||||
await refresh();
|
||||
setTimeout(() => {
|
||||
if (users.length === 0 && activePage > 1) {
|
||||
refresh(activePage - 1);
|
||||
}
|
||||
}, 100);
|
||||
})();
|
||||
},
|
||||
});
|
||||
},
|
||||
@@ -459,13 +465,12 @@ const UsersTable = () => {
|
||||
});
|
||||
};
|
||||
|
||||
const refresh = async () => {
|
||||
setActivePage(1);
|
||||
const refresh = async (page = activePage) => {
|
||||
const { searchKeyword, searchGroup } = getFormValues();
|
||||
if (searchKeyword === '' && searchGroup === '') {
|
||||
await loadUsers(1, pageSize);
|
||||
await loadUsers(page, pageSize);
|
||||
} else {
|
||||
await searchUsers(1, pageSize, searchKeyword, searchGroup);
|
||||
await searchUsers(page, pageSize, searchKeyword, searchGroup);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -606,7 +611,6 @@ const UsersTable = () => {
|
||||
onClick={() => {
|
||||
if (formApi) {
|
||||
formApi.reset();
|
||||
// 重置后立即查询,使用setTimeout确保表单重置完成
|
||||
setTimeout(() => {
|
||||
setActivePage(1);
|
||||
loadUsers(1, pageSize);
|
||||
|
||||
Reference in New Issue
Block a user