suerprisePlus
2024-09-24 0d50fe17a7086791275bc21d70adc79c5497c9d2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<template>
    <div class="leftTreee">
        <div class="treeSearch">
            <el-input v-model="filterText" class="w-50 m-2" placeholder="Type something">
                <template #prefix>
                    <el-icon class="el-input__icon">
                        <search />
                    </el-icon>
                </template>
            </el-input>
        </div>
        <div class="treeBox">
            <div class="elTree">
                <el-tree ref="treeRef" :data="treeVal" :filter-node-method="filterNode" :props="defaultProps"
                    @node-click="handleNodeClick" />
            </div>
        </div>
    </div>
</template>
 
<script setup lang="ts">
import { ref, onMounted, watch } from 'vue';
import { Search } from '@element-plus/icons-vue'
import { ElTree } from 'element-plus'
const showLine = ref(false);
const treeVal = ref([]);
 
const defaultProps = {
    children: 'children',
    label: 'title',
}
 
const setLayerTreeStart = () => {
    treeVal.value = treeData;
 
}
const filterText = ref('')
const treeRef = ref<InstanceType<typeof ElTree>>()
 
const handleNodeClick = () => {
 
}
const filterNode = (value: string, data: Tree) => {
    if (!value) return true
 
    return data.title.includes(value)
}
 
onMounted(() => {
    setLayerTreeStart();
})
watch(filterText, (val) => {
    if(!val){
        
    }
    treeRef.value.filter(val)
})
 
</script>
 
<style lang="scss" scoped>
.leftTreee {
    height: 100%;
    width: 20%;
    background: #dfdfdf;
    display: flex;
    flex-direction: column;
    position: relative;
 
    .treeSearch {
        padding: 5px;
    }
 
    .treeBox {
        flex: 1;
        position: relative;
        padding: 5px;
 
        .elTree {
            position: absolute;
            height: calc(100% - 10px);
            width: calc(100% - 10px);
            overflow: auto;
        }
 
        .elTree::-webkit-scrollbar {
            width: 4px;
        }
 
        .elTree::-webkit-scrollbar-thumb {
            border-radius: 10px;
            background: rgba(0, 0, 0, 0.2);
        }
 
        .elTree::-webkit-scrollbar-track {
            border-radius: 0;
            background: rgba(0, 0, 0, 0.1);
        }
 
 
    }
}
</style>