【issues/8374】分页始终显示在底部

pull/8412/head
JEECG 2025-06-10 09:52:27 +08:00
parent fc05fe1aff
commit 9ddad931ff
2 changed files with 25 additions and 3 deletions

View File

@ -222,7 +222,7 @@
// update-end--author:sunjianlei---date:220230630---forQQYUN-5571
);
const { getScrollRef, redoHeight } = useTableScroll(getProps, tableElRef, getColumnsRef, getRowSelectionRef, getDataSourceRef, slots);
const { getScrollRef, redoHeight } = useTableScroll(getProps, tableElRef, getColumnsRef, getRowSelectionRef, getDataSourceRef, slots, getPaginationInfo);
const { customRow } = useCustomRow(getProps, {
setSelectedRowKeys,

View File

@ -15,7 +15,8 @@ export function useTableScroll(
columnsRef: ComputedRef<BasicColumn[]>,
rowSelectionRef: ComputedRef<TableRowSelection<any> | null>,
getDataSourceRef: ComputedRef<Recordable[]>,
slots: Slots
slots: Slots,
getPaginationInfo: ComputedRef<any>
) {
const tableHeightRef: Ref<Nullable<number>> = ref(null);
@ -138,12 +139,33 @@ export function useTableScroll(
// 10+6(padding:10 + padding-bottom:6)
height -= 16;
// update-end--author:liaozhiyang---date:20240603---forTV360X-861
height = (height < minHeight! ? (minHeight as number) : height) ?? height;
height = (height > maxHeight! ? (maxHeight as number) : height) ?? height;
setHeight(height);
bodyEl!.style.height = `${height}px`;
// update-begin--author:liaozhiyang---date:20240609---forissues/8374
if (maxHeight === undefined) {
if (unref(getPaginationInfo) && unref(getDataSourceRef).length) {
const pageSize = unref(getPaginationInfo)?.pageSize;
const current = unref(getPaginationInfo)?.current;
const total = unref(getPaginationInfo)?.total;
const tableBody = tableEl.querySelector('.ant-table-body') as HTMLElement;
const tr = tableEl.querySelector('.ant-table-tbody')?.children ?? [];
const lastrEl = tr[tr.length - 1] as HTMLElement;
const trHeight = lastrEl.offsetHeight;
const dataHeight = trHeight * pageSize;
if (tableBody && lastrEl) {
if (current === 1 && pageSize > unref(getDataSourceRef).length && total <= pageSize) {
tableBody.style.height = `${height}px`;
} else {
tableBody.style.height = `${dataHeight < height ? dataHeight : height}px`;
}
}
}
}
// update-end--author:liaozhiyang---date:20240609---forissues/8374
}
useWindowSizeFn(calcTableHeight, 280);
onMountedOrActivated(() => {