From 42eea2a91ad41efc196eb083d662abdf2be86d39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=2EKing-=E7=8E=8B=E5=87=AF=E5=A3=AE?= Date: Fri, 14 Jul 2023 11:28:03 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-97526=20feat:=E7=BB=99=E5=B8=A6=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E7=9A=84=E5=A4=9A=E9=80=89=E5=A4=9A=E5=B1=82=E7=BA=A7?= =?UTF-8?q?=E6=A0=91=E5=A2=9E=E5=8A=A0searcherPaneAutoShrink,searcherPaneI?= =?UTF-8?q?sSelectedAny=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/fineui/src/case/ztree/parttree.js | 13 +++++++++++-- .../treevaluechooser/abstract.treevaluechooser.js | 2 +- .../treevaluechooser/pane.treevaluechooser.js | 9 ++++++++- .../src/widget/multiselecttree/multiselecttree.js | 2 ++ .../multitree/trigger/multi.tree.search.pane.js | 6 +++++- 5 files changed, 27 insertions(+), 5 deletions(-) diff --git a/packages/fineui/src/case/ztree/parttree.js b/packages/fineui/src/case/ztree/parttree.js index 2a93dd7bb..266e0d6b9 100644 --- a/packages/fineui/src/case/ztree/parttree.js +++ b/packages/fineui/src/case/ztree/parttree.js @@ -16,6 +16,12 @@ export class PartTree extends AsyncTree { static EVENT_CLICK_TREE_NODE = "EVENT_CLICK_TREE_NODE"; + _defaultConfig() { + return extend(super._defaultConfig(...arguments), { + isSelectedAny: true, //是否返回所有被checked的结点(包括被checked的结点的子结点) + }); + } + constructor(...args) { super(...args); this.seMethos = super._selectTreeNode; @@ -55,8 +61,11 @@ export class PartTree extends AsyncTree { const name = this._getNodeValue(treeNode); this.fireEvent(PartTree.EVENT_CLICK_TREE_NODE); if (treeNode.checked === true) { - this.options.paras.selectedValues = this._getUnionValue(); - // this._buildTree(self.options.paras.selectedValues, concat(parentValues, name)); + if (this.options.isSelectedAny) { + this.options.paras.selectedValues = this._getUnionValue(); //获取所有被selected的结点 + } else { + this._addTreeNode(this.options.paras.selectedValues, parentValues, name, {});//给selectedValues增加被click的结点(不包含该节点的子结点) + } o.itemsCreator( extend({}, o.paras, { type: TreeView.REQ_TYPE_ADJUST_DATA, diff --git a/packages/fineui/src/component/treevaluechooser/abstract.treevaluechooser.js b/packages/fineui/src/component/treevaluechooser/abstract.treevaluechooser.js index 87e23cb84..61323f27c 100644 --- a/packages/fineui/src/component/treevaluechooser/abstract.treevaluechooser.js +++ b/packages/fineui/src/component/treevaluechooser/abstract.treevaluechooser.js @@ -389,7 +389,7 @@ export class AbstractTreeValueChooser extends Widget { each(selected, (k, v) => { const p = clone(parents); p.push(k); - if (!dealWithSelectedValues(selected[k], p)) { + if (!dealWithSelectedValues(selected[k], p) || op.searcherPaneAutoShrink === false) { each(selected[k], (nk, nv) => { const t = clone(p); t.push(nk); diff --git a/packages/fineui/src/component/treevaluechooser/pane.treevaluechooser.js b/packages/fineui/src/component/treevaluechooser/pane.treevaluechooser.js index aad0bf08d..ff5aad90f 100644 --- a/packages/fineui/src/component/treevaluechooser/pane.treevaluechooser.js +++ b/packages/fineui/src/component/treevaluechooser/pane.treevaluechooser.js @@ -15,6 +15,9 @@ export class TreeValueChooserPane extends AbstractTreeValueChooser { items: null, itemsCreator: emptyFn, showLine: true, + //searcherPaneAutoShrink和searcherPaneIsSelectedAny同时为false时,返回值和非搜索状态下的树逻辑一致 + searcherPaneAutoShrink: true,//其搜索树是否会判别子结点全选则取父结点的值 + searcherPaneIsSelectedAny: true, //其搜索树是否返回所有被checked的结点(包括被checked的结点的子结点) }); } @@ -25,7 +28,11 @@ export class TreeValueChooserPane extends AbstractTreeValueChooser { type: o.hideSearch ? MultiSelectTreePopup.xtype : MultiSelectTree.xtype, element: this, showLine: o.showLine, - itemsCreator: bind(this._itemsCreator, this), + searcherPaneIsSelectedAny: o.hideSearch || o.searcherPaneIsSelectedAny, + itemsCreator: (options, callback) => { + options.searcherPaneAutoShrink = o.hideSearch || o.searcherPaneAutoShrink; + this._itemsCreator.call(this, options, callback); + }, }); this.pane.on(MultiSelectTree.EVENT_CHANGE, () => { diff --git a/packages/fineui/src/widget/multiselecttree/multiselecttree.js b/packages/fineui/src/widget/multiselecttree/multiselecttree.js index 9493f444b..1047a9601 100644 --- a/packages/fineui/src/widget/multiselecttree/multiselecttree.js +++ b/packages/fineui/src/widget/multiselecttree/multiselecttree.js @@ -16,6 +16,7 @@ export class MultiSelectTree extends Single { baseCls: "bi-multi-select-tree", itemsCreator: emptyFn, simple: false, + searcherPaneIsSelectedAny: true, }); } @@ -44,6 +45,7 @@ export class MultiSelectTree extends Single { this.searcherPane = createWidget({ type: MultiTreeSearchPane.xtype, cls: "bi-border-left bi-border-right bi-border-bottom", + isSelectedAny: o.searcherPaneIsSelectedAny, keywordGetter() { return self.searcher.getKeyword(); }, diff --git a/packages/fineui/src/widget/multitree/trigger/multi.tree.search.pane.js b/packages/fineui/src/widget/multitree/trigger/multi.tree.search.pane.js index 63de74987..01bb92499 100644 --- a/packages/fineui/src/widget/multitree/trigger/multi.tree.search.pane.js +++ b/packages/fineui/src/widget/multitree/trigger/multi.tree.search.pane.js @@ -6,7 +6,10 @@ import { TreeView, PartTree } from "@/case"; export class MultiTreeSearchPane extends Pane { static xtype = "bi.multi_tree_search_pane"; - props = { baseCls: "bi-multi-tree-search-pane bi-card" }; + props = { + baseCls: "bi-multi-tree-search-pane bi-card", + isSelectedAny: true, + }; static EVENT_CHANGE = "EVENT_CHANGE"; static EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM"; @@ -22,6 +25,7 @@ export class MultiTreeSearchPane extends Pane { type: PartTree.xtype, element: this, tipText: i18nText("BI-No_Select"), + isSelectedAny: opts.isSelectedAny, itemsCreator(op, callback) { op.keyword = opts.keywordGetter(); opts.itemsCreator(op, callback);