From d6f65d476e07a62e63b2635f8f1f082eee4d7a83 Mon Sep 17 00:00:00 2001 From: Lowell Date: Tue, 12 Oct 2021 09:11:50 +0800 Subject: [PATCH] =?UTF-8?q?fix(Table):=20=E8=A7=A3=E5=86=B3=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E4=BA=86=E5=88=86=E9=A1=B5=E7=9A=84=E6=83=85=E5=86=B5?= =?UTF-8?q?=E4=B8=8B=EF=BC=8C=E8=B0=83=E6=95=B4=E8=A1=A8=E6=A0=BC=E5=88=86?= =?UTF-8?q?=E9=A1=B5=E6=9D=A1=E6=95=B0=E5=90=8E=EF=BC=8C=E5=A6=82=E6=9E=9C?= =?UTF-8?q?=E7=BF=BB=E9=A1=B5=EF=BC=8C=E5=88=86=E9=A1=B5=E6=9D=A1=E6=95=B0?= =?UTF-8?q?=E4=BC=9A=E9=87=8D=E7=BD=AE=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82?= =?UTF-8?q?=20(#1270)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.zh_CN.md | 1 + mock/demo/table-demo.ts | 2 +- .../Table/src/hooks/usePagination.tsx | 22 ++++++++++--------- src/views/demo/table/FetchTable.vue | 1 + 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.zh_CN.md b/CHANGELOG.zh_CN.md index eac37a96..2abc2600 100644 --- a/CHANGELOG.zh_CN.md +++ b/CHANGELOG.zh_CN.md @@ -11,6 +11,7 @@ - 修复`inset`属性不起作用的问题 - 修复`useTable`与`BasicTable`实例的`reload`方法`await`表现不一致的问题 - 修复`clickToRowSelect`会无视行选择框 disabled 状态的问题 + - 修复`BasicTable`在某些情况下,分页会被重置的问题 - **BasicModal** - 修复点击遮罩、按下`Esc`键都不能关闭`Modal`的问题 - 修复点击关闭按钮、最大化按钮旁边的空白区域也会导致`Modal`关闭的问题 diff --git a/mock/demo/table-demo.ts b/mock/demo/table-demo.ts index 2fae797f..f3a0f16f 100644 --- a/mock/demo/table-demo.ts +++ b/mock/demo/table-demo.ts @@ -12,7 +12,7 @@ function getRandomPics(count = 10): string[] { const demoList = (() => { const result: any[] = []; - for (let index = 0; index < 60; index++) { + for (let index = 0; index < 200; index++) { result.push({ id: `${index}`, beginTime: '@datetime', diff --git a/src/components/Table/src/hooks/usePagination.tsx b/src/components/Table/src/hooks/usePagination.tsx index 4fb2362f..ba310bd1 100644 --- a/src/components/Table/src/hooks/usePagination.tsx +++ b/src/components/Table/src/hooks/usePagination.tsx @@ -1,6 +1,6 @@ import type { PaginationProps } from '../types/pagination'; import type { BasicTableProps } from '../types/table'; -import { computed, unref, ref, ComputedRef, watchEffect } from 'vue'; +import { computed, unref, ref, ComputedRef, watch } from 'vue'; import { LeftOutlined, RightOutlined } from '@ant-design/icons-vue'; import { isBoolean } from '/@/utils/is'; import { PAGE_SIZE, PAGE_SIZE_OPTIONS } from '../const'; @@ -27,15 +27,17 @@ export function usePagination(refProps: ComputedRef) { const configRef = ref({}); const show = ref(true); - watchEffect(() => { - const { pagination } = unref(refProps); - if (!isBoolean(pagination) && pagination) { - configRef.value = { - ...unref(configRef), - ...(pagination ?? {}), - }; - } - }); + watch( + () => unref(refProps).pagination, + (pagination) => { + if (!isBoolean(pagination) && pagination) { + configRef.value = { + ...unref(configRef), + ...(pagination ?? {}), + }; + } + }, + ); const getPaginationInfo = computed((): PaginationProps | boolean => { const { pagination } = unref(refProps); diff --git a/src/views/demo/table/FetchTable.vue b/src/views/demo/table/FetchTable.vue index 21c4dffe..8d9efa35 100644 --- a/src/views/demo/table/FetchTable.vue +++ b/src/views/demo/table/FetchTable.vue @@ -22,6 +22,7 @@ title: '远程加载示例', api: demoListApi, columns: getBasicColumns(), + pagination: { pageSize: 10 }, }); function handleReloadCurrent() { reload(); -- GitLab