From 399d2c7a12b017053188109109a035ca85455020 Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Fri, 14 Feb 2020 15:46:00 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-24695=20fix:=20=E4=B8=8D=E5=BD=B1?= =?UTF-8?q?=E5=93=8D=E7=88=B6=E5=AD=90=E8=8A=82=E7=82=B9=E5=8B=BE=E9=80=89?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E7=9A=84=E6=A0=91=E5=9C=A8=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E9=80=89=E4=B8=AD=E6=97=B6=E7=9A=84=E5=A4=84=E7=90=86=20&&=20?= =?UTF-8?q?=E7=B1=BB=E6=94=B9=E6=88=90=E7=94=9F=E5=91=BD=E5=91=A8=E6=9C=9F?= =?UTF-8?q?=E5=BD=A2=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../abstract.treevaluechooser.list.js | 16 +++---- .../trigger/multi.tree.search.pane.js | 42 ++++++++++--------- 2 files changed, 31 insertions(+), 27 deletions(-) diff --git a/src/component/treevaluechooser/abstract.treevaluechooser.list.js b/src/component/treevaluechooser/abstract.treevaluechooser.list.js index 182b47af27..526ce4c67f 100644 --- a/src/component/treevaluechooser/abstract.treevaluechooser.list.js +++ b/src/component/treevaluechooser/abstract.treevaluechooser.list.js @@ -107,7 +107,7 @@ BI.AbstractListTreeValueChooser = BI.inherit(BI.AbstractTreeValueChooser, { function nodeSearch(deep, parentValues, current, result) { if (self._isMatch(parentValues, current, keyword)) { - var checked = isSelected(current); + var checked = isSelected(parentValues, current); createOneJson(parentValues, current, false, checked, true, result); return [true, checked]; } @@ -127,7 +127,7 @@ BI.AbstractListTreeValueChooser = BI.inherit(BI.AbstractTreeValueChooser, { } }); if (can === true) { - checked = isSelected(current); + checked = isSelected(parentValues, current); createOneJson(parentValues, current, true, checked, false, result); } return [can, checked]; @@ -177,9 +177,9 @@ BI.AbstractListTreeValueChooser = BI.inherit(BI.AbstractTreeValueChooser, { }); } - function isSelected(value) { + function isSelected(parentValues, value) { return BI.any(selectedValues, function (idx, array) { - return BI.last(array) === value; + return BI.isEqual(parentValues, array.slice(0, parentValues.length)) && BI.last(array) === value; }); } @@ -205,7 +205,7 @@ BI.AbstractListTreeValueChooser = BI.inherit(BI.AbstractTreeValueChooser, { var times = op.times; var parentValues = op.parentValues || []; var selectedValues = op.selectedValues || []; - var valueMap = dealWithSelectedValue(selectedValues); + var valueMap = dealWithSelectedValue(parentValues, selectedValues); var nodes = this._getChildren(parentValues); for (var i = (times - 1) * this._const.perPage; nodes[i] && i < times * this._const.perPage; i++) { var checked = BI.has(valueMap, nodes[i].value); @@ -254,10 +254,12 @@ BI.AbstractListTreeValueChooser = BI.inherit(BI.AbstractTreeValueChooser, { }); }); - function dealWithSelectedValue(selectedValues) { + function dealWithSelectedValue(parentValues, selectedValues) { var valueMap = {}; BI.each(selectedValues, function (idx, v) { - valueMap[BI.last(v)] = [2, 0]; + if (BI.isEqual(parentValues, v.slice(0, parentValues.length))) { + valueMap[BI.last(v)] = [2, 0]; + } }); return valueMap; } diff --git a/src/widget/multitree/trigger/multi.tree.search.pane.js b/src/widget/multitree/trigger/multi.tree.search.pane.js index 7e752e1e12..a18ab2a04a 100644 --- a/src/widget/multitree/trigger/multi.tree.search.pane.js +++ b/src/widget/multitree/trigger/multi.tree.search.pane.js @@ -7,20 +7,16 @@ BI.MultiTreeSearchPane = BI.inherit(BI.Pane, { - _defaultConfig: function () { - return BI.extend(BI.MultiTreeSearchPane.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-multi-tree-search-pane bi-card", - itemsCreator: BI.emptyFn, - keywordGetter: BI.emptyFn - }); + props: { + baseCls: "bi-multi-tree-search-pane bi-card", + itemsCreator: BI.emptyFn, + keywordGetter: BI.emptyFn }, - _init: function () { - BI.MultiTreeSearchPane.superclass._init.apply(this, arguments); - + render: function () { var self = this, opts = this.options; - this.partTree = BI.createWidget(opts.el, { + return BI.extend({ type: "bi.part_tree", element: this, tipText: BI.i18nText("BI-No_Select"), @@ -28,16 +24,22 @@ BI.MultiTreeSearchPane = BI.inherit(BI.Pane, { op.keyword = opts.keywordGetter(); opts.itemsCreator(op, callback); }, - value: opts.value - }); - - this.partTree.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - - this.partTree.on(BI.TreeView.EVENT_CHANGE, function () { - self.fireEvent(BI.MultiTreeSearchPane.EVENT_CHANGE); - }); + value: opts.value, + listeners: [{ + eventName: BI.Controller.EVENT_CHANGE, + action: function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + } + }, { + eventName: BI.TreeView.EVENT_CHANGE, + action: function () { + self.fireEvent(BI.MultiTreeSearchPane.EVENT_CHANGE); + } + }], + ref: function (_ref) { + self.partTree = _ref; + } + }, opts.el); }, hasChecked: function () {