From dab6b9dae0495c31a9f7ec626b183276a52d957d Mon Sep 17 00:00:00 2001 From: wisen Date: Wed, 24 Nov 2021 14:46:37 +0800 Subject: [PATCH] Tree: add filter-check-strictly property --- examples/docs/en-US/tree.md | 2 +- examples/docs/es/tree.md | 2 +- examples/docs/fr-FR/tree.md | 2 +- examples/docs/zh-CN/tree.md | 2 +- packages/tree/src/model/node.js | 3 +++ packages/tree/src/tree.vue | 8 +++++++- 6 files changed, 14 insertions(+), 5 deletions(-) diff --git a/examples/docs/en-US/tree.md b/examples/docs/en-US/tree.md index 7192c1453..3c162045b 100644 --- a/examples/docs/en-US/tree.md +++ b/examples/docs/en-US/tree.md @@ -811,7 +811,7 @@ You can drag and drop Tree nodes by adding a `draggable` attribute. | draggable | whether enable tree nodes drag and drop | boolean | — | false | | allow-drag | this function will be executed before dragging a node. If `false` is returned, the node can not be dragged | Function(node) | — | — | | allow-drop | this function will be executed before the dragging node is dropped. If `false` is returned, the dragging node can not be dropped at the target node. `type` has three possible values: 'prev' (inserting the dragging node before the target node), 'inner' (inserting the dragging node to the target node) and 'next' (inserting the dragging node after the target node) | Function(draggingNode, dropNode, type) | — | — | - +| filter-check-strictly | Whether to check the parent time only check the filtered child when `show-checkbox` is `true` | boolean | — | false | ### props | Attribute | Description | Type | Accepted Values | Default | | --------- | ---------------------------------------- | ------ | --------------- | ------- | diff --git a/examples/docs/es/tree.md b/examples/docs/es/tree.md index c66065aa1..947203030 100644 --- a/examples/docs/es/tree.md +++ b/examples/docs/es/tree.md @@ -811,7 +811,7 @@ Puede arrastrar y soltar nodos de Tree añadiendo un atributo `draggable` . | draggable | si se habilita la función de drag & drop en los nodos | boolean | — | false | | allow-drag | esta función se ejecutará antes de arrastrar un nodo. si devuelve `false`, el nodo no puede ser arrastrado. | Function(nodo) | — | — | | allow-drop | esta función se ejecutará al arrastrar y soltar un nodo. si devuelve false, el nodo arrastrando no se puede soltar en el nodo destino. `type` tiene tres valores posibles: 'prev' (insertar el nodo de arrastre antes del nodo de destino), 'inner' (insertar el nodo de arrastre en el nodo de destino) y 'next' (insertar el nodo de arrastre después del nodo de destino) | Function(Nodoquesearrastra, Nododestino, type) | — | — | - +| filter-check-strictly | Whether to check the parent time only check the filtered child when `show-checkbox` is `true` | boolean | — | false | ### props | Atributo | Descripción | Tipo | Valores aceptados | Por defecto | | -------- | ---------------------------------------- | ----------------------------- | ----------------- | ----------- | diff --git a/examples/docs/fr-FR/tree.md b/examples/docs/fr-FR/tree.md index fa6055b26..7f48de3d0 100644 --- a/examples/docs/fr-FR/tree.md +++ b/examples/docs/fr-FR/tree.md @@ -815,7 +815,7 @@ Vous pouvez déplacer les noeuds par drag'n drop en ajoutant l'attribut `draggab | draggable | Si les noeuds sont déplaçables par drag'n drop. | boolean | — | false | | allow-drag | Fonction exécutée avant le déplacement d'un noeud. Si `false` est retourné, le noeud ne sera pas déplaçable. | Function(node) | — | — | | allow-drop | Fonction exécutée avant le placement d'un noeud. Si `false` est retourné, le noeud ne pourra être placé sur la zone en question. `type` a trois valeurs possibles: 'prev' (insertion avant le noeud cible), 'inner' (insertion dans le noeud cible) and 'next' (insertion après le noeud cible). | Function(draggingNode, dropNode, type) | — | — | - +| filter-check-strictly | Whether to check the parent time only check the filtered child when `show-checkbox` is `true` | boolean | — | false | ### props | Attribut | Description | Type | Valeurs acceptées | Défaut | diff --git a/examples/docs/zh-CN/tree.md b/examples/docs/zh-CN/tree.md index cb2b6a9f4..a933d0163 100644 --- a/examples/docs/zh-CN/tree.md +++ b/examples/docs/zh-CN/tree.md @@ -820,7 +820,7 @@ | draggable | 是否开启拖拽节点功能 | boolean | — | false | | allow-drag | 判断节点能否被拖拽 | Function(node) | — | — | | allow-drop | 拖拽时判定目标节点能否被放置。`type` 参数有三种情况:'prev'、'inner' 和 'next',分别表示放置在目标节点前、插入至目标节点和放置在目标节点后 | Function(draggingNode, dropNode, type) | — | — | - +| filter-check-strictly | 在显示复选框且处于筛选状态下,选择父级是否只勾选筛选结果的子级 | boolean | — | false | ### props | 参数 | 说明 | 类型 | 可选值 | 默认值 | | -------- | ----------------- | ------ | ---- | ---- | diff --git a/packages/tree/src/model/node.js b/packages/tree/src/model/node.js index c72299582..7ba26406c 100644 --- a/packages/tree/src/model/node.js +++ b/packages/tree/src/model/node.js @@ -355,6 +355,9 @@ export default class Node { setChecked(value, deep, recursion, passValue) { this.indeterminate = value === 'half'; + + if (this.store.filterCheckStrictly && !this.visible) return; + this.checked = value === true; if (this.store.checkStrictly) return; diff --git a/packages/tree/src/tree.vue b/packages/tree/src/tree.vue index 5b1c1b4c4..24b26340f 100644 --- a/packages/tree/src/tree.vue +++ b/packages/tree/src/tree.vue @@ -128,7 +128,8 @@ type: Number, default: 18 }, - iconClass: String + iconClass: String, + filterCheckStrictly: Boolean }, computed: { @@ -173,6 +174,10 @@ checkStrictly(newVal) { this.store.checkStrictly = newVal; + }, + + filterCheckStrictly(newVal) { + this.store.filterCheckStrictly = newVal; } }, @@ -330,6 +335,7 @@ load: this.load, currentNodeKey: this.currentNodeKey, checkStrictly: this.checkStrictly, + filterCheckStrictly: this.filterCheckStrictly, checkDescendants: this.checkDescendants, defaultCheckedKeys: this.defaultCheckedKeys, defaultExpandedKeys: this.defaultExpandedKeys,