add 树型框可以不半选父级
This commit is contained in:
parent
f87a5bb70a
commit
72e79b3361
@ -24,7 +24,8 @@ const _sfc_main$1 = defineComponent({
|
|||||||
checkStrictly: { type: [Boolean, String] },
|
checkStrictly: { type: [Boolean, String] },
|
||||||
collapseTransition: { type: Boolean },
|
collapseTransition: { type: Boolean },
|
||||||
onlyIconControl: { type: Boolean },
|
onlyIconControl: { type: Boolean },
|
||||||
hideicon: { type: Boolean }
|
hideicon: { type: Boolean },
|
||||||
|
selectParent: { type: Boolean }
|
||||||
},
|
},
|
||||||
emits: ["node-click"],
|
emits: ["node-click"],
|
||||||
setup(__props, { emit }) {
|
setup(__props, { emit }) {
|
||||||
@ -97,9 +98,11 @@ const _sfc_main$1 = defineComponent({
|
|||||||
return (node) => {
|
return (node) => {
|
||||||
if (props.checkStrictly) {
|
if (props.checkStrictly) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else if (props.selectParent) {
|
||||||
let res = _isChildAllSelected(node);
|
let res = _isChildAllSelected(node);
|
||||||
return res;
|
return res;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@ -166,6 +169,7 @@ const _sfc_main$1 = defineComponent({
|
|||||||
checkStrictly: __props.checkStrictly,
|
checkStrictly: __props.checkStrictly,
|
||||||
"only-icon-control": __props.onlyIconControl,
|
"only-icon-control": __props.onlyIconControl,
|
||||||
hideicon: props.hideicon,
|
hideicon: props.hideicon,
|
||||||
|
"select-parent": props.selectParent,
|
||||||
onNodeClick: recursiveNodeClick
|
onNodeClick: recursiveNodeClick
|
||||||
}, createSlots({ _: 2 }, [
|
}, createSlots({ _: 2 }, [
|
||||||
_ctx.$slots.title ? {
|
_ctx.$slots.title ? {
|
||||||
@ -177,7 +181,7 @@ const _sfc_main$1 = defineComponent({
|
|||||||
]),
|
]),
|
||||||
key: "0"
|
key: "0"
|
||||||
} : void 0
|
} : void 0
|
||||||
]), 1032, ["tree", "node-list", "show-checkbox", "show-line", "selected-key", "collapse-transition", "checkStrictly", "only-icon-control", "hideicon"])
|
]), 1032, ["tree", "node-list", "show-checkbox", "show-line", "selected-key", "collapse-transition", "checkStrictly", "only-icon-control", "hideicon", "select-parent"])
|
||||||
])) : createCommentVNode("", true)
|
])) : createCommentVNode("", true)
|
||||||
]),
|
]),
|
||||||
_: 2
|
_: 2
|
||||||
@ -383,7 +387,8 @@ const _sfc_main = defineComponent({
|
|||||||
title: "title"
|
title: "title"
|
||||||
};
|
};
|
||||||
} },
|
} },
|
||||||
hideicon: { type: Boolean }
|
hideicon: { type: Boolean },
|
||||||
|
selectParent: { type: Boolean, default: true }
|
||||||
},
|
},
|
||||||
emits: ["update:checkedKeys", "update:expandKeys", "node-click"],
|
emits: ["update:checkedKeys", "update:expandKeys", "node-click"],
|
||||||
setup(__props, { emit }) {
|
setup(__props, { emit }) {
|
||||||
@ -446,7 +451,8 @@ const _sfc_main = defineComponent({
|
|||||||
"collapse-transition": __props.collapseTransition,
|
"collapse-transition": __props.collapseTransition,
|
||||||
"only-icon-control": __props.onlyIconControl,
|
"only-icon-control": __props.onlyIconControl,
|
||||||
onNodeClick: handleClick,
|
onNodeClick: handleClick,
|
||||||
hideicon: props.hideicon
|
hideicon: props.hideicon,
|
||||||
|
selectParent: props.selectParent
|
||||||
}, createSlots({ _: 2 }, [
|
}, createSlots({ _: 2 }, [
|
||||||
_ctx.$slots.title ? {
|
_ctx.$slots.title ? {
|
||||||
name: "title",
|
name: "title",
|
||||||
@ -455,7 +461,7 @@ const _sfc_main = defineComponent({
|
|||||||
]),
|
]),
|
||||||
key: "0"
|
key: "0"
|
||||||
} : void 0
|
} : void 0
|
||||||
]), 1032, ["tree", "node-list", "show-checkbox", "show-line", "selectedKey", "check-strictly", "collapse-transition", "only-icon-control", "hideicon"])
|
]), 1032, ["tree", "node-list", "show-checkbox", "show-line", "selectedKey", "check-strictly", "collapse-transition", "only-icon-control", "hideicon", "selectParent"])
|
||||||
], 2);
|
], 2);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
18
lib/index.js
18
lib/index.js
@ -17621,7 +17621,8 @@ const _sfc_main$K = defineComponent({
|
|||||||
checkStrictly: { type: [Boolean, String] },
|
checkStrictly: { type: [Boolean, String] },
|
||||||
collapseTransition: { type: Boolean },
|
collapseTransition: { type: Boolean },
|
||||||
onlyIconControl: { type: Boolean },
|
onlyIconControl: { type: Boolean },
|
||||||
hideicon: { type: Boolean }
|
hideicon: { type: Boolean },
|
||||||
|
selectParent: { type: Boolean }
|
||||||
},
|
},
|
||||||
emits: ["node-click"],
|
emits: ["node-click"],
|
||||||
setup(__props, { emit }) {
|
setup(__props, { emit }) {
|
||||||
@ -17694,9 +17695,11 @@ const _sfc_main$K = defineComponent({
|
|||||||
return (node) => {
|
return (node) => {
|
||||||
if (props.checkStrictly) {
|
if (props.checkStrictly) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else if (props.selectParent) {
|
||||||
let res = _isChildAllSelected(node);
|
let res = _isChildAllSelected(node);
|
||||||
return res;
|
return res;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@ -17763,6 +17766,7 @@ const _sfc_main$K = defineComponent({
|
|||||||
checkStrictly: __props.checkStrictly,
|
checkStrictly: __props.checkStrictly,
|
||||||
"only-icon-control": __props.onlyIconControl,
|
"only-icon-control": __props.onlyIconControl,
|
||||||
hideicon: props.hideicon,
|
hideicon: props.hideicon,
|
||||||
|
"select-parent": props.selectParent,
|
||||||
onNodeClick: recursiveNodeClick
|
onNodeClick: recursiveNodeClick
|
||||||
}, createSlots({ _: 2 }, [
|
}, createSlots({ _: 2 }, [
|
||||||
_ctx.$slots.title ? {
|
_ctx.$slots.title ? {
|
||||||
@ -17774,7 +17778,7 @@ const _sfc_main$K = defineComponent({
|
|||||||
]),
|
]),
|
||||||
key: "0"
|
key: "0"
|
||||||
} : void 0
|
} : void 0
|
||||||
]), 1032, ["tree", "node-list", "show-checkbox", "show-line", "selected-key", "collapse-transition", "checkStrictly", "only-icon-control", "hideicon"])
|
]), 1032, ["tree", "node-list", "show-checkbox", "show-line", "selected-key", "collapse-transition", "checkStrictly", "only-icon-control", "hideicon", "select-parent"])
|
||||||
])) : createCommentVNode("", true)
|
])) : createCommentVNode("", true)
|
||||||
]),
|
]),
|
||||||
_: 2
|
_: 2
|
||||||
@ -17980,7 +17984,8 @@ const _sfc_main$J = defineComponent({
|
|||||||
title: "title"
|
title: "title"
|
||||||
};
|
};
|
||||||
} },
|
} },
|
||||||
hideicon: { type: Boolean }
|
hideicon: { type: Boolean },
|
||||||
|
selectParent: { type: Boolean, default: true }
|
||||||
},
|
},
|
||||||
emits: ["update:checkedKeys", "update:expandKeys", "node-click"],
|
emits: ["update:checkedKeys", "update:expandKeys", "node-click"],
|
||||||
setup(__props, { emit }) {
|
setup(__props, { emit }) {
|
||||||
@ -18043,7 +18048,8 @@ const _sfc_main$J = defineComponent({
|
|||||||
"collapse-transition": __props.collapseTransition,
|
"collapse-transition": __props.collapseTransition,
|
||||||
"only-icon-control": __props.onlyIconControl,
|
"only-icon-control": __props.onlyIconControl,
|
||||||
onNodeClick: handleClick,
|
onNodeClick: handleClick,
|
||||||
hideicon: props.hideicon
|
hideicon: props.hideicon,
|
||||||
|
selectParent: props.selectParent
|
||||||
}, createSlots({ _: 2 }, [
|
}, createSlots({ _: 2 }, [
|
||||||
_ctx.$slots.title ? {
|
_ctx.$slots.title ? {
|
||||||
name: "title",
|
name: "title",
|
||||||
@ -18052,7 +18058,7 @@ const _sfc_main$J = defineComponent({
|
|||||||
]),
|
]),
|
||||||
key: "0"
|
key: "0"
|
||||||
} : void 0
|
} : void 0
|
||||||
]), 1032, ["tree", "node-list", "show-checkbox", "show-line", "selectedKey", "check-strictly", "collapse-transition", "only-icon-control", "hideicon"])
|
]), 1032, ["tree", "node-list", "show-checkbox", "show-line", "selectedKey", "check-strictly", "collapse-transition", "only-icon-control", "hideicon", "selectParent"])
|
||||||
], 2);
|
], 2);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,7 @@ export interface TreeNodeProps {
|
|||||||
collapseTransition: boolean;
|
collapseTransition: boolean;
|
||||||
onlyIconControl: boolean;
|
onlyIconControl: boolean;
|
||||||
hideicon?: boolean;
|
hideicon?: boolean;
|
||||||
|
selectParent:boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface TreeNodeEmits {
|
interface TreeNodeEmits {
|
||||||
@ -130,9 +131,11 @@ const isChildAllSelected = computed(() => {
|
|||||||
return (node: TreeData): boolean => {
|
return (node: TreeData): boolean => {
|
||||||
if (props.checkStrictly) {
|
if (props.checkStrictly) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else if(props.selectParent) {
|
||||||
let res = _isChildAllSelected(node);
|
let res = _isChildAllSelected(node);
|
||||||
return res;
|
return res;
|
||||||
|
}else{
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@ -198,6 +201,7 @@ const isChildAllSelected = computed(() => {
|
|||||||
:checkStrictly="checkStrictly"
|
:checkStrictly="checkStrictly"
|
||||||
:only-icon-control="onlyIconControl"
|
:only-icon-control="onlyIconControl"
|
||||||
:hideicon="props.hideicon"
|
:hideicon="props.hideicon"
|
||||||
|
:select-parent="props.selectParent"
|
||||||
@node-click="recursiveNodeClick"
|
@node-click="recursiveNodeClick"
|
||||||
>
|
>
|
||||||
<template v-if="$slots.title" v-slot:title="slotProp: { data: any }">
|
<template v-if="$slots.title" v-slot:title="slotProp: { data: any }">
|
||||||
|
@ -39,6 +39,7 @@ export interface TreeProps {
|
|||||||
showCheckbox?: boolean;
|
showCheckbox?: boolean;
|
||||||
replaceFields?: ReplaceFieldsOptions;
|
replaceFields?: ReplaceFieldsOptions;
|
||||||
hideicon?: boolean;
|
hideicon?: boolean;
|
||||||
|
selectParent?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface TreeEmits {
|
interface TreeEmits {
|
||||||
@ -65,6 +66,7 @@ const props = withDefaults(defineProps<TreeProps>(), {
|
|||||||
title: "title",
|
title: "title",
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
selectParent:true
|
||||||
});
|
});
|
||||||
|
|
||||||
const slots = useSlots();
|
const slots = useSlots();
|
||||||
@ -146,6 +148,7 @@ function handleClick(node: TreeData) {
|
|||||||
:only-icon-control="onlyIconControl"
|
:only-icon-control="onlyIconControl"
|
||||||
@node-click="handleClick"
|
@node-click="handleClick"
|
||||||
:hideicon="props.hideicon"
|
:hideicon="props.hideicon"
|
||||||
|
:selectParent="props.selectParent"
|
||||||
>
|
>
|
||||||
<template v-if="$slots.title" v-slot:title="{ data }">
|
<template v-if="$slots.title" v-slot:title="{ data }">
|
||||||
<slot name="title" :data="data"></slot>
|
<slot name="title" :data="data"></slot>
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user