Skip to content

Commit 8ca1ae8

Browse files
committed
fix: #56 current page -1 refresh table
1 parent 1896271 commit 8ca1ae8

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/components/table/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ export default {
112112
)
113113
)
114114

115+
// 对接自己的通用数据接口需要修改下方代码中的 r.pageNo, r.totalCount, r.data
115116
if (result instanceof Promise) {
116117
result.then(r => {
117118
this.localPagination = Object.assign({}, this.localPagination, {
@@ -121,7 +122,16 @@ export default {
121122
pageSize: (pagination && pagination.pageSize) ||
122123
this.localPagination.pageSize
123124
})
125+
126+
// 为防止删除数据后导致页面当前页面数据长度为 0 ,自动翻页到上一页
127+
if (r.data.length == 0 && this.localPagination.current != 1) {
128+
this.localPagination.current--
129+
this.loadData()
130+
return
131+
}
124132

133+
// 这里用于判断接口是否有返回 r.totalCount 或 this.showPagination = false
134+
// 当情况满足时,表示数据不满足分页大小,关闭 table 分页功能
125135
!r.totalCount && ['auto', false].includes(this.showPagination) && (this.localPagination = false)
126136
this.localDataSource = r.data // 返回结果中的数组数据
127137
this.localLoading = false

0 commit comments

Comments
 (0)