From 70a669a86d15cc72895c5883bb5bbaccfc8fbc61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E9=AD=94=E7=8E=8B?= <40223749+LYErin@users.noreply.github.com> Date: Wed, 8 Sep 2021 23:37:21 +0800 Subject: [PATCH] feat(tree): add check-strategy prop (#1122) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * docs(tree): add checkStrategy prop * docs(tree): add log * feat(n-tree): 属性更新 * feat(n-tree): update the description of docs Co-authored-by: unknown --- CHANGELOG.en-US.md | 4 ++++ CHANGELOG.zh-CN.md | 4 ++++ src/tree-select/src/TreeSelect.tsx | 2 +- src/tree/demos/enUS/index.demo-entry.md | 1 + src/tree/demos/zhCN/index.demo-entry.md | 1 + src/tree/src/Tree.tsx | 4 ++-- 6 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.en-US.md b/CHANGELOG.en-US.md index e20408462..61792303d 100644 --- a/CHANGELOG.en-US.md +++ b/CHANGELOG.en-US.md @@ -1,5 +1,9 @@ # CHANGELOG +### Feats + +- `n-tree` add `check-strategy` document prop. + ## 2.18.1 (2021-09-08) ### Feats diff --git a/CHANGELOG.zh-CN.md b/CHANGELOG.zh-CN.md index f39d8c5cf..69e7c5eee 100644 --- a/CHANGELOG.zh-CN.md +++ b/CHANGELOG.zh-CN.md @@ -1,5 +1,9 @@ # CHANGELOG +### Feats + +- `n-tree` 增加 `check-strategy` 文档属性 + ## 2.18.1 (2021-09-08) ### Feats diff --git a/src/tree-select/src/TreeSelect.tsx b/src/tree-select/src/TreeSelect.tsx index 47e0e810c..3e35c902c 100644 --- a/src/tree-select/src/TreeSelect.tsx +++ b/src/tree-select/src/TreeSelect.tsx @@ -749,7 +749,7 @@ export default defineComponent({ checkedKeys={this.treeCheckedKeys} selectedKeys={this.treeSelectedKeys} checkable={checkable} - internalCheckStrategy={this.checkStrategy} + checkStrategy={this.checkStrategy} cascade={this.mergedCascade} leafOnly={this.leafOnly} multiple={this.multiple} diff --git a/src/tree/demos/enUS/index.demo-entry.md b/src/tree/demos/enUS/index.demo-entry.md index 966c3475f..fcd088004 100644 --- a/src/tree/demos/enUS/index.demo-entry.md +++ b/src/tree/demos/enUS/index.demo-entry.md @@ -31,6 +31,7 @@ batch-render | block-node | `boolean` | `false` | The node name is spread out in the whole row. | | cancelable | `boolean` | `true` | Whether node's select status can be cancelled. | | cascade | `boolean` | `false` | Whether to cascade checkboxes. | +| check-strategy | `string` | `'all'` | The way to set the value of callback function. `all` means setting all checked node. `parent` means setting all checked parent node when all child node are checked. `child` means setting all child node. | | checkable | `boolean` | `false` | Whether to display the selection box, you need to set `cascade` to `true`. | | children-field | `string` | `'children'` | The children field in `TreeOption`. | | checked-keys | `Array` | `undefined` | If set, checked status will work in controlled manner. | diff --git a/src/tree/demos/zhCN/index.demo-entry.md b/src/tree/demos/zhCN/index.demo-entry.md index 5731c4cf8..3bfd74632 100644 --- a/src/tree/demos/zhCN/index.demo-entry.md +++ b/src/tree/demos/zhCN/index.demo-entry.md @@ -31,6 +31,7 @@ batch-render | block-node | `boolean` | `false` | 节点名称整行撑开 | | cancelable | `boolean` | `true` | 选中之后是否允许取消 | | cascade | `boolean` | `false` | 是否关联选项 | +| check-strategy | `string` | `'all'` | 设置勾选策略来指定回调参数的值,`all` 表示回调函数值为全部选中节点;`parent` 表示回调函数值为父节点(当父节点下所有子节点都选中时);`child` 表示回调函数值为子节点 | | checkable | `boolean` | `false` | 是否显示选择框,需要将 `cascade` 设置为 `true` | | children-field | `string` | `'children'` | 替代 `TreeOption` 中的 children 字段名 | | checked-keys | `Array` | `undefined` | 如果设定则 `checked` 状态受控 | diff --git a/src/tree/src/Tree.tsx b/src/tree/src/Tree.tsx index 01d29bc84..225bc3511 100644 --- a/src/tree/src/Tree.tsx +++ b/src/tree/src/Tree.tsx @@ -213,7 +213,7 @@ const treeProps = { type: Boolean, default: true }, - internalCheckStrategy: { + checkStrategy: { type: String as PropType, default: 'all' } @@ -269,7 +269,7 @@ export default defineComponent({ }) }) const mergedCheckStrategyRef = computed(() => - props.leafOnly ? 'child' : props.internalCheckStrategy + props.leafOnly ? 'child' : props.checkStrategy ) const displayedCheckedKeysRef = computed(() => { return checkedStatusRef.value.checkedKeys