Commit 822f4e819209d0a0044fd7f786ab6b0016af3788

Authored by YunaiV
1 parent 4efb6c08

v3.8.2 修复分页组件请求两次问题(I4SQOR)

yudao-ui-admin/src/components/Pagination/index.vue
1 <template> 1 <template>
2 <div :class="{'hidden':hidden}" class="pagination-container"> 2 <div :class="{'hidden':hidden}" class="pagination-container">
3 <el-pagination 3 <el-pagination
  4 + v-if="pageShow"
4 :background="background" 5 :background="background"
5 :current-page.sync="currentPage" 6 :current-page.sync="currentPage"
6 :page-size.sync="pageSize" 7 :page-size.sync="pageSize"
7 :layout="layout" 8 :layout="layout"
8 :page-sizes="pageSizes" 9 :page-sizes="pageSizes"
  10 + :pager-count="pagerCount"
9 :total="total" 11 :total="total"
10 v-bind="$attrs" 12 v-bind="$attrs"
11 @size-change="handleSizeChange" 13 @size-change="handleSizeChange"
@@ -60,6 +62,11 @@ export default { @@ -60,6 +62,11 @@ export default {
60 default: false 62 default: false
61 } 63 }
62 }, 64 },
  65 + data() {
  66 + return {
  67 + pageShow: true
  68 + };
  69 + },
63 computed: { 70 computed: {
64 currentPage: { 71 currentPage: {
65 get() { 72 get() {
@@ -80,6 +87,12 @@ export default { @@ -80,6 +87,12 @@ export default {
80 }, 87 },
81 methods: { 88 methods: {
82 handleSizeChange(val) { 89 handleSizeChange(val) {
  90 + if (this.currentPage * val > this.total) {
  91 + this.pageShow = false;
  92 + this.$nextTick(() => {
  93 + this.pageShow = true
  94 + })
  95 + }
83 this.$emit('pagination', { page: this.currentPage, limit: val }) 96 this.$emit('pagination', { page: this.currentPage, limit: val })
84 if (this.autoScroll) { 97 if (this.autoScroll) {
85 scrollTo(0, 800) 98 scrollTo(0, 800)