add 树型框可以不半选父级

This commit is contained in:
2023-05-12 15:56:44 +08:00
parent f87a5bb70a
commit 72e79b3361
5 changed files with 34 additions and 15 deletions

View File

@@ -36,6 +36,7 @@ export interface TreeNodeProps {
collapseTransition: boolean;
onlyIconControl: boolean;
hideicon?: boolean;
selectParent:boolean;
}
interface TreeNodeEmits {
@@ -130,9 +131,11 @@ const isChildAllSelected = computed(() => {
return (node: TreeData): boolean => {
if (props.checkStrictly) {
return false;
} else {
} else if(props.selectParent) {
let res = _isChildAllSelected(node);
return res;
}else{
return false
}
};
});
@@ -198,6 +201,7 @@ const isChildAllSelected = computed(() => {
:checkStrictly="checkStrictly"
:only-icon-control="onlyIconControl"
:hideicon="props.hideicon"
:select-parent="props.selectParent"
@node-click="recursiveNodeClick"
>
<template v-if="$slots.title" v-slot:title="slotProp: { data: any }">

View File

@@ -39,6 +39,7 @@ export interface TreeProps {
showCheckbox?: boolean;
replaceFields?: ReplaceFieldsOptions;
hideicon?: boolean;
selectParent?: boolean;
}
interface TreeEmits {
@@ -65,6 +66,7 @@ const props = withDefaults(defineProps<TreeProps>(), {
title: "title",
};
},
selectParent:true
});
const slots = useSlots();
@@ -146,6 +148,7 @@ function handleClick(node: TreeData) {
:only-icon-control="onlyIconControl"
@node-click="handleClick"
:hideicon="props.hideicon"
:selectParent="props.selectParent"
>
<template v-if="$slots.title" v-slot:title="{ data }">
<slot name="title" :data="data"></slot>