通过getTotal判断more是否true

This commit is contained in:
wkj 2025-06-13 13:37:34 +08:00
parent dbd52c8f26
commit e686d60bb4
3 changed files with 23 additions and 4 deletions

View File

@ -1018,12 +1018,17 @@ class ListNode extends EntityNode {
const { data, total } = sr; const { data, total } = sr;
assert(data); assert(data);
const count = Object.keys(data).length; const count = Object.keys(data).length;
const getTotal = this.getTotal;
this.pagination.more = count === this.pagination.pageSize; this.pagination.more = count === this.pagination.pageSize;
if (typeof currentPage === 'number' && !append) { if (typeof currentPage === 'number' && !append) {
this.pagination.currentPage = currentPage; this.pagination.currentPage = currentPage;
} }
if (typeof total === 'number') { if (typeof total === 'number') {
this.pagination.total = total; this.pagination.total = total;
if (typeof getTotal === 'number' && this.pagination.more && total < getTotal) {
const pages = Math.floor((total - 1) / this.pagination.pageSize) + 1;
this.pagination.more = this.pagination.currentPage + 1 < pages;
}
} }
if (append) { if (append) {
this.pagination.count += count; this.pagination.count += count;
@ -2288,7 +2293,8 @@ export class RunningTree extends Feature {
// 切换分页pageSize就重新设置 // 切换分页pageSize就重新设置
return node.setPagination({ return node.setPagination({
pageSize, pageSize,
currentPage: 0 currentPage: 0,
total: undefined,
}); });
} }
setCurrentPage(path, currentPage) { setCurrentPage(path, currentPage) {

View File

@ -1021,12 +1021,17 @@ class ListNode extends EntityNode {
const { data, total } = sr; const { data, total } = sr;
(0, assert_1.assert)(data); (0, assert_1.assert)(data);
const count = Object.keys(data).length; const count = Object.keys(data).length;
const getTotal = this.getTotal;
this.pagination.more = count === this.pagination.pageSize; this.pagination.more = count === this.pagination.pageSize;
if (typeof currentPage === 'number' && !append) { if (typeof currentPage === 'number' && !append) {
this.pagination.currentPage = currentPage; this.pagination.currentPage = currentPage;
} }
if (typeof total === 'number') { if (typeof total === 'number') {
this.pagination.total = total; this.pagination.total = total;
if (typeof getTotal === 'number' && this.pagination.more && total < getTotal) {
const pages = Math.floor((total - 1) / this.pagination.pageSize) + 1;
this.pagination.more = this.pagination.currentPage + 1 < pages;
}
} }
if (append) { if (append) {
this.pagination.count += count; this.pagination.count += count;
@ -2291,7 +2296,8 @@ class RunningTree extends Feature_1.Feature {
// 切换分页pageSize就重新设置 // 切换分页pageSize就重新设置
return node.setPagination({ return node.setPagination({
pageSize, pageSize,
currentPage: 0 currentPage: 0,
total: undefined,
}); });
} }
setCurrentPage(path, currentPage) { setCurrentPage(path, currentPage) {

View File

@ -1261,12 +1261,18 @@ class ListNode<
const { data, total } = sr; const { data, total } = sr;
assert(data); assert(data);
const count = Object.keys(data).length; const count = Object.keys(data).length;
const getTotal = this.getTotal;
this.pagination.more = count === this.pagination.pageSize; this.pagination.more = count === this.pagination.pageSize;
if (typeof currentPage === 'number' && !append) { if (typeof currentPage === 'number' && !append) {
this.pagination.currentPage = currentPage; this.pagination.currentPage = currentPage;
} }
if (typeof total === 'number') { if (typeof total === 'number') {
this.pagination.total = total; this.pagination.total = total;
if (typeof getTotal === 'number' && this.pagination.more && total < getTotal) {
const pages = Math.floor((total - 1) / this.pagination.pageSize) + 1;
this.pagination.more = this.pagination.currentPage + 1 < pages
}
} }
if (append) { if (append) {
this.pagination.count += count; this.pagination.count += count;
@ -2775,8 +2781,9 @@ export class RunningTree<ED extends EntityDict & BaseEntityDict> extends Feature
// 切换分页pageSize就重新设置 // 切换分页pageSize就重新设置
return node.setPagination({ return node.setPagination({
pageSize, pageSize,
currentPage: 0 currentPage: 0,
}); total: undefined,
} as any);
} }
setCurrentPage<T extends keyof ED>(path: string, currentPage: number) { setCurrentPage<T extends keyof ED>(path: string, currentPage: number) {