pda-cli/src/dev/core/model/pagination.model.js
2025-08-15 16:25:44 +08:00

97 lines
1.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

export class PaginationModel {
/**
* 页码从1开始
*/
pageNum = 1;
/**
* 页面大小
*/
pageSize = 10;
size = 0;
orderBy = null;
/**
* 起始行
*/
startRow = 1;
/**
*
* 末行
*/
endRow = 0;
/**
* 总数
*/
total = 0;
/**
* 总页数
*/
pages = 0;
data = [];
firstPage = 1;
prePage = 0;
nextPage = 0;
lastPage = 1;
isFirstPage = true;
/**
* 是否是最后一页
*/
isLastPage = false;
hasPreviousPage = false
/**
* 是否有下一页
*/
hasNextPage = false;
navigatePages = 8;
navigatepageNums = [1];
isLast = false;
// <!--通过status设置组件的状态加载前值为loadmore加载中为loading没有数据为nomore-->
status = 'nomore';
refreshPage(data) {
for (let attr in data) {
this[attr] = data[attr]
}
if (this.hasNextPage) {
this.pageNum = this.pageNum + 1
this.status = 'loadmore'
} else {
this.status = 'nomore'
}
return data
}
/**
* 分页
* pagination[page]
* pagination[perpage]
* 排序
* sort[field]
* sort[sort]
*/
appendToUrl(pageNum, pageSize) {
if (pageNum) {
this.pageNum = pageNum;
}
if (pageSize) {
this.pageSize = pageSize;
}
return `pageNum=${this.pageNum}&pageSize=${this.pageSize}`
}
}