Skip to content

Commit 96ec260

Browse files
committed
fix: s-table May lose pageSize bug, update demo list
1 parent b0aed30 commit 96ec260

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

src/components/table/index.js

+9-6
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,10 @@ export default {
104104
* @param Boolean bool
105105
*/
106106
refresh (bool = false) {
107-
this.loadData(bool ? { current: 1 } : {})
107+
bool && (this.localPagination = Object.assign({}, {
108+
current: 1, pageSize: this.pageSize
109+
}))
110+
this.loadData()
108111
},
109112
/**
110113
* 加载数据方法
@@ -114,11 +117,11 @@ export default {
114117
*/
115118
loadData (pagination, filters, sorter) {
116119
this.localLoading = true
117-
var result = this.data(Object.assign({
120+
const parameter = Object.assign({
118121
pageNo: (pagination && pagination.current) ||
119-
this.localPagination.current,
122+
this.localPagination.current,
120123
pageSize: (pagination && pagination.pageSize) ||
121-
this.localPagination.pageSize
124+
this.localPagination.pageSize
122125
},
123126
(sorter && sorter.field && {
124127
sortField: sorter.field
@@ -128,7 +131,8 @@ export default {
128131
}) || {}, {
129132
...filters
130133
}
131-
))
134+
)
135+
const result = this.data(parameter)
132136
// 对接自己的通用数据接口需要修改下方代码中的 r.pageNo, r.totalCount, r.data
133137
// eslint-disable-next-line
134138
if (result instanceof Promise || '[object Promise]' === result.toString()) {
@@ -140,7 +144,6 @@ export default {
140144
pageSize: (pagination && pagination.pageSize) ||
141145
this.localPagination.pageSize
142146
})
143-
144147
// 为防止删除数据后导致页面当前页面数据长度为 0 ,自动翻页到上一页
145148
if (r.data.length === 0 && this.localPagination.current !== 1) {
146149
this.localPagination.current--

src/views/list/table/List.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363

6464
<div class="table-operator">
6565
<a-button type="primary" icon="plus" @click="$router.push({ name: 'QueryListEdit' })">新建</a-button>
66+
<a-button type="dashed" @click="tableOption(false)" v-if="optionAlertShow">关闭 alert</a-button>
6667
<a-dropdown v-action:edit v-if="selectedRowKeys.length > 0">
6768
<a-menu slot="overlay">
6869
<a-menu-item key="1"><a-icon type="delete" />删除</a-menu-item>
@@ -75,12 +76,10 @@
7576
</a-dropdown>
7677
</div>
7778

78-
<div>
79-
<a-button @click="tableOption(false)" v-if="optionAlertShow">关闭 alert</a-button>
80-
</div>
8179
<s-table
8280
ref="table"
8381
size="default"
82+
rowKey="key"
8483
:columns="columns"
8584
:data="loadData"
8685
:alert="options.alert"
@@ -172,6 +171,7 @@ export default {
172171
],
173172
// 加载数据方法 必须为 Promise 对象
174173
loadData: parameter => {
174+
console.log('loadData.parameter', parameter)
175175
return getServiceList(Object.assign(parameter, this.queryParam))
176176
.then(res => {
177177
return res.result

0 commit comments

Comments
 (0)