Compare commits
No commits in common. "71a3b6f1c43d380a3969ebb4389caaf058e951a2" and "a19040aa60c871d9ffbec711095bc0da10985a18" have entirely different histories.
71a3b6f1c4
...
a19040aa60
@ -24,8 +24,7 @@ const _sfc_main$1 = defineComponent({
|
||||
checkStrictly: { type: [Boolean, String] },
|
||||
collapseTransition: { type: Boolean },
|
||||
onlyIconControl: { type: Boolean },
|
||||
hideicon: { type: Boolean },
|
||||
selectParent: { type: Boolean }
|
||||
hideicon: { type: Boolean }
|
||||
},
|
||||
emits: ["node-click"],
|
||||
setup(__props, { emit }) {
|
||||
@ -53,7 +52,7 @@ const _sfc_main$1 = defineComponent({
|
||||
emit("node-click", node);
|
||||
}
|
||||
function handleChange(checked, node) {
|
||||
props.tree.setCheckedKeys(checked, props.checkStrictly || props.selectParent, node);
|
||||
props.tree.setCheckedKeys(checked, props.checkStrictly, node);
|
||||
}
|
||||
function handleIconClick(node) {
|
||||
node.isLeaf = !node.isLeaf;
|
||||
@ -73,16 +72,17 @@ const _sfc_main$1 = defineComponent({
|
||||
}
|
||||
const isChildAllSelected = computed(() => {
|
||||
function _isChildAllSelected(node) {
|
||||
if (!props.showCheckbox) {
|
||||
return false;
|
||||
}
|
||||
let childSelectNum = 0;
|
||||
let res = false;
|
||||
for (const item of node.children) {
|
||||
if (item.isChecked)
|
||||
childSelectNum++;
|
||||
}
|
||||
if (!props.selectParent) {
|
||||
if (childSelectNum > 0)
|
||||
node.isChecked = true;
|
||||
}
|
||||
if (childSelectNum == node.children.length) {
|
||||
for (const item of node.children) {
|
||||
res = _isChildAllSelected(item);
|
||||
@ -95,14 +95,11 @@ const _sfc_main$1 = defineComponent({
|
||||
return res;
|
||||
}
|
||||
return (node) => {
|
||||
console.log(props.selectParent);
|
||||
if (props.checkStrictly) {
|
||||
return false;
|
||||
} else if (props.selectParent) {
|
||||
} else {
|
||||
let res = _isChildAllSelected(node);
|
||||
return res;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
});
|
||||
@ -169,7 +166,6 @@ const _sfc_main$1 = defineComponent({
|
||||
checkStrictly: __props.checkStrictly,
|
||||
"only-icon-control": __props.onlyIconControl,
|
||||
hideicon: props.hideicon,
|
||||
"select-parent": props.selectParent,
|
||||
onNodeClick: recursiveNodeClick
|
||||
}, createSlots({ _: 2 }, [
|
||||
_ctx.$slots.title ? {
|
||||
@ -181,7 +177,7 @@ const _sfc_main$1 = defineComponent({
|
||||
]),
|
||||
key: "0"
|
||||
} : void 0
|
||||
]), 1032, ["tree", "node-list", "show-checkbox", "show-line", "selected-key", "collapse-transition", "checkStrictly", "only-icon-control", "hideicon", "select-parent"])
|
||||
]), 1032, ["tree", "node-list", "show-checkbox", "show-line", "selected-key", "collapse-transition", "checkStrictly", "only-icon-control", "hideicon"])
|
||||
])) : createCommentVNode("", true)
|
||||
]),
|
||||
_: 2
|
||||
@ -231,7 +227,6 @@ class Tree {
|
||||
checkStrictly,
|
||||
replaceFields: { children, id, title }
|
||||
} = this.config;
|
||||
console.log(origin, "origin");
|
||||
const nodeKey = Reflect.get(origin, id);
|
||||
const nodeTitle = Reflect.get(origin, title);
|
||||
const nodeChildren = Reflect.get(origin, children);
|
||||
@ -269,7 +264,6 @@ class Tree {
|
||||
});
|
||||
}
|
||||
setChildrenChecked(checked, nodes) {
|
||||
console.log("\u8D70\u8D4B\u503C\u5B50\u8282\u70B9\u4E86");
|
||||
var ableCount = 0;
|
||||
var checkCount = 0;
|
||||
const len = nodes.length;
|
||||
@ -290,7 +284,6 @@ class Tree {
|
||||
}
|
||||
}
|
||||
setParentChecked(checked, parent) {
|
||||
console.log("\u8D70\u8D4B\u503C\u7236\u8282\u70B9\u4E86");
|
||||
if (!parent) {
|
||||
return;
|
||||
}
|
||||
@ -306,7 +299,6 @@ class Tree {
|
||||
}
|
||||
setCheckedKeys(checked, checkStrictly, node) {
|
||||
node.isChecked = checked;
|
||||
console.log(node, checkStrictly, 186);
|
||||
if (!checkStrictly) {
|
||||
if (node.parentNode) {
|
||||
this.setParentChecked(checked, node.parentNode);
|
||||
@ -391,8 +383,7 @@ const _sfc_main = defineComponent({
|
||||
title: "title"
|
||||
};
|
||||
} },
|
||||
hideicon: { type: Boolean },
|
||||
selectParent: { type: Boolean, default: false }
|
||||
hideicon: { type: Boolean }
|
||||
},
|
||||
emits: ["update:checkedKeys", "update:expandKeys", "node-click"],
|
||||
setup(__props, { emit }) {
|
||||
@ -455,8 +446,7 @@ const _sfc_main = defineComponent({
|
||||
"collapse-transition": __props.collapseTransition,
|
||||
"only-icon-control": __props.onlyIconControl,
|
||||
onNodeClick: handleClick,
|
||||
hideicon: props.hideicon,
|
||||
selectParent: props.selectParent
|
||||
hideicon: props.hideicon
|
||||
}, createSlots({ _: 2 }, [
|
||||
_ctx.$slots.title ? {
|
||||
name: "title",
|
||||
@ -465,7 +455,7 @@ const _sfc_main = defineComponent({
|
||||
]),
|
||||
key: "0"
|
||||
} : void 0
|
||||
]), 1032, ["tree", "node-list", "show-checkbox", "show-line", "selectedKey", "check-strictly", "collapse-transition", "only-icon-control", "hideicon", "selectParent"])
|
||||
]), 1032, ["tree", "node-list", "show-checkbox", "show-line", "selectedKey", "check-strictly", "collapse-transition", "only-icon-control", "hideicon"])
|
||||
], 2);
|
||||
};
|
||||
}
|
||||
|
@ -17621,8 +17621,7 @@ const _sfc_main$K = defineComponent({
|
||||
checkStrictly: { type: [Boolean, String] },
|
||||
collapseTransition: { type: Boolean },
|
||||
onlyIconControl: { type: Boolean },
|
||||
hideicon: { type: Boolean },
|
||||
selectParent: { type: Boolean }
|
||||
hideicon: { type: Boolean }
|
||||
},
|
||||
emits: ["node-click"],
|
||||
setup(__props, { emit }) {
|
||||
@ -17650,7 +17649,7 @@ const _sfc_main$K = defineComponent({
|
||||
emit("node-click", node);
|
||||
}
|
||||
function handleChange(checked, node) {
|
||||
props.tree.setCheckedKeys(checked, props.checkStrictly || props.selectParent, node);
|
||||
props.tree.setCheckedKeys(checked, props.checkStrictly, node);
|
||||
}
|
||||
function handleIconClick(node) {
|
||||
node.isLeaf = !node.isLeaf;
|
||||
@ -17670,16 +17669,17 @@ const _sfc_main$K = defineComponent({
|
||||
}
|
||||
const isChildAllSelected = computed$1(() => {
|
||||
function _isChildAllSelected(node) {
|
||||
if (!props.showCheckbox) {
|
||||
return false;
|
||||
}
|
||||
let childSelectNum = 0;
|
||||
let res = false;
|
||||
for (const item of node.children) {
|
||||
if (item.isChecked)
|
||||
childSelectNum++;
|
||||
}
|
||||
if (!props.selectParent) {
|
||||
if (childSelectNum > 0)
|
||||
node.isChecked = true;
|
||||
}
|
||||
if (childSelectNum == node.children.length) {
|
||||
for (const item of node.children) {
|
||||
res = _isChildAllSelected(item);
|
||||
@ -17692,14 +17692,11 @@ const _sfc_main$K = defineComponent({
|
||||
return res;
|
||||
}
|
||||
return (node) => {
|
||||
console.log(props.selectParent);
|
||||
if (props.checkStrictly) {
|
||||
return false;
|
||||
} else if (props.selectParent) {
|
||||
} else {
|
||||
let res = _isChildAllSelected(node);
|
||||
return res;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
});
|
||||
@ -17766,7 +17763,6 @@ const _sfc_main$K = defineComponent({
|
||||
checkStrictly: __props.checkStrictly,
|
||||
"only-icon-control": __props.onlyIconControl,
|
||||
hideicon: props.hideicon,
|
||||
"select-parent": props.selectParent,
|
||||
onNodeClick: recursiveNodeClick
|
||||
}, createSlots({ _: 2 }, [
|
||||
_ctx.$slots.title ? {
|
||||
@ -17778,7 +17774,7 @@ const _sfc_main$K = defineComponent({
|
||||
]),
|
||||
key: "0"
|
||||
} : void 0
|
||||
]), 1032, ["tree", "node-list", "show-checkbox", "show-line", "selected-key", "collapse-transition", "checkStrictly", "only-icon-control", "hideicon", "select-parent"])
|
||||
]), 1032, ["tree", "node-list", "show-checkbox", "show-line", "selected-key", "collapse-transition", "checkStrictly", "only-icon-control", "hideicon"])
|
||||
])) : createCommentVNode("", true)
|
||||
]),
|
||||
_: 2
|
||||
@ -17828,7 +17824,6 @@ class Tree {
|
||||
checkStrictly,
|
||||
replaceFields: { children, id, title }
|
||||
} = this.config;
|
||||
console.log(origin, "origin");
|
||||
const nodeKey = Reflect.get(origin, id);
|
||||
const nodeTitle = Reflect.get(origin, title);
|
||||
const nodeChildren = Reflect.get(origin, children);
|
||||
@ -17866,7 +17861,6 @@ class Tree {
|
||||
});
|
||||
}
|
||||
setChildrenChecked(checked, nodes) {
|
||||
console.log("\u8D70\u8D4B\u503C\u5B50\u8282\u70B9\u4E86");
|
||||
var ableCount = 0;
|
||||
var checkCount = 0;
|
||||
const len = nodes.length;
|
||||
@ -17887,7 +17881,6 @@ class Tree {
|
||||
}
|
||||
}
|
||||
setParentChecked(checked, parent) {
|
||||
console.log("\u8D70\u8D4B\u503C\u7236\u8282\u70B9\u4E86");
|
||||
if (!parent) {
|
||||
return;
|
||||
}
|
||||
@ -17903,7 +17896,6 @@ class Tree {
|
||||
}
|
||||
setCheckedKeys(checked, checkStrictly, node) {
|
||||
node.isChecked = checked;
|
||||
console.log(node, checkStrictly, 186);
|
||||
if (!checkStrictly) {
|
||||
if (node.parentNode) {
|
||||
this.setParentChecked(checked, node.parentNode);
|
||||
@ -17988,8 +17980,7 @@ const _sfc_main$J = defineComponent({
|
||||
title: "title"
|
||||
};
|
||||
} },
|
||||
hideicon: { type: Boolean },
|
||||
selectParent: { type: Boolean, default: false }
|
||||
hideicon: { type: Boolean }
|
||||
},
|
||||
emits: ["update:checkedKeys", "update:expandKeys", "node-click"],
|
||||
setup(__props, { emit }) {
|
||||
@ -18052,8 +18043,7 @@ const _sfc_main$J = defineComponent({
|
||||
"collapse-transition": __props.collapseTransition,
|
||||
"only-icon-control": __props.onlyIconControl,
|
||||
onNodeClick: handleClick,
|
||||
hideicon: props.hideicon,
|
||||
selectParent: props.selectParent
|
||||
hideicon: props.hideicon
|
||||
}, createSlots({ _: 2 }, [
|
||||
_ctx.$slots.title ? {
|
||||
name: "title",
|
||||
@ -18062,7 +18052,7 @@ const _sfc_main$J = defineComponent({
|
||||
]),
|
||||
key: "0"
|
||||
} : void 0
|
||||
]), 1032, ["tree", "node-list", "show-checkbox", "show-line", "selectedKey", "check-strictly", "collapse-transition", "only-icon-control", "hideicon", "selectParent"])
|
||||
]), 1032, ["tree", "node-list", "show-checkbox", "show-line", "selectedKey", "check-strictly", "collapse-transition", "only-icon-control", "hideicon"])
|
||||
], 2);
|
||||
};
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ export interface TreeData {
|
||||
isLeaf: boolean;
|
||||
hasNextSibling: boolean;
|
||||
parentNode: Nullable<TreeData>;
|
||||
selectParent: boolean;
|
||||
}
|
||||
|
||||
export interface TreeNodeProps {
|
||||
@ -37,7 +36,6 @@ export interface TreeNodeProps {
|
||||
collapseTransition: boolean;
|
||||
onlyIconControl: boolean;
|
||||
hideicon?: boolean;
|
||||
selectParent: boolean;
|
||||
}
|
||||
|
||||
interface TreeNodeEmits {
|
||||
@ -83,11 +81,7 @@ function recursiveNodeClick(node: TreeData) {
|
||||
}
|
||||
|
||||
function handleChange(checked: boolean, node: TreeData) {
|
||||
props.tree.setCheckedKeys(
|
||||
checked,
|
||||
props.checkStrictly || props.selectParent,
|
||||
node
|
||||
);
|
||||
props.tree.setCheckedKeys(checked, props.checkStrictly, node);
|
||||
}
|
||||
|
||||
function handleIconClick(node: TreeData) {
|
||||
@ -112,14 +106,15 @@ function handleRowClick(node: TreeData) {
|
||||
//判断是否半选
|
||||
const isChildAllSelected = computed(() => {
|
||||
function _isChildAllSelected(node: TreeData): boolean {
|
||||
if (!props.showCheckbox) {
|
||||
return false;
|
||||
}
|
||||
let childSelectNum = 0;
|
||||
let res = false; // true为半选 false为全选
|
||||
for (const item of node.children) {
|
||||
if (item.isChecked) childSelectNum++;
|
||||
}
|
||||
if (!props.selectParent) {
|
||||
if (childSelectNum > 0) node.isChecked = true; //此处的处理与 checkedKeys 有关联
|
||||
}
|
||||
if (childSelectNum == node.children.length) {
|
||||
//继续递归向下判断
|
||||
for (const item of node.children) {
|
||||
@ -133,14 +128,11 @@ const isChildAllSelected = computed(() => {
|
||||
}
|
||||
|
||||
return (node: TreeData): boolean => {
|
||||
console.log(props.selectParent);
|
||||
if (props.checkStrictly) {
|
||||
return false;
|
||||
} else if (props.selectParent) {
|
||||
} else {
|
||||
let res = _isChildAllSelected(node);
|
||||
return res;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
});
|
||||
@ -206,7 +198,6 @@ 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 }">
|
||||
|
@ -39,7 +39,6 @@ export interface TreeProps {
|
||||
showCheckbox?: boolean;
|
||||
replaceFields?: ReplaceFieldsOptions;
|
||||
hideicon?: boolean;
|
||||
selectParent?: boolean;
|
||||
}
|
||||
|
||||
interface TreeEmits {
|
||||
@ -66,7 +65,6 @@ const props = withDefaults(defineProps<TreeProps>(), {
|
||||
title: "title",
|
||||
};
|
||||
},
|
||||
selectParent: false,
|
||||
});
|
||||
|
||||
const slots = useSlots();
|
||||
@ -148,7 +146,6 @@ 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>
|
||||
|
@ -94,7 +94,7 @@ class Tree {
|
||||
checkStrictly,
|
||||
replaceFields: { children, id, title },
|
||||
} = this.config;
|
||||
console.log(origin, "origin");
|
||||
|
||||
const nodeKey = Reflect.get(origin, id);
|
||||
const nodeTitle = Reflect.get(origin, title);
|
||||
const nodeChildren = Reflect.get(origin, children);
|
||||
@ -137,7 +137,6 @@ class Tree {
|
||||
}
|
||||
|
||||
setChildrenChecked(checked: boolean, nodes: TreeData[]) {
|
||||
console.log("走赋值子节点了");
|
||||
var ableCount = 0;
|
||||
var checkCount = 0;
|
||||
const len = nodes.length;
|
||||
@ -164,7 +163,6 @@ class Tree {
|
||||
}
|
||||
|
||||
setParentChecked(checked: boolean, parent: TreeData) {
|
||||
console.log("走赋值父节点了");
|
||||
if (!parent) {
|
||||
return;
|
||||
}
|
||||
@ -185,7 +183,6 @@ class Tree {
|
||||
node: TreeData
|
||||
) {
|
||||
node.isChecked = checked;
|
||||
console.log(node, checkStrictly, 186);
|
||||
if (!checkStrictly) {
|
||||
if (node.parentNode) {
|
||||
this.setParentChecked(checked, node.parentNode);
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user