Browse Source

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

es6
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) {
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;
}

42
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 () {

Loading…
Cancel
Save