@@ -109,7 +109,8 @@ export default {
109109 current : localPageNum ,
110110 pageSize : this . pageSize ,
111111 showSizeChanger : this . showSizeChanger
112- } )
112+ } ) || false
113+ console . log ( 'this.localPagination' , this . localPagination )
113114 this . needTotalList = this . initTotalList ( this . columns )
114115 this . loadData ( )
115116 } ,
@@ -135,9 +136,9 @@ export default {
135136 this . localLoading = true
136137 const parameter = Object . assign ( {
137138 pageNo : ( pagination && pagination . current ) ||
138- this . localPagination . current || this . pageNum ,
139+ this . showPagination && this . localPagination . current || this . pageNum ,
139140 pageSize : ( pagination && pagination . pageSize ) ||
140- this . localPagination . pageSize || this . pageSize
141+ this . showPagination && this . localPagination . pageSize || this . pageSize
141142 } ,
142143 ( sorter && sorter . field && {
143144 sortField : sorter . field
@@ -148,29 +149,36 @@ export default {
148149 ...filters
149150 }
150151 )
152+ console . log ( 'parameter' , parameter )
151153 const result = this . data ( parameter )
152154 // 对接自己的通用数据接口需要修改下方代码中的 r.pageNo, r.totalCount, r.data
153155 // eslint-disable-next-line
154156 if ( ( typeof result === 'object' || typeof result === 'function' ) && typeof result . then === 'function' ) {
155157 result . then ( r => {
156- this . localPagination = Object . assign ( { } , this . localPagination , {
158+ this . localPagination = this . showPagination && Object . assign ( { } , this . localPagination , {
157159 current : r . pageNo , // 返回结果中的当前分页数
158160 total : r . totalCount , // 返回结果中的总记录数
159161 showSizeChanger : this . showSizeChanger ,
160162 pageSize : ( pagination && pagination . pageSize ) ||
161163 this . localPagination . pageSize
162- } )
164+ } ) || false
163165 // 为防止删除数据后导致页面当前页面数据长度为 0 ,自动翻页到上一页
164- if ( r . data . length === 0 && this . localPagination . current > 1 ) {
166+ if ( r . data . length === 0 && this . showPagination && this . localPagination . current > 1 ) {
165167 this . localPagination . current --
166168 this . loadData ( )
167169 return
168170 }
169171
170- // 这里用于判断接口是否有返回 r.totalCount 或 this.showPagination = false
172+ // 这里用于判断接口是否有返回 r.totalCount 且 this.showPagination = true 且 pageNo 和 pageSize 存在 且 totalCount 小于等于 pageNo * pageSize 的大小
171173 // 当情况满足时,表示数据不满足分页大小,关闭 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 * this . localPagination . pageSize ) ) ) {
176+ this . localPagination . hideOnSinglePage = true
177+ }
178+ } catch ( e ) {
179+ this . localPagination = false
180+ }
181+ console . log ( 'loadData -> this.localPagination' , this . localPagination )
174182 this . localDataSource = r . data // 返回结果中的数组数据
175183 this . localLoading = false
176184 } )
@@ -272,7 +280,9 @@ export default {
272280 if ( k === 'rowSelection' ) {
273281 if ( showAlert && this . rowSelection ) {
274282 // 如果需要使用alert,则重新绑定 rowSelection 事件
283+ console . log ( 'this.rowSelection' , this . rowSelection )
275284 props [ k ] = {
285+ ...this . rowSelection ,
276286 selectedRows : this . selectedRows ,
277287 selectedRowKeys : this . selectedRowKeys ,
278288 onChange : ( selectedRowKeys , selectedRows ) => {
0 commit comments