// 分页参数 自定义名称
pageParamName: this.pageModel.pageParamName ? this.pageModel.pageParamName : ['page', 'limit'],
// 当前列表显示记录起始数
start: 0,
// 当前列表显示记录结束数
end: 0,
// 总页数
totalPage: 0,
// 记录总数
totalSize: 0,
// 分页请求返回数据
dataList: [] }
},
ready () {
this.getData();
},
methods: {
// 首页
firstClick: function () {
if (this.cur > 1) {
this.cur = 1;
this.getData();
}
},
// 尾页
lastClick: function () {
if (this.cur < this.totalPage) {
this.cur = this.totalPage;
this.getData();
}
},
// 上一页
preClick: function () {
if (this.cur > 1) {
this.cur--;
this.getData();
}
},
// 下一页
nextClick: function () {
if (this.cur < this.totalPage) {
this.cur++;
this.getData();
}
},
// 页码
pageClick: function (data) {
if (data != this.cur) {
this.cur = data;
this.getData();
}
},
// 刷新显示记录数
refreshPageCon: function () {
this.start = (this.cur - 1) * this.limit + 1;
if (this.totalSize >= this.limit * this.cur) {
this.end = this.limit * this.cur;
} else {
this.end = this.totalSize;
}
},
// 分页请求
getData: function () {
let _this = this;
this.param[this.pageParamName[0]] = this.cur;
this.param[this.pageParamName[1]] = this.limit;
Ajax({
url: _this.url,
method: _this.method,
data: _this.param,
callback: function (res) {
// 返回结果数据集
this.dataList = res.data;
// 返回总记录数
_this.totalSize = 25;
_this.totalPage = Math.ceil(_this.totalSize / _this.limit);
_this.refreshPageCon();
_this.$dispatch('refresh', this.dataList);
}
});
},
// 每页显示记录数 下拉
menuChange: function () {
this.getData();
},
getPage: function (curPage, totalPage, pageNum) {
var leftPage, rightPage;
curPage = curPage > 1 ? curPage : 1;
curPage = curPage > totalPage ? totalPage : curPage;
totalPage = curPage > totalPage ? curPage : totalPage;
// 左侧页数
leftPage = curPage - Math.floor(pageNum / 2);
leftPage = leftPage > 1 ? leftPage : 1;
// 右侧页数
rightPage = curPage + Math.floor(pageNum / 2);
rightPage = rightPage > totalPage ? totalPage : rightPage;
var curPageNum = rightPage - leftPage + 1;
// 左侧调整
if (curPageNum < pageNum && leftPage > 1) {
leftPage = leftPage - (pageNum - curPageNum);
leftPage = leftPage > 1 ? leftPage : 1;
curPageNum = rightPage - leftPage + 1;
}
// 右侧调整
if (curPageNum < pageNum && rightPage < totalPage) {










