|
@@ -15,6 +15,7 @@
|
|
|
|
|
|
<script>
|
|
|
import { scrollTo } from '@/utils/scroll-to'
|
|
|
+import { Searchs } from '@/helpers'
|
|
|
export default {
|
|
|
name: 'Pagination',
|
|
|
props: {
|
|
@@ -51,6 +52,10 @@ export default {
|
|
|
hidden: {
|
|
|
type: Boolean,
|
|
|
default: false
|
|
|
+ },
|
|
|
+ sync: {
|
|
|
+ type: Boolean,
|
|
|
+ default: false
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
@@ -59,7 +64,6 @@ export default {
|
|
|
return this.page
|
|
|
},
|
|
|
set (val) {
|
|
|
- console.log(this)
|
|
|
this.$emit('update:page', val)
|
|
|
}
|
|
|
},
|
|
@@ -72,18 +76,38 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
+ mounted() {
|
|
|
+ if (this.sync) {
|
|
|
+ const searchs = new Searchs(this.$route.fullPath)
|
|
|
+ const active = searchs.get()
|
|
|
+ for (const key in active.page) {
|
|
|
+ if (active.page.hasOwnProperty(key)) {
|
|
|
+ const item = active.page[key];
|
|
|
+ this.$emit('update:' + key, item)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
methods: {
|
|
|
+ syncStore() {
|
|
|
+ if (this.sync) {
|
|
|
+ const searchs = new Searchs(this.$route.fullPath)
|
|
|
+ searchs.update(this._props, undefined, 'page')
|
|
|
+ }
|
|
|
+ },
|
|
|
handleSizeChange (val) {
|
|
|
this.$emit('pagination', { page: this.currentPage, limit: val })
|
|
|
if (this.autoScroll) {
|
|
|
scrollTo(0, 800)
|
|
|
}
|
|
|
+ this.syncStore()
|
|
|
},
|
|
|
handleCurrentChange (val) {
|
|
|
this.$emit('pagination', { page: val, limit: this.pageSize })
|
|
|
if (this.autoScroll) {
|
|
|
scrollTo(0, 800)
|
|
|
}
|
|
|
+ this.syncStore()
|
|
|
}
|
|
|
}
|
|
|
}
|