|
@@ -18,7 +18,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import {onMounted, ref} from 'vue'
|
|
|
+import {onMounted, ref, watch} from 'vue'
|
|
|
import {getArrValue} from "js-fast-way";
|
|
|
|
|
|
//参数
|
|
@@ -64,6 +64,10 @@ const props = defineProps({
|
|
|
type: Boolean,
|
|
|
default: false,
|
|
|
},
|
|
|
+ autoExpandKey: {
|
|
|
+ type: Array,
|
|
|
+ default: () => ([]),
|
|
|
+ },
|
|
|
})
|
|
|
|
|
|
//节点数据
|
|
@@ -75,6 +79,7 @@ const isRadio = ref(props.radio)
|
|
|
const isStrictly = ref(props.strictly)
|
|
|
const isCounts = ref(props.counts)
|
|
|
const currentNodeKey = ref(props.currentKey)
|
|
|
+const AutoExpandKeys = ref(props.autoExpandKey)
|
|
|
|
|
|
//事件
|
|
|
const emit = defineEmits(['load', 'nodeTap'])
|
|
@@ -89,6 +94,13 @@ onMounted(() => {
|
|
|
})
|
|
|
})
|
|
|
|
|
|
+//监听
|
|
|
+watch(() => [
|
|
|
+ props.autoExpandKey
|
|
|
+], ([keys]) => {
|
|
|
+ AutoExpandKeys.value = keys
|
|
|
+}, {deep: true})
|
|
|
+
|
|
|
const treeLoadTap = (item) => {
|
|
|
getLazyLoad(item)
|
|
|
}
|
|
@@ -141,6 +153,16 @@ const setLazyLoad = (data, arr) => {
|
|
|
if (data.level === 0) {
|
|
|
nodeData.value = newNodeData
|
|
|
}
|
|
|
+ //处理自动展开
|
|
|
+ //const keys = getArrValue(AutoExpandKeys.value)
|
|
|
+ /*if (keys.length === nodeItem.level) {
|
|
|
+ if (keys[nodeItem.level-1] === nodeItem.key) {
|
|
|
+ nodeItem.isExpand = true
|
|
|
+ emit('load', nodeItem, (loadData) => {
|
|
|
+ setLazyLoad(nodeItem, loadData)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }*/
|
|
|
}
|
|
|
}
|
|
|
|