移除 AbsoluteContainer 组件,新增 TableHeightAdaption 组件

This commit is contained in:
hooray
2021-12-15 00:20:58 +08:00
parent bf3a9ccc8b
commit ee380d6944
3 changed files with 30 additions and 21 deletions
@@ -1,18 +0,0 @@
<template>
<div class="absolute-container">
<slot />
</div>
</template>
<style lang="scss" scoped>
.absolute-container {
position: absolute;
width: 100%;
transition: 0.3s;
}
.main-container {
.topbar-container + .main .absolute-container {
height: calc(100% - #{$g-topbar-height});
}
}
</style>
@@ -0,0 +1,28 @@
<template>
<div class="adaption-container">
<slot />
</div>
</template>
<script setup name="TableHeightAdaption">
onMounted(() => {
nextTick(() => {
// 获取表头高度,然后设置 .el-table__body-wrapper 的 height
let height = document.getElementsByClassName('el-table__header-wrapper')[0].offsetHeight
document.getElementsByClassName('el-table__body-wrapper')[0].style.height = `calc(100% - ${height}px)`
})
})
</script>
<style lang="scss" scoped>
.adaption-container {
height: 100%;
overflow: auto;
:deep(.el-table) {
height: 100%;
.el-table__body-wrapper {
overflow-y: auto;
}
}
}
</style>
+2 -3
View File
@@ -9,7 +9,7 @@
</div>
<div class="sidebar-mask" :class="{'show': $store.state.settings.mode === 'mobile' && !$store.state.settings.sidebarCollapse}" @click="$store.commit('settings/toggleSidebarCollapse')" />
<div class="main-container" :style="{'padding-bottom': $route.meta.paddingBottom}">
<Topbar />
<Topbar v-if="!($store.state.settings.menuMode === 'head' && !$store.state.settings.enableSidebarCollapse && !$store.state.settings.enableBreadcrumb)" />
<div class="main">
<router-view v-slot="{ Component, route }">
<transition name="main" mode="out-in" appear>
@@ -172,12 +172,11 @@ function switchMenu(index) {
height: 100%;
flex: auto;
position: relative;
padding: $g-topbar-height 0 0;
overflow: hidden;
transition: 0.3s;
}
.topbar-container + .main {
padding: $g-topbar-height 0 0;
margin: $g-topbar-height 0 0;
}
}
}