表格第二页只有一条数据,这时删除后,拉取刷新表格,发现表格分页跳到第一页,但是总数是20条,
页面也没数据,这其实是分页的current值还是2导致
直接上代码
handleDel(taskRow) {
this.$confirm('此操作将删除该数据, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
delTaskLog(taskRow.id).then(res => {
this.$message.success('操作成功')
this.reSizePage()
this.loadData()
}).catch(error => {
this.$message.error(error.msg)
})
}).catch(() => {
this.$message.info('已取消删除')
})
},
reSizePage(num) {
const totalPage = Math.ceil((this.pageInfo.total - 1) / this.pageInfo.size)
const pagenum = this.pageInfo.current > totalPage ? totalPage : this.pageInfo.current
this.pageInfo.current = pagenum < 1 ? 1 : pagenum
}
getTableData(){
fetchPage(cleanObject(obj)).then(response => {
const { data } = response.data.data
this.tableData = data.records
this.pageInfo.pageTotal = data.records.length
this.pageInfo.total = data.total
})
}
handleDel(ids) {
this.$confirm('此操作将删除该数据, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
particle.delParticle({ ids: ids }).then(res => {
this.$message.success('操作成功')
this.reSizePage(ids.length)
this.loadData()
}).catch(error => {
this.$message.error(error.msg)
})
}).catch(() => {
this.$message.info('已取消删除')
})
},
reSizePage(num) {
if (num === this.pageInfo.pageTotal) {
this.pageInfo.current = (this.pageInfo.current - 1) || 1
}
}
IPage resultPage = this.page(fdParticlePageDTO.getPage(), wrapper1.lambda().orderByDesc(FdParticle::getUpdateTime).eq(FdParticle::getType,fdParticlePageDTO.getType()));
if (fdParticlePageDTO.getPage().getCurrent() > 1 && resultPage.getRecords().size() == 0){
fdParticlePageDTO.getPage().setCurrent(fdParticlePageDTO.getPage().getCurrent() -1);
resultPage = this.page(fdParticlePageDTO.getPage(), wrapper1.lambda().orderByDesc(FdParticle::getUpdateTime).eq(FdParticle::getType,fdParticlePageDTO.getType()));
}
|