feat: add page size storage function to Component Page
This commit is contained in:
parent
7eeb649530
commit
51efaf1495
1 changed files with 26 additions and 0 deletions
|
@ -144,6 +144,14 @@
|
||||||
nextText: {
|
nextText: {
|
||||||
type: String,
|
type: String,
|
||||||
default: ''
|
default: ''
|
||||||
|
},
|
||||||
|
name: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
|
cachePageSize: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
|
@ -229,6 +237,13 @@
|
||||||
[`${prefixCls}-item-active`]: this.currentPage === this.allPages
|
[`${prefixCls}-item-active`]: this.currentPage === this.allPages
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
},
|
||||||
|
pageSizeKey() {
|
||||||
|
if (this.cachePageSize && this.name !== null) {
|
||||||
|
return `pageSize_${this.name}`;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -273,6 +288,9 @@
|
||||||
this.currentPageSize = pageSize;
|
this.currentPageSize = pageSize;
|
||||||
this.$emit('on-page-size-change', pageSize);
|
this.$emit('on-page-size-change', pageSize);
|
||||||
this.changePage(1);
|
this.changePage(1);
|
||||||
|
if (this.cachePageSize && this.name !== null) {
|
||||||
|
window.localStorage.setItem(this.pageSizeKey, pageSize);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onPage (page) {
|
onPage (page) {
|
||||||
this.changePage(page);
|
this.changePage(page);
|
||||||
|
@ -308,6 +326,14 @@
|
||||||
this.changePage(page);
|
this.changePage(page);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
mounted () {
|
||||||
|
if (this.cachePageSize && this.name !== null) {
|
||||||
|
const pageSize = window.localStorage.getItem(this.pageSizeKey);
|
||||||
|
if (this.pageSizeOpts.includes(pageSize)) {
|
||||||
|
this.currentPageSize = pageSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Add table
Reference in a new issue