@@ -31,7 +31,7 @@ Table 重封装组件说明
31
31
</template>
32
32
33
33
<script>
34
- import STable from '@/components/table/ '
34
+ import STable from '@/components'
35
35
36
36
export default {
37
37
components: {
@@ -210,7 +210,7 @@ Table 重封装组件说明
210
210
----
211
211
> 除去 ` a-table ` 自带属性外,还而外提供了一些额外属性属性
212
212
213
-
213
+
214
214
| 属性 | 说明 | 类型 | 默认值 |
215
215
| -------------- | ----------------------------------------------- | ----------------- | ------ |
216
216
| alert | 设置是否显示表格信息栏 | [ object, boolean] | null |
@@ -231,35 +231,43 @@ alert: {
231
231
----
232
232
233
233
> 你可能需要为了与后端提供的接口返回结果一致而去修改以下代码:
234
- (需要注意的是,这里的修改是全局性的,意味着整个项目所有使用该 table 组件都需要遵守这个返回结果定义的字段。)
234
+ > (需要注意的是,这里的修改是全局性的,意味着整个项目所有使用该 table 组件都需要遵守这个返回结果定义的字段。)
235
+ >
236
+ > 文档中的结构有可能由于组件 bug 进行修正而改动。实际修改请以当时最新版本为准
235
237
236
- 修改 ` @/components/table/index.js ` 第 132 行起
238
+ 修改 ` @/components/table/index.js ` 第 156 行起
237
239
238
240
239
241
240
242
``` javascript
241
243
result .then (r => {
242
- this .localPagination = Object .assign ({}, this .localPagination , {
243
- current: r .pageNo , // 返回结果中的当前分页数
244
- total: r .totalCount , // 返回结果中的总记录数
245
- showSizeChanger: this .showSizeChanger ,
246
- pageSize: (pagination && pagination .pageSize ) ||
247
- this .localPagination .pageSize
248
- })
249
-
250
- // 为防止删除数据后导致页面当前页面数据长度为 0 ,自动翻页到上一页
251
- if (r .data .length == 0 && this .localPagination .current != 1 ) {
252
- this .localPagination .current --
253
- this .loadData ()
254
- return
255
- }
244
+ this .localPagination = this .showPagination && Object .assign ({}, this .localPagination , {
245
+ current: r .pageNo , // 返回结果中的当前分页数
246
+ total: r .totalCount , // 返回结果中的总记录数
247
+ showSizeChanger: this .showSizeChanger ,
248
+ pageSize: (pagination && pagination .pageSize ) ||
249
+ this .localPagination .pageSize
250
+ }) || false
251
+ // 为防止删除数据后导致页面当前页面数据长度为 0 ,自动翻页到上一页
252
+ if (r .data .length === 0 && this .showPagination && this .localPagination .current > 1 ) {
253
+ this .localPagination .current --
254
+ this .loadData ()
255
+ return
256
+ }
256
257
257
- // 这里用于判断接口是否有返回 r.totalCount 或 this.showPagination = false
258
- // 当情况满足时,表示数据不满足分页大小,关闭 table 分页功能
259
- ! r .totalCount && [' auto' , false ].includes (this .showPagination ) && (this .localPagination = false )
260
- this .localDataSource = r .data // 返回结果中的数组数据
261
- this .localLoading = false
262
- });
258
+ // 这里用于判断接口是否有返回 r.totalCount 且 this.showPagination = true 且 pageNo 和 pageSize 存在 且 totalCount 小于等于 pageNo * pageSize 的大小
259
+ // 当情况满足时,表示数据不满足分页大小,关闭 table 分页功能
260
+ try {
261
+ if (([' auto' , true ].includes (this .showPagination ) && r .totalCount <= (r .pageNo * this .localPagination .pageSize ))) {
262
+ this .localPagination .hideOnSinglePage = true
263
+ }
264
+ } catch (e) {
265
+ this .localPagination = false
266
+ }
267
+ console .log (' loadData -> this.localPagination' , this .localPagination )
268
+ this .localDataSource = r .data // 返回结果中的数组数据
269
+ this .localLoading = false
270
+ })
263
271
```
264
272
返回 JSON 例子:
265
273
``` json
@@ -330,4 +338,4 @@ result.then(r => {
330
338
更新时间
331
339
----
332
340
333
- 该文档最后更新于: 2019-01-21 AM 08:37
341
+ 该文档最后更新于: 2019-06-23 PM 17:19
0 commit comments