summaryrefslogtreecommitdiff
path: root/src/components/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/common')
-rw-r--r--src/components/common/Pagination.vue31
1 files changed, 15 insertions, 16 deletions
diff --git a/src/components/common/Pagination.vue b/src/components/common/Pagination.vue
index 9e898ca1..0f03cadd 100644
--- a/src/components/common/Pagination.vue
+++ b/src/components/common/Pagination.vue
@@ -58,13 +58,24 @@ export default {
*/
setup (props) {
const { query } = useRoute()
- const pageSize = ref(defaultPageSize)
+ // pageSize取值顺序:1.url;2.缓存;3.pageObj;4.默认值
+ const urlPageSize = parseInt(query.pageSize)
+ const cachePageSize = parseInt(localStorage.getItem(storageKey.pageSize + '-' + localStorage.getItem(storageKey.username) + '-' + props.tableId))
+ const pageObjPageSize = props.pageObj.pageSize
+ const pageSize = ref(urlPageSize || cachePageSize || pageObjPageSize || defaultPageSize)
const currentPageNo = ref(props.storePageNoOnUrl ? (query.pageNo || (props.pageObj.pageNo || 1)) : (props.pageObj.pageNo || 1))
return {
pageSize,
currentPageNo
}
},
+ mounted () {
+ if (this.postPageSizes && this.postPageSizes.length > 0) {
+ this.resetPageSizes()
+ }
+ this.currentPageNo = parseInt(this.currentPageNo)
+ this.current(this.currentPageNo)
+ },
data () {
return {
// pageSize: defaultPageSize,
@@ -147,6 +158,7 @@ export default {
size (val) {
// eslint-disable-next-line vue/no-mutating-props
// this.pageObj.pageNo = 1
+ this.$emit('scrollbarToTop')
this.$emit('pageSize', val)
this.backgroundColor()
@@ -163,11 +175,12 @@ export default {
wrap.scrollTop = 0
}
})
+ this.$emit('scrollbarToTop')
})
},
resetPageSizes: function () {
if (this.postPageSizes) {
- this.pageSizes = this.postPageSizes.map((item) => {
+ this.pageSizes = this.postPageSizes.map(item => {
return {
label: item + this.$t('pageSize'),
value: item
@@ -183,20 +196,6 @@ export default {
// }
}
},
- mounted () {
- if (this.postPageSizes && this.postPageSizes.length > 0) {
- this.pageSize = this.postPageSizes[0]
- this.resetPageSizes()
- } else {
- const pageSize = localStorage.getItem(storageKey.pageSize + '-' + localStorage.getItem(storageKey.username) + '-' + this.tableId)
- if (pageSize != 'undefined' && pageSize != null) {
- this.pageSize = parseInt(pageSize)
- }
- }
-
- this.currentPageNo = parseInt(this.currentPageNo)
- this.current(this.currentPageNo)
- },
watch: {
postPageSizes: {
immediate: true,