From b639650397409757e50886126ae3d039d9c6e49d Mon Sep 17 00:00:00 2001 From: lzdjack <51448229+lzdjack@users.noreply.github.com> Date: Sat, 18 Dec 2021 22:25:33 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dtable=E8=87=AA?= =?UTF-8?q?=E9=80=82=E5=BA=94=E9=AB=98=E5=BA=A6=E5=92=8Ctitle=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E5=A3=B0=E6=98=8E=E9=97=AE=E9=A2=98=20(#1496)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1.修复table升级ant3.0导致无法自适应剩余高度 2.修复table升级ant3.0导致BasicColumn类型的title属性无法找到 --- src/components/Table/src/hooks/useTableFooter.ts | 2 +- src/components/Table/src/hooks/useTableScroll.ts | 12 ++++-------- src/components/Table/src/types/table.ts | 6 ++---- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/components/Table/src/hooks/useTableFooter.ts b/src/components/Table/src/hooks/useTableFooter.ts index df8393a0..12285eb0 100644 --- a/src/components/Table/src/hooks/useTableFooter.ts +++ b/src/components/Table/src/hooks/useTableFooter.ts @@ -8,7 +8,7 @@ export function useTableFooter( propsRef: ComputedRef, scrollRef: ComputedRef<{ x: string | number | true; - y: Nullable; + y: string | number | null; scrollToFirstRowOnChange: boolean; }>, tableElRef: Ref, diff --git a/src/components/Table/src/hooks/useTableScroll.ts b/src/components/Table/src/hooks/useTableScroll.ts index a8969da1..f98490bb 100644 --- a/src/components/Table/src/hooks/useTableScroll.ts +++ b/src/components/Table/src/hooks/useTableScroll.ts @@ -1,6 +1,6 @@ import type { BasicTableProps, TableRowSelection, BasicColumn } from '../types/table'; import type { Ref, ComputedRef } from 'vue'; -import { computed, unref, ref, nextTick, watch } from 'vue'; +import { computed, unref, nextTick, watch } from 'vue'; import { getViewportOffset } from '/@/utils/domUtils'; import { isBoolean } from '/@/utils/is'; import { useWindowSizeFn } from '/@/hooks/event/useWindowSizeFn'; @@ -15,8 +15,6 @@ export function useTableScroll( rowSelectionRef: ComputedRef, getDataSourceRef: ComputedRef, ) { - const tableHeightRef: Ref> = ref(null); - const modalFn = useModalContext(); // Greater than animation time 280 @@ -43,8 +41,7 @@ export function useTableScroll( }); } - function setHeight(height: number) { - tableHeightRef.value = height; + function setHeight() { // Solve the problem of modal adaptive height calculation when the form is placed in the modal modalFn?.redoModalHeight?.(); } @@ -141,7 +138,7 @@ export function useTableScroll( headerHeight; height = (height > maxHeight! ? (maxHeight as number) : height) ?? height; - setHeight(height); + setHeight(); bodyEl!.style.height = `${height}px`; } @@ -179,11 +176,10 @@ export function useTableScroll( }); const getScrollRef = computed(() => { - const tableHeight = unref(tableHeightRef); const { canResize, scroll } = unref(propsRef); return { x: unref(getScrollX), - y: canResize ? tableHeight : null, + y: canResize ? '100%' : null, scrollToFirstRowOnChange: false, ...scroll, }; diff --git a/src/components/Table/src/types/table.ts b/src/components/Table/src/types/table.ts index 10f2c8ce..8fbdde26 100644 --- a/src/components/Table/src/types/table.ts +++ b/src/components/Table/src/types/table.ts @@ -1,10 +1,8 @@ import type { VNodeChild } from 'vue'; import type { PaginationProps } from './pagination'; import type { FormProps } from '/@/components/Form'; -import type { - ColumnProps, - TableRowSelection as ITableRowSelection, -} from 'ant-design-vue/lib/table/interface'; +import type { TableRowSelection as ITableRowSelection } from 'ant-design-vue/lib/table/interface'; +import type { ColumnProps } from 'ant-design-vue/lib/table'; import { ComponentType } from './componentType'; import { VueNode } from '/@/utils/propTypes';