From 85b14ba7e45f3ac1b5c3de7a42d9e31638f6b23d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=B1=E7=9C=A0=E5=84=80=E5=BC=8F?= <854085467@qq.com> Date: Mon, 3 Oct 2022 01:34:30 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B(component):=20table=20=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=20indentSize=20=E5=B1=9E=E6=80=A7,=20=E5=9C=A8?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E8=BF=9C=E7=A8=8B=E6=95=B0=E6=8D=AE=E6=97=B6?= =?UTF-8?q?=E4=B8=8D=E7=94=9F=E6=95=88=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/src/component/table/TableRow.vue | 2 +- package/component/src/component/table/index.vue | 12 ++++++------ package/component/src/component/tree/index.vue | 2 +- package/component/src/component/tree/tree.ts | 16 +++++++++++++--- .../src/document/zh-CN/components/tree.md | 13 +++++++------ .../src/document/zh-CN/guide/changelog.md | 1 + 6 files changed, 29 insertions(+), 17 deletions(-) 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) {