格式化

This commit is contained in:
Theluyuan 2023-05-17 08:57:33 +08:00
parent 9ce9d66cbe
commit 70b082a208
3 changed files with 18 additions and 14 deletions

View File

@ -24,7 +24,7 @@ export interface TreeData {
isLeaf: boolean; isLeaf: boolean;
hasNextSibling: boolean; hasNextSibling: boolean;
parentNode: Nullable<TreeData>; parentNode: Nullable<TreeData>;
selectParent:boolean; selectParent: boolean;
} }
export interface TreeNodeProps { export interface TreeNodeProps {
@ -37,7 +37,7 @@ export interface TreeNodeProps {
collapseTransition: boolean; collapseTransition: boolean;
onlyIconControl: boolean; onlyIconControl: boolean;
hideicon?: boolean; hideicon?: boolean;
selectParent:boolean; selectParent: boolean;
} }
interface TreeNodeEmits { interface TreeNodeEmits {
@ -83,7 +83,11 @@ function recursiveNodeClick(node: TreeData) {
} }
function handleChange(checked: boolean, node: TreeData) { function handleChange(checked: boolean, node: TreeData) {
props.tree.setCheckedKeys(checked, props.checkStrictly || props.selectParent, node); props.tree.setCheckedKeys(
checked,
props.checkStrictly || props.selectParent,
node
);
} }
function handleIconClick(node: TreeData) { function handleIconClick(node: TreeData) {
@ -113,7 +117,7 @@ const isChildAllSelected = computed(() => {
for (const item of node.children) { for (const item of node.children) {
if (item.isChecked) childSelectNum++; if (item.isChecked) childSelectNum++;
} }
if(!props.selectParent){ if (!props.selectParent) {
if (childSelectNum > 0) node.isChecked = true; // checkedKeys if (childSelectNum > 0) node.isChecked = true; // checkedKeys
} }
if (childSelectNum == node.children.length) { if (childSelectNum == node.children.length) {
@ -129,14 +133,14 @@ const isChildAllSelected = computed(() => {
} }
return (node: TreeData): boolean => { return (node: TreeData): boolean => {
console.log(props.selectParent) console.log(props.selectParent);
if (props.checkStrictly) { if (props.checkStrictly) {
return false; return false;
} else if(props.selectParent) { } else if (props.selectParent) {
let res = _isChildAllSelected(node); let res = _isChildAllSelected(node);
return res; return res;
}else{ } else {
return false return false;
} }
}; };
}); });

View File

@ -66,7 +66,7 @@ const props = withDefaults(defineProps<TreeProps>(), {
title: "title", title: "title",
}; };
}, },
selectParent:false selectParent: false,
}); });
const slots = useSlots(); const slots = useSlots();

View File

@ -94,7 +94,7 @@ class Tree {
checkStrictly, checkStrictly,
replaceFields: { children, id, title }, replaceFields: { children, id, title },
} = this.config; } = this.config;
console.log(origin,"origin") console.log(origin, "origin");
const nodeKey = Reflect.get(origin, id); const nodeKey = Reflect.get(origin, id);
const nodeTitle = Reflect.get(origin, title); const nodeTitle = Reflect.get(origin, title);
const nodeChildren = Reflect.get(origin, children); const nodeChildren = Reflect.get(origin, children);
@ -112,7 +112,7 @@ class Tree {
isChecked: false, isChecked: false,
isLeaf: false, isLeaf: false,
hasNextSibling: hasNextSibling, hasNextSibling: hasNextSibling,
parentNode: parentNode || null parentNode: parentNode || null,
}); });
node.isDisabled = nodeDisabled; node.isDisabled = nodeDisabled;
@ -137,7 +137,7 @@ class Tree {
} }
setChildrenChecked(checked: boolean, nodes: TreeData[]) { setChildrenChecked(checked: boolean, nodes: TreeData[]) {
console.log("走赋值子节点了") console.log("走赋值子节点了");
var ableCount = 0; var ableCount = 0;
var checkCount = 0; var checkCount = 0;
const len = nodes.length; const len = nodes.length;
@ -164,7 +164,7 @@ class Tree {
} }
setParentChecked(checked: boolean, parent: TreeData) { setParentChecked(checked: boolean, parent: TreeData) {
console.log("走赋值父节点了") console.log("走赋值父节点了");
if (!parent) { if (!parent) {
return; return;
} }
@ -185,7 +185,7 @@ class Tree {
node: TreeData node: TreeData
) { ) {
node.isChecked = checked; node.isChecked = checked;
console.log(node,checkStrictly,186) console.log(node, checkStrictly, 186);
if (!checkStrictly) { if (!checkStrictly) {
if (node.parentNode) { if (node.parentNode) {
this.setParentChecked(checked, node.parentNode); this.setParentChecked(checked, node.parentNode);