From f801f4fb11ff8ca08417a9ddf0231fb570fa26e3 Mon Sep 17 00:00:00 2001
From: 疯狂的狮子Li <15040126243@163.com>
Date: 星期一, 24 七月 2023 16:47:51 +0800
Subject: [PATCH] fix 修复 固定页面header穿模问题

---
 src/components/TreeSelect/index.vue |   36 +++++++++++++++++++-----------------
 1 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/src/components/TreeSelect/index.vue b/src/components/TreeSelect/index.vue
index 4ff0e76..3076804 100644
--- a/src/components/TreeSelect/index.vue
+++ b/src/components/TreeSelect/index.vue
@@ -28,9 +28,7 @@
   </div>
 </template>
 
-<script setup>
-
-const { proxy } = getCurrentInstance();
+<script setup lang="ts">
 
 const props = defineProps({
   /* 閰嶇疆椤� */
@@ -68,6 +66,9 @@
   }
 })
 
+
+const selectTree = ref<ElTreeSelectInstance>();
+
 const emit = defineEmits(['update:value']);
 
 const valueId = computed({
@@ -77,16 +78,16 @@
   }
 });
 const valueTitle = ref('');
-const defaultExpandedKey = ref([]);
+const defaultExpandedKey = ref<any[]>([]);
 
-function initHandle() {
+const initHandle = () => {
   nextTick(() => {
     const selectedValue = valueId.value;
-    if(selectedValue !== null && typeof (selectedValue) !== 'undefined') {
-      const node = proxy.$refs.selectTree.getNode(selectedValue)
+    if (selectedValue !== null && typeof (selectedValue) !== 'undefined') {
+      const node = selectTree.value?.getNode(selectedValue)
       if (node) {
         valueTitle.value = node.data[props.objMap.label]
-        proxy.$refs.selectTree.setCurrentKey(selectedValue) // 璁剧疆榛樿閫変腑
+        selectTree.value?.setCurrentKey(selectedValue) // 璁剧疆榛樿閫変腑
         defaultExpandedKey.value = [selectedValue] // 璁剧疆榛樿灞曞紑
       }
     } else {
@@ -94,27 +95,27 @@
     }
   })
 }
-function handleNodeClick(node) {
+const handleNodeClick = (node: any) => {
   valueTitle.value = node[props.objMap.label]
   valueId.value = node[props.objMap.value];
   defaultExpandedKey.value = [];
-  proxy.$refs.treeSelect.blur()
+  selectTree.value?.blur()
   selectFilterData('')
 }
-function selectFilterData(val) {
-  proxy.$refs.selectTree.filter(val)
+const selectFilterData = (val: any) => {
+  selectTree.value?.filter(val)
 }
-function filterNode(value, data) {
+const filterNode = (value: any, data: any) => {
   if (!value) return true
   return data[props.objMap['label']].indexOf(value) !== -1
 }
-function clearHandle() {
+const clearHandle = () => {
   valueTitle.value = ''
   valueId.value = ''
   defaultExpandedKey.value = [];
   clearSelected()
 }
-function clearSelected() {
+const clearSelected = () => {
   const allNode = document.querySelectorAll('#tree-option .el-tree-node')
   allNode.forEach((element) => element.classList.remove('is-current'))
 }
@@ -128,8 +129,9 @@
 })
 </script>
 
-<style lang='scss' scoped>
+<style lang="scss" scoped>
 @import "@/assets/styles/variables.module.scss";
+
 .el-scrollbar .el-scrollbar__view .el-select-dropdown__item {
   padding: 0;
   background-color: #fff;
@@ -153,4 +155,4 @@
   background-color: mix(#fff, $--color-primary, 90%);
   color: $--color-primary;
 }
-</style>
\ No newline at end of file
+</style>

--
Gitblit v1.9.3