Browse Source

REPORT-24695 fix: 不影响父子节点勾选状态的树在搜索选中时的处理 && 类改成生命周期形式

master
windy 5 years ago
parent
commit
399d2c7a12
  1. 16
      src/component/treevaluechooser/abstract.treevaluechooser.list.js
  2. 42
      src/widget/multitree/trigger/multi.tree.search.pane.js

16
src/component/treevaluechooser/abstract.treevaluechooser.list.js

@ -107,7 +107,7 @@ BI.AbstractListTreeValueChooser = BI.inherit(BI.AbstractTreeValueChooser, {
function nodeSearch(deep, parentValues, current, result) { function nodeSearch(deep, parentValues, current, result) {
if (self._isMatch(parentValues, current, keyword)) { if (self._isMatch(parentValues, current, keyword)) {
var checked = isSelected(current); var checked = isSelected(parentValues, current);
createOneJson(parentValues, current, false, checked, true, result); createOneJson(parentValues, current, false, checked, true, result);
return [true, checked]; return [true, checked];
} }
@ -127,7 +127,7 @@ BI.AbstractListTreeValueChooser = BI.inherit(BI.AbstractTreeValueChooser, {
} }
}); });
if (can === true) { if (can === true) {
checked = isSelected(current); checked = isSelected(parentValues, current);
createOneJson(parentValues, current, true, checked, false, result); createOneJson(parentValues, current, true, checked, false, result);
} }
return [can, checked]; 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.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 times = op.times;
var parentValues = op.parentValues || []; var parentValues = op.parentValues || [];
var selectedValues = op.selectedValues || []; var selectedValues = op.selectedValues || [];
var valueMap = dealWithSelectedValue(selectedValues); var valueMap = dealWithSelectedValue(parentValues, selectedValues);
var nodes = this._getChildren(parentValues); var nodes = this._getChildren(parentValues);
for (var i = (times - 1) * this._const.perPage; nodes[i] && i < times * this._const.perPage; i++) { for (var i = (times - 1) * this._const.perPage; nodes[i] && i < times * this._const.perPage; i++) {
var checked = BI.has(valueMap, nodes[i].value); 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 = {}; var valueMap = {};
BI.each(selectedValues, function (idx, v) { 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; return valueMap;
} }

42
src/widget/multitree/trigger/multi.tree.search.pane.js

@ -7,20 +7,16 @@
BI.MultiTreeSearchPane = BI.inherit(BI.Pane, { BI.MultiTreeSearchPane = BI.inherit(BI.Pane, {
_defaultConfig: function () { props: {
return BI.extend(BI.MultiTreeSearchPane.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-multi-tree-search-pane bi-card",
baseCls: "bi-multi-tree-search-pane bi-card", itemsCreator: BI.emptyFn,
itemsCreator: BI.emptyFn, keywordGetter: BI.emptyFn
keywordGetter: BI.emptyFn
});
}, },
_init: function () { render: function () {
BI.MultiTreeSearchPane.superclass._init.apply(this, arguments);
var self = this, opts = this.options; var self = this, opts = this.options;
this.partTree = BI.createWidget(opts.el, { return BI.extend({
type: "bi.part_tree", type: "bi.part_tree",
element: this, element: this,
tipText: BI.i18nText("BI-No_Select"), tipText: BI.i18nText("BI-No_Select"),
@ -28,16 +24,22 @@ BI.MultiTreeSearchPane = BI.inherit(BI.Pane, {
op.keyword = opts.keywordGetter(); op.keyword = opts.keywordGetter();
opts.itemsCreator(op, callback); opts.itemsCreator(op, callback);
}, },
value: opts.value value: opts.value,
}); listeners: [{
eventName: BI.Controller.EVENT_CHANGE,
this.partTree.on(BI.Controller.EVENT_CHANGE, function () { action: function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
}); }
}, {
this.partTree.on(BI.TreeView.EVENT_CHANGE, function () { eventName: BI.TreeView.EVENT_CHANGE,
self.fireEvent(BI.MultiTreeSearchPane.EVENT_CHANGE); action: function () {
}); self.fireEvent(BI.MultiTreeSearchPane.EVENT_CHANGE);
}
}],
ref: function (_ref) {
self.partTree = _ref;
}
}, opts.el);
}, },
hasChecked: function () { hasChecked: function () {

Loading…
Cancel
Save