feat: add ancestor node
This commit is contained in:
parent
6c927ceb79
commit
308e7d40f3
1 changed files with 6 additions and 2 deletions
|
|
@ -21,6 +21,7 @@ type Props = {
|
|||
iconSize?: string;
|
||||
selectable?: boolean;
|
||||
selectedNode?: Node[];
|
||||
ancestorNode?: Node[];
|
||||
decoration?: {
|
||||
level?: number;
|
||||
bg?: string;
|
||||
|
|
@ -34,7 +35,7 @@ const nodes = defineModel<Node[]>('nodes', { required: true });
|
|||
|
||||
const emits = defineEmits<{
|
||||
(e: 'checked'): void;
|
||||
(e: 'select', node: Node): void;
|
||||
(e: 'select', node: Node, ancestor?: Node[]): void;
|
||||
}>();
|
||||
|
||||
const dec = props.decoration?.find((v) => v.level === (props.level || 0));
|
||||
|
|
@ -162,8 +163,11 @@ function toggleExpand(node: Node) {
|
|||
$emit('checked');
|
||||
}
|
||||
"
|
||||
@select="(v) => $emit('select', v)"
|
||||
@select="(v) => $emit('select', v, props.ancestorNode)"
|
||||
:level="(level || 0) + 1"
|
||||
:ancestorNode="
|
||||
!props.ancestorNode ? [node] : [...props.ancestorNode, node]
|
||||
"
|
||||
:expandable
|
||||
:decoration
|
||||
/>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue