|
@@ -62,68 +62,71 @@ export function useTableScroll(
|
|
|
if (!unref(getCanResize)) return;
|
|
|
|
|
|
await nextTick();
|
|
|
- const table = unref(tableElRef);
|
|
|
- if (!table) return;
|
|
|
-
|
|
|
- const tableEl: Element = table.$el;
|
|
|
- if (!tableEl) return;
|
|
|
-
|
|
|
- const headEl = tableEl.querySelector('.ant-table-thead ');
|
|
|
-
|
|
|
- if (!headEl) return;
|
|
|
-
|
|
|
- // Table height from bottom
|
|
|
- const { bottomIncludeBody } = getViewportOffset(headEl);
|
|
|
- // Table height from bottom height-custom offset
|
|
|
-
|
|
|
- const paddingHeight = 32;
|
|
|
- const borderHeight = 0;
|
|
|
- // Pager height
|
|
|
- let paginationHeight = 2;
|
|
|
- if (!isBoolean(pagination)) {
|
|
|
- if (!paginationEl) {
|
|
|
- paginationEl = tableEl.querySelector('.ant-pagination') as HTMLElement;
|
|
|
- }
|
|
|
- if (paginationEl) {
|
|
|
- const offsetHeight = paginationEl.offsetHeight;
|
|
|
- paginationHeight += offsetHeight || 0;
|
|
|
- } else {
|
|
|
- // TODO First fix 24
|
|
|
- paginationHeight += 24;
|
|
|
+ //Add a delay to get the correct bottomIncludeBody paginationHeight footerHeight headerHeight
|
|
|
+ setTimeout(() => {
|
|
|
+ const table = unref(tableElRef);
|
|
|
+ if (!table) return;
|
|
|
+
|
|
|
+ const tableEl: Element = table.$el;
|
|
|
+ if (!tableEl) return;
|
|
|
+
|
|
|
+ const headEl = tableEl.querySelector('.ant-table-thead ');
|
|
|
+
|
|
|
+ if (!headEl) return;
|
|
|
+
|
|
|
+ // Table height from bottom
|
|
|
+ const { bottomIncludeBody } = getViewportOffset(headEl);
|
|
|
+ // Table height from bottom height-custom offset
|
|
|
+
|
|
|
+ const paddingHeight = 32;
|
|
|
+ const borderHeight = 0;
|
|
|
+ // Pager height
|
|
|
+ let paginationHeight = 2;
|
|
|
+ if (!isBoolean(pagination)) {
|
|
|
+ if (!paginationEl) {
|
|
|
+ paginationEl = tableEl.querySelector('.ant-pagination') as HTMLElement;
|
|
|
+ }
|
|
|
+ if (paginationEl) {
|
|
|
+ const offsetHeight = paginationEl.offsetHeight;
|
|
|
+ paginationHeight += offsetHeight || 0;
|
|
|
+ } else {
|
|
|
+ // TODO First fix 24
|
|
|
+ paginationHeight += 24;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- let footerHeight = 0;
|
|
|
- if (!isBoolean(pagination)) {
|
|
|
- if (!footerEl) {
|
|
|
- footerEl = tableEl.querySelector('.ant-table-footer') as HTMLElement;
|
|
|
- } else {
|
|
|
- const offsetHeight = footerEl.offsetHeight;
|
|
|
- footerHeight += offsetHeight || 0;
|
|
|
+ let footerHeight = 0;
|
|
|
+ if (!isBoolean(pagination)) {
|
|
|
+ if (!footerEl) {
|
|
|
+ footerEl = tableEl.querySelector('.ant-table-footer') as HTMLElement;
|
|
|
+ } else {
|
|
|
+ const offsetHeight = footerEl.offsetHeight;
|
|
|
+ footerHeight += offsetHeight || 0;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- let headerHeight = 0;
|
|
|
- if (headEl) {
|
|
|
- headerHeight = (headEl as HTMLElement).offsetHeight;
|
|
|
- }
|
|
|
+ let headerHeight = 0;
|
|
|
+ if (headEl) {
|
|
|
+ headerHeight = (headEl as HTMLElement).offsetHeight;
|
|
|
+ }
|
|
|
|
|
|
- let height =
|
|
|
- bottomIncludeBody -
|
|
|
- (resizeHeightOffset || 0) -
|
|
|
- paddingHeight -
|
|
|
- borderHeight -
|
|
|
- paginationHeight -
|
|
|
- footerHeight -
|
|
|
- headerHeight;
|
|
|
+ let height =
|
|
|
+ bottomIncludeBody -
|
|
|
+ (resizeHeightOffset || 0) -
|
|
|
+ paddingHeight -
|
|
|
+ borderHeight -
|
|
|
+ paginationHeight -
|
|
|
+ footerHeight -
|
|
|
+ headerHeight;
|
|
|
|
|
|
- height = (height > maxHeight! ? (maxHeight as number) : height) ?? height;
|
|
|
- setHeight(height);
|
|
|
+ height = (height > maxHeight! ? (maxHeight as number) : height) ?? height;
|
|
|
+ setHeight(height);
|
|
|
|
|
|
- if (!bodyEl) {
|
|
|
- bodyEl = tableEl.querySelector('.ant-table-body');
|
|
|
- }
|
|
|
- bodyEl!.style.height = `${height}px`;
|
|
|
+ if (!bodyEl) {
|
|
|
+ bodyEl = tableEl.querySelector('.ant-table-body');
|
|
|
+ }
|
|
|
+ bodyEl!.style.height = `${height}px`;
|
|
|
+ }, 200);
|
|
|
}
|
|
|
|
|
|
useWindowSizeFn(calcTableHeight, 200);
|