diff --git a/package/component/src/component/table/TableRow.vue b/package/component/src/component/table/TableRow.vue index f0f01802..623fb58d 100644 --- a/package/component/src/component/table/TableRow.vue +++ b/package/component/src/component/table/TableRow.vue @@ -172,7 +172,7 @@ const renderRowClassName = (data: any, index: number) => { return props.rowClassName(data, index); }; -const childrenIndentSize = props.currentIndentSize + props.indentSize; +const childrenIndentSize = computed(() => props.currentIndentSize + props.indentSize); const renderFixedStyle = (column: any, columnIndex: number) => { if (column.fixed) { diff --git a/package/component/src/component/table/index.vue b/package/component/src/component/table/index.vue index 9a703575..6034d368 100644 --- a/package/component/src/component/table/index.vue +++ b/package/component/src/component/table/index.vue @@ -503,12 +503,12 @@ props.columns.map((value: any) => { }); const currentIndentSize = ref(0); -const childrenExpandSpace = ref(false); - -props.dataSource.map((value: any) => { - if (value[props.childrenColumnName]) { - childrenExpandSpace.value = true; - } +const childrenExpandSpace = computed(() => { + return props.dataSource.find((value: any) => { + if (value[props.childrenColumnName]) { + return true; + } + }) != undefined; }); /** diff --git a/package/component/src/component/tree/index.vue b/package/component/src/component/tree/index.vue index e172527b..30fdf945 100644 --- a/package/component/src/component/tree/index.vue +++ b/package/component/src/component/tree/index.vue @@ -24,7 +24,7 @@ export interface TreeProps { checkedKeys?: KeysType; data: OriginalTreeData; showCheckbox?: boolean; - checkStrictly: boolean; + checkStrictly?: boolean; edit?: EditType; collapseTransition?: boolean; onlyIconControl?: boolean; diff --git a/package/component/src/component/tree/tree.ts b/package/component/src/component/tree/tree.ts index a0e3d7fe..7184f951 100644 --- a/package/component/src/component/tree/tree.ts +++ b/package/component/src/component/tree/tree.ts @@ -1,6 +1,7 @@ import { OriginalTreeData, StringOrNumber } from "./tree.type"; import { Nullable } from "../../types"; import { Ref, ref } from "vue"; +import { check } from "prettier"; type CustomKey = string | number; type CustomString = (() => string) | string; @@ -134,11 +135,20 @@ class Tree { setChildrenChecked(checked: boolean, nodes: TreeData[]) { const len = nodes.length; + /** + * 判断所有子项, 如果存在选中项, 并且全选, 取消所有选中 + * + * 如果存在选中项, 未全部选着, 选中全部 + * + * 如果不存在选中项, 选中全部可选 + */ for (let i = 0; i < len; i++) { - nodes[i].isChecked = checked; + if(!nodes[i].isDisabled || (nodes[i].isDisabled && nodes[i].children.length > 0)) { + nodes[i].isChecked = checked; + } nodes[i].children && - nodes[i].children.length > 0 && - this.setChildrenChecked(checked, nodes[i].children); + nodes[i].children.length > 0 && + this.setChildrenChecked(checked, nodes[i].children); } } diff --git a/package/document-component/src/document/zh-CN/components/tree.md b/package/document-component/src/document/zh-CN/components/tree.md index 7a31b7b8..46e21b73 100644 --- a/package/document-component/src/document/zh-CN/components/tree.md +++ b/package/document-component/src/document/zh-CN/components/tree.md @@ -197,9 +197,9 @@ function handleClick(node) {