fix(page-wraper): fix PageWrapper the scroll bar on the right side of the content area when the user clicks on the tab page to reload the page (#341)
This commit is contained in:
parent
e8fe6a929b
commit
fcff2cb191
|
|
@ -18,7 +18,7 @@
|
||||||
</template>
|
</template>
|
||||||
</PageHeader>
|
</PageHeader>
|
||||||
<div
|
<div
|
||||||
class="m-4 overflow-hidden"
|
class="overflow-hidden"
|
||||||
:class="[`${prefixCls}-content`, contentClass]"
|
:class="[`${prefixCls}-content`, contentClass]"
|
||||||
:style="getContentStyle"
|
:style="getContentStyle"
|
||||||
>
|
>
|
||||||
|
|
@ -109,6 +109,8 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
|
//fix:in contentHeight mode: delay getting footer and header dom element to get the correct height
|
||||||
|
setTimeout(() => {
|
||||||
const footer = unref(footerRef);
|
const footer = unref(footerRef);
|
||||||
const header = unref(headerRef);
|
const header = unref(headerRef);
|
||||||
footerHeight.value = 0;
|
footerHeight.value = 0;
|
||||||
|
|
@ -122,8 +124,23 @@
|
||||||
if (headerEl) {
|
if (headerEl) {
|
||||||
headerHeight += headerEl?.offsetHeight ?? 0;
|
headerHeight += headerEl?.offsetHeight ?? 0;
|
||||||
}
|
}
|
||||||
|
//fix:subtract content's marginTop and marginBottom value
|
||||||
setPageHeight?.(unref(contentHeight) - unref(footerHeight) - headerHeight);
|
let subtractHeight = 0;
|
||||||
|
const attributes = getComputedStyle(
|
||||||
|
document.querySelectorAll('.vben-page-wrapper-content')[0]
|
||||||
|
);
|
||||||
|
if (attributes.marginBottom) {
|
||||||
|
const contentMarginBottom = Number(attributes.marginBottom.replace(/[^\d]/g, ''));
|
||||||
|
subtractHeight += contentMarginBottom;
|
||||||
|
}
|
||||||
|
if (attributes.marginTop) {
|
||||||
|
const contentMarginTop = Number(attributes.marginTop.replace(/[^\d]/g, ''));
|
||||||
|
subtractHeight += contentMarginTop;
|
||||||
|
}
|
||||||
|
setPageHeight?.(
|
||||||
|
unref(contentHeight) - unref(footerHeight) - headerHeight - subtractHeight
|
||||||
|
);
|
||||||
|
}, 400);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -151,6 +168,9 @@
|
||||||
.@{prefix-cls} {
|
.@{prefix-cls} {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
|
.@{prefix-cls}-content {
|
||||||
|
margin: 16px 16px 0 16px;
|
||||||
|
}
|
||||||
.ant-page-header {
|
.ant-page-header {
|
||||||
&:empty {
|
&:empty {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,8 @@ export function useTableScroll(
|
||||||
if (!unref(getCanResize)) return;
|
if (!unref(getCanResize)) return;
|
||||||
|
|
||||||
await nextTick();
|
await nextTick();
|
||||||
|
//Add a delay to get the correct bottomIncludeBody paginationHeight footerHeight headerHeight
|
||||||
|
setTimeout(() => {
|
||||||
const table = unref(tableElRef);
|
const table = unref(tableElRef);
|
||||||
if (!table) return;
|
if (!table) return;
|
||||||
|
|
||||||
|
|
@ -124,6 +126,7 @@ export function useTableScroll(
|
||||||
bodyEl = tableEl.querySelector('.ant-table-body');
|
bodyEl = tableEl.querySelector('.ant-table-body');
|
||||||
}
|
}
|
||||||
bodyEl!.style.height = `${height}px`;
|
bodyEl!.style.height = `${height}px`;
|
||||||
|
}, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
useWindowSizeFn(calcTableHeight, 200);
|
useWindowSizeFn(calcTableHeight, 200);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue