forked from wangjiadong/comp
parent
b1843653bc
commit
055520c299
3 changed files with 159 additions and 120 deletions
@ -1,69 +1,64 @@ |
|||||||
<template> |
<template> |
||||||
<BasicModal v-bind="$attrs" title="配置路径"> |
<BasicModal v-bind="$attrs" @register="register" title="配置路径" @visible-change="visChange" @ok="hanOk"> |
||||||
<a-directory-tree v-model:expandedKeys="expandedKeys" v-model:selectedKeys="selectedKeys" multiple |
<a-tree v-if="ifTree" v-model:expandedKeys="expandedKeys" v-model:selectedKeys="selectedKeys" |
||||||
:tree-data="treeData"></a-directory-tree> |
:load-data="onLoadData" @select="hanSelect" :tree-data="treeData" /> |
||||||
</BasicModal> |
</BasicModal> |
||||||
</template> |
</template> |
||||||
<script lang="ts" setup> |
<script lang="ts" setup> |
||||||
import { BasicModal } from '/@/components/Modal'; |
import { getPathApi, getPathTreeApi } from '/@/api/sys/user'; |
||||||
|
import { BasicModal, useModalInner } from '/@/components/Modal'; |
||||||
|
|
||||||
|
const [register, { closeModal, setModalProps }] = useModalInner((data: any) => { |
||||||
|
currentlySelecte.value = data.path |
||||||
|
target.value = data.target |
||||||
|
}) |
||||||
|
|
||||||
|
const ifTree = ref(true) |
||||||
// tree |
// tree |
||||||
|
|
||||||
import type { TreeProps } from 'ant-design-vue'; |
|
||||||
import { ref } from 'vue'; |
import { ref } from 'vue'; |
||||||
|
import type { TreeProps } from 'ant-design-vue'; |
||||||
const expandedKeys = ref<string[]>(['0-0', '0-1']); |
const expandedKeys = ref<string[]>([]); |
||||||
const selectedKeys = ref<string[]>([]); |
const selectedKeys = ref<string[]>([]); |
||||||
const treeData: TreeProps['treeData'] = [ |
const currentlySelecte = ref('') |
||||||
{ |
const target = ref('') |
||||||
title: 'C:\\', |
|
||||||
key: '0-0', |
const emit = defineEmits(['confirmPath']) |
||||||
children: [ |
function hanOk() { |
||||||
{ |
closeModal() |
||||||
title: 'leaf 0-0', |
emit('confirmPath', currentlySelecte.value, target.value) |
||||||
key: '0-0-0', |
} |
||||||
children: [ |
|
||||||
{ |
const treeData = ref<TreeProps['treeData']>(); |
||||||
title: 'child:\\', |
const onLoadData: TreeProps['loadData'] = treeNode => { |
||||||
key: '0-0-0-0', |
return new Promise<void>(resolve => { |
||||||
children: [ |
if (treeNode.dataRef.children) { |
||||||
{ |
resolve(); |
||||||
title: 'leaf 0-0', |
return; |
||||||
key: '0-0-0-0-0', |
} |
||||||
isLeaf: true, |
asGetPathApi(treeNode.key).then(res => { |
||||||
}, |
treeNode.dataRef.children = res; |
||||||
{ |
treeData.value = [...treeData.value]; |
||||||
title: 'leaf 0-1', |
resolve(); |
||||||
key: '0-0-0-0-1', |
}) |
||||||
isLeaf: true, |
}); |
||||||
}, |
}; |
||||||
], |
|
||||||
}, |
|
||||||
] |
|
||||||
}, |
let isOne = true; |
||||||
{ |
function visChange(visible) { |
||||||
title: 'leaf 0-1', |
if (visible && isOne) { |
||||||
key: '0-0-1', |
getPathApi().then(res => { |
||||||
isLeaf: true, |
treeData.value = res |
||||||
}, |
isOne = false |
||||||
], |
}) |
||||||
}, |
} |
||||||
{ |
} |
||||||
title: 'parent 1', |
|
||||||
key: '0-1', |
function asGetPathApi(path) { |
||||||
children: [ |
return getPathTreeApi(path); |
||||||
{ |
} |
||||||
title: 'leaf 1-0', |
function hanSelect(selectedKeys: any[]) { |
||||||
key: '0-1-0', |
currentlySelecte.value = selectedKeys[0] |
||||||
isLeaf: true, |
} |
||||||
}, |
|
||||||
{ |
|
||||||
title: 'leaf 1-1', |
|
||||||
key: '0-1-1', |
|
||||||
isLeaf: true, |
|
||||||
}, |
|
||||||
], |
|
||||||
}, |
|
||||||
]; |
|
||||||
</script> |
</script> |
Loading…
Reference in new issue