Files
zhgh_squ/src/main/resources/static/components/plugins/TreeLayout.vue
T
2026-06-12 14:38:45 +08:00

102 lines
1.8 KiB
Vue

<template>
<div class="v-tree-layout">
<div class="shrink" :style="'left:' + (showTree ? 'calc(20% - 15px)' : '0')" @click="shrink">
<i v-if="!showTree" class="el-icon-arrow-right"></i>
<i v-else class="el-icon-arrow-left"></i>
</div>
<div class="v-tree-layout-left" :style="{width: showTree ? '20%' : '0'}">
<slot name="tree"></slot>
</div>
<div class="v-tree-layout-right" :style="{width: showTree ? '80%' : '100%'}">
<slot></slot>
</div>
</div>
</template>
<script>
module.exports = {
props: {},
data() {
return {
showTree: true
}
},
methods: {
shrink() {
this.showTree = !this.showTree
}
}
}
</script>
<style>
.shrink {
position: absolute;
height: 30px;
width: 30px;
display: flex;
justify-content: center;
align-items: center;
border-radius: 15px;
background-color: white;
z-index: 99;
top: 0;
bottom: 0;
margin: auto;
box-shadow: 0 0 5px rgb(200, 200, 200);
cursor: pointer;
transition: all 500ms;
}
.shrink:hover {
box-shadow: 0 0 10px rgb(150, 150, 150);
}
.v-tree-layout-left::-webkit-scrollbar {
width: 4px;
height: 10px;
}
.v-tree-layout-left::-webkit-scrollbar-thumb {
border-radius: 10px;
background: #dcdcdc;
}
.v-tree-layout-left::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 5px transparent;
border-radius: 10px;
background: transparent;
}
.v-tree-layout {
width: 100%;
height: 100%;
position: relative;
display: flex;
flex-direction: row;
}
.v-tree-layout-left {
width: 20%;
}
.v-tree-layout-left,
.v-tree-layout-left .el-tree {
background-color: #ffffff;
}
.v-tree-layout-right {
width: 80%;
border-left: 1px solid rgb(240, 240, 240);
}
.v-tree-layout-left,
.v-tree-layout-right {
height: 100%;
box-sizing: border-box;
overflow: auto;
transition: all 500ms;
position: relative;
}
</style>