Skip to content

Commit

Permalink
add showPager prop
Browse files Browse the repository at this point in the history
增加showPager参数,控制表格分页是否需要,默认为true
  • Loading branch information
jiahengaa committed Oct 30, 2020
1 parent 84a477d commit 264a1aa
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions src/components/table/table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
<slot name="footer"></slot>
</div>

<div style="margin-top: 15px">
<div style="margin-top: 15px" v-if="showPager">
<Page
show-total
:filterResultL="localeFilterResultL"
Expand Down Expand Up @@ -397,6 +397,10 @@ export default {
resetFilter: {
type: String,
},
showPager: {
type: Boolean,
default: true,
},
},
data() {
return {
Expand Down Expand Up @@ -745,11 +749,16 @@ export default {
this.getRenderData();
},
getRenderData() {
var skipNum = (this.currentIndex - 1) * this.currentSize;
this.renderData =
skipNum + this.currentSize >= this.rebuildData.length
? this.rebuildData.slice(skipNum, this.rebuildData.length)
: this.rebuildData.slice(skipNum, skipNum + this.currentSize);
if (this.showPager) {
var skipNum = (this.currentIndex - 1) * this.currentSize;
this.renderData =
skipNum + this.currentSize >= this.rebuildData.length
? this.rebuildData.slice(skipNum, this.rebuildData.length)
: this.rebuildData.slice(skipNum, skipNum + this.currentSize);
} else {
this.renderData = this.rebuildData;
}
},
makeFilterRows(tempColRows) {
let hRows = [];
Expand Down Expand Up @@ -1359,8 +1368,12 @@ export default {
this.rebuildDataStr = JSON.stringify(
this.makeDataWithSortAndFilter(sender, column)
);
this.$refs.page.currentPage = 1;
this.currentIndex = 1;
if (this.showPager) {
this.$refs.page.currentPage = 1;
this.currentIndex = 1;
}
this.getRenderData();
},
makeObjData() {
Expand Down

0 comments on commit 264a1aa

Please sign in to comment.