test tree 不选择父选择框

This commit is contained in:
Theluyuan 2023-05-15 08:59:25 +08:00
parent 56769f4152
commit eb3f2e831c
6 changed files with 22 additions and 24 deletions

View File

@ -73,14 +73,8 @@ const _sfc_main$1 = defineComponent({
}
const isChildAllSelected = computed(() => {
function _isChildAllSelected(node) {
if (!props.showCheckbox) {
return false;
}
let childSelectNum = 0;
let res = false;
if (!props.selectParent) {
return false;
}
for (const item of node.children) {
if (item.isChecked)
childSelectNum++;
@ -239,6 +233,7 @@ class Tree {
const nodeTitle = Reflect.get(origin, title);
const nodeChildren = Reflect.get(origin, children);
const nodeDisabled = !!Reflect.get(origin, "disabled");
const selectParent = !!Reflect.get(origin, "selectParent");
const nodeIsLeaf = !!Reflect.get(origin, "spread");
const parentNode = nodeMap.get(parentKey);
const node = Object.assign({}, origin, {
@ -251,7 +246,8 @@ class Tree {
isChecked: false,
isLeaf: false,
hasNextSibling,
parentNode: parentNode || null
parentNode: parentNode || null,
selectParent
});
node.isDisabled = nodeDisabled;
node.isChecked = checkedKeys.includes(nodeKey);
@ -307,6 +303,9 @@ class Tree {
}
setCheckedKeys(checked, checkStrictly, node) {
node.isChecked = checked;
if (!node.selectParent) {
return false;
}
if (!checkStrictly) {
if (node.parentNode) {
this.setParentChecked(checked, node.parentNode);

View File

@ -17670,14 +17670,8 @@ const _sfc_main$K = defineComponent({
}
const isChildAllSelected = computed$1(() => {
function _isChildAllSelected(node) {
if (!props.showCheckbox) {
return false;
}
let childSelectNum = 0;
let res = false;
if (!props.selectParent) {
return false;
}
for (const item of node.children) {
if (item.isChecked)
childSelectNum++;
@ -17836,6 +17830,7 @@ class Tree {
const nodeTitle = Reflect.get(origin, title);
const nodeChildren = Reflect.get(origin, children);
const nodeDisabled = !!Reflect.get(origin, "disabled");
const selectParent = !!Reflect.get(origin, "selectParent");
const nodeIsLeaf = !!Reflect.get(origin, "spread");
const parentNode = nodeMap.get(parentKey);
const node = Object.assign({}, origin, {
@ -17848,7 +17843,8 @@ class Tree {
isChecked: false,
isLeaf: false,
hasNextSibling,
parentNode: parentNode || null
parentNode: parentNode || null,
selectParent
});
node.isDisabled = nodeDisabled;
node.isChecked = checkedKeys.includes(nodeKey);
@ -17904,6 +17900,9 @@ class Tree {
}
setCheckedKeys(checked, checkStrictly, node) {
node.isChecked = checked;
if (!node.selectParent) {
return false;
}
if (!checkStrictly) {
if (node.parentNode) {
this.setParentChecked(checked, node.parentNode);

View File

@ -24,6 +24,7 @@ export interface TreeData {
isLeaf: boolean;
hasNextSibling: boolean;
parentNode: Nullable<TreeData>;
selectParent:boolean;
}
export interface TreeNodeProps {
@ -107,16 +108,8 @@ 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
if(!props.selectParent){
return false
}
for (const item of node.children) {
if (item.isChecked) childSelectNum++;
}

View File

@ -17,6 +17,7 @@ export interface TreeData {
isLeaf: boolean;
hasNextSibling: boolean;
parentNode: Nullable<TreeData>;
selectParent:boolean;
}
interface ReplaceFields {
@ -99,6 +100,7 @@ class Tree {
const nodeTitle = Reflect.get(origin, title);
const nodeChildren = Reflect.get(origin, children);
const nodeDisabled = !!Reflect.get(origin, "disabled");
const selectParent = !!Reflect.get(origin, "selectParent");
const nodeIsLeaf = !!Reflect.get(origin, "spread");
const parentNode = nodeMap.get(parentKey);
@ -113,6 +115,7 @@ class Tree {
isLeaf: false,
hasNextSibling: hasNextSibling,
parentNode: parentNode || null,
selectParent: selectParent
});
node.isDisabled = nodeDisabled;
@ -183,6 +186,9 @@ class Tree {
node: TreeData
) {
node.isChecked = checked;
if (!node.selectParent) {
return false;
}
if (!checkStrictly) {
if (node.parentNode) {
this.setParentChecked(checked, node.parentNode);

View File

@ -13,6 +13,7 @@ export interface TreeData {
isLeaf: boolean;
hasNextSibling: boolean;
parentNode: Nullable<TreeData>;
selectParent: boolean;
}
interface ReplaceFields {
id: string;
@ -38,7 +39,7 @@ declare class Tree {
treeForeach(tree: any, func: Function): void;
setChildrenChecked(checked: boolean, nodes: TreeData[]): void;
setParentChecked(checked: boolean, parent: TreeData): void;
setCheckedKeys(checked: boolean, checkStrictly: boolean | string, node: TreeData): void;
setCheckedKeys(checked: boolean, checkStrictly: boolean | string, node: TreeData): false | undefined;
getData(): TreeData[];
getKeys(): {
checkedKeys: any[];

File diff suppressed because one or more lines are too long