当删除第二页的最后一条数据后,自动获取第一页
公共方法
export function calcPageNo (total, pageNo = 1, pageSize = 10, delNum = 1) {
const restNum = total - pageSize * (pageNo - 1)
let pageNoDiff = Math.floor((delNum - restNum) / pageSize) + 1
pageNoDiff < 0 && (pageNoDiff = 0)
pageNo = pageNo - pageNoDiff
pageNo < 1 && (pageNo = 1)
return pageNo
}
删除操作后
let pageNo = calcPageNo(
this.pagination.total,
this.pagination.current,
this.pagination.pageSize,
1
)
this.pagination.current = pageNo