瀏覽代碼

修复分页组件请求两次问题

RuoYi 3 年之前
父節點
當前提交
9f9a06ab93
共有 2 個文件被更改,包括 11 次插入2 次删除
  1. 9 0
      src/components/Pagination/index.vue
  2. 2 2
      src/views/system/menu/index.vue

+ 9 - 0
src/components/Pagination/index.vue

@@ -1,6 +1,7 @@
 <template>
   <div :class="{ 'hidden': hidden }" class="pagination-container">
     <el-pagination
+      v-if="pageShow"
       :background="background"
       v-model:current-page="currentPage"
       v-model:page-size="pageSize"
@@ -17,6 +18,8 @@
 <script setup>
 import { scrollTo } from '@/utils/scroll-to'
 
+const pageShow = ref(true);
+
 const props = defineProps({
   total: {
     required: true,
@@ -77,6 +80,12 @@ const pageSize = computed({
   }
 })
 function handleSizeChange(val) {
+  if (currentPage.value * val > props.total) {
+    pageShow.value = false;
+    nextTick(() => {
+      pageShow.value = true
+    })
+  }
   emit('pagination', { page: currentPage.value, limit: val })
   if (props.autoScroll) {
     scrollTo(0, 800)

+ 2 - 2
src/views/system/menu/index.vue

@@ -373,8 +373,8 @@ function selected(name) {
 }
 /** 关闭弹窗隐藏图标选择 */
 function handleClose() {
- cancel();
- showChooseIcon.value = false;
+  cancel();
+  showChooseIcon.value = false;
 }
 /** 搜索按钮操作 */
 function handleQuery() {