@@ -109,7 +109,8 @@ export default {
109
109
current : localPageNum ,
110
110
pageSize : this . pageSize ,
111
111
showSizeChanger : this . showSizeChanger
112
- } )
112
+ } ) || false
113
+ console . log ( 'this.localPagination' , this . localPagination )
113
114
this . needTotalList = this . initTotalList ( this . columns )
114
115
this . loadData ( )
115
116
} ,
@@ -135,9 +136,9 @@ export default {
135
136
this . localLoading = true
136
137
const parameter = Object . assign ( {
137
138
pageNo : ( pagination && pagination . current ) ||
138
- this . localPagination . current || this . pageNum ,
139
+ this . showPagination && this . localPagination . current || this . pageNum ,
139
140
pageSize : ( pagination && pagination . pageSize ) ||
140
- this . localPagination . pageSize || this . pageSize
141
+ this . showPagination && this . localPagination . pageSize || this . pageSize
141
142
} ,
142
143
( sorter && sorter . field && {
143
144
sortField : sorter . field
@@ -148,29 +149,36 @@ export default {
148
149
...filters
149
150
}
150
151
)
152
+ console . log ( 'parameter' , parameter )
151
153
const result = this . data ( parameter )
152
154
// 对接自己的通用数据接口需要修改下方代码中的 r.pageNo, r.totalCount, r.data
153
155
// eslint-disable-next-line
154
156
if ( ( typeof result === 'object' || typeof result === 'function' ) && typeof result . then === 'function' ) {
155
157
result . then ( r => {
156
- this . localPagination = Object . assign ( { } , this . localPagination , {
158
+ this . localPagination = this . showPagination && Object . assign ( { } , this . localPagination , {
157
159
current : r . pageNo , // 返回结果中的当前分页数
158
160
total : r . totalCount , // 返回结果中的总记录数
159
161
showSizeChanger : this . showSizeChanger ,
160
162
pageSize : ( pagination && pagination . pageSize ) ||
161
163
this . localPagination . pageSize
162
- } )
164
+ } ) || false
163
165
// 为防止删除数据后导致页面当前页面数据长度为 0 ,自动翻页到上一页
164
- if ( r . data . length === 0 && this . localPagination . current > 1 ) {
166
+ if ( r . data . length === 0 && this . showPagination && this . localPagination . current > 1 ) {
165
167
this . localPagination . current --
166
168
this . loadData ( )
167
169
return
168
170
}
169
171
170
- // 这里用于判断接口是否有返回 r.totalCount 或 this.showPagination = false
172
+ // 这里用于判断接口是否有返回 r.totalCount 且 this.showPagination = true 且 pageNo 和 pageSize 存在 且 totalCount 小于等于 pageNo * pageSize 的大小
171
173
// 当情况满足时,表示数据不满足分页大小,关闭 table 分页功能
172
-
173
- ( ! this . showPagination || ! r . totalCount && this . showPagination === 'auto' ) && ( this . localPagination . hideOnSinglePage = true )
174
+ try {
175
+ if ( ( [ 'auto' , true ] . includes ( this . showPagination ) && r . totalCount <= ( r . pageNo * pagination . pageSize ) ) ) {
176
+ this . localPagination . hideOnSinglePage = true
177
+ }
178
+ } catch ( e ) {
179
+ this . localPagination = false
180
+ }
181
+ console . log ( 'loadData -> this.localPagination' , this . localPagination )
174
182
this . localDataSource = r . data // 返回结果中的数组数据
175
183
this . localLoading = false
176
184
} )
@@ -272,7 +280,9 @@ export default {
272
280
if ( k === 'rowSelection' ) {
273
281
if ( showAlert && this . rowSelection ) {
274
282
// 如果需要使用alert,则重新绑定 rowSelection 事件
283
+ console . log ( 'this.rowSelection' , this . rowSelection )
275
284
props [ k ] = {
285
+ ...this . rowSelection ,
276
286
selectedRows : this . selectedRows ,
277
287
selectedRowKeys : this . selectedRowKeys ,
278
288
onChange : ( selectedRowKeys , selectedRows ) => {
0 commit comments