You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
1.7 KiB
Vue
79 lines
1.7 KiB
Vue
<template>
|
|
<div class="m-4 mr-0 overflow-hidden bg-white">
|
|
<BasicTree
|
|
ref="asyncExpandTreeRef"
|
|
treeWrapperClassName="h-[calc(100%-35px)] overflow-auto"
|
|
:clickRowToExpand="false"
|
|
:treeData="treeData"
|
|
:fieldNames="{ key: 'id', title: 'name' }"
|
|
@select="handleSelect"
|
|
/>
|
|
</div>
|
|
</template>
|
|
<script lang="ts" setup>
|
|
import { onMounted, ref, nextTick, unref } from 'vue';
|
|
import { BasicTree, TreeItem, TreeActionType } from '@/components/Tree';
|
|
import { getChildrenTree } from '@/api/demo/system';
|
|
import { isArray } from '@/utils/is';
|
|
|
|
const emit = defineEmits(['select']);
|
|
|
|
const treeData: any = ref([]);
|
|
const asyncExpandTreeRef = ref<Nullable<TreeActionType>>(null);
|
|
|
|
async function fetch() {
|
|
treeData.value = [
|
|
{
|
|
id: 'meitiku',
|
|
name: '媒体库',
|
|
children: [
|
|
// {
|
|
// id: '',
|
|
// name: '全部资源',
|
|
// },
|
|
{
|
|
id: '1',
|
|
name: '可见光',
|
|
},
|
|
{
|
|
id: '2',
|
|
name: '红外照片',
|
|
},
|
|
{
|
|
id: '3',
|
|
name: '变焦照片',
|
|
},
|
|
{
|
|
id: '4',
|
|
name: '广角照片',
|
|
},
|
|
{
|
|
id: '5',
|
|
name: '视频资源',
|
|
},
|
|
{
|
|
id: '0',
|
|
name: '其他文件',
|
|
},
|
|
],
|
|
},
|
|
];
|
|
|
|
// 显示到一级
|
|
nextTick(() => {
|
|
unref(asyncExpandTreeRef)?.filterByLevel(1);
|
|
});
|
|
}
|
|
|
|
function handleSelect(keys) {
|
|
emit('select', keys[0]);
|
|
}
|
|
|
|
onMounted(() => {
|
|
fetch();
|
|
});
|
|
defineExpose({
|
|
fetch,
|
|
});
|
|
</script>
|