Browse Source

BI-61057 refactor: 新增getAllValue方法

es6
windy 4 years ago
parent
commit
67a3239f97
  1. 2
      changelog.md
  2. 34
      src/component/treevaluechooser/abstract.treevaluechooser.js
  3. 4
      src/component/treevaluechooser/combo.treevaluechooser.js
  4. 4
      src/component/treevaluechooser/pane.treevaluechooser.js
  5. 9
      src/component/valuechooser/combo.valuechooser.insert.js
  6. 9
      src/component/valuechooser/combo.valuechooser.js
  7. 9
      src/component/valuechooser/pane.valuechooser.js

2
changelog.md

@ -1,5 +1,7 @@
# 更新日志
2.0(2020-07)
- 同步复选下拉及其面板新增getAllValue获取所有已选值
- 同步复选下拉树及其面板新增getAllValue获取完整的选中树节点
- 修复date_picker最大值最小值与面板展示判断问题
- 复选下拉树和下拉列表添加showView和hideVIew方法
- number_editor支持自动检测数值与范围是否合法

34
src/component/treevaluechooser/abstract.treevaluechooser.js

@ -783,5 +783,35 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
_getChildCount: function (parentValues) {
return this._getChildren(parentValues).length;
}
});
},
buildCompleteTree: function (selectedValues) {
var self = this;
var result = {};
if (selectedValues !== null && !BI.isEmpty(selectedValues)) {
fill([], this.tree.getRoot(), selectedValues, result);
}
return result;
function fill(parentValues, node, selected, r) {
if (selected === null || BI.isEmpty(selected)) {
BI.each(node.getChildren(), function (i, child) {
var newParents = BI.clone(parentValues);
newParents.push(child.value);
r[child.value] = {};
fill(newParents, child, null, r[child.value]);
});
return;
}
BI.each(selected, function (k) {
var node = self._getTreeNode(parentValues, k);
var newParents = BI.clone(parentValues);
newParents.push(node.value);
r[k] = {};
fill(newParents, node, selected[k], r[k]);
});
}
},
});

4
src/component/treevaluechooser/combo.treevaluechooser.js

@ -91,6 +91,10 @@ BI.TreeValueChooserCombo = BI.inherit(BI.AbstractTreeValueChooser, {
return this.combo.getValue();
},
getAllValue: function() {
return this.buildCompleteTree(this.combo.getValue());
},
populate: function (items) {
this._initData(items);
this.combo.populate.apply(this.combo, arguments);

4
src/component/treevaluechooser/pane.treevaluechooser.js

@ -45,6 +45,10 @@ BI.TreeValueChooserPane = BI.inherit(BI.AbstractTreeValueChooser, {
return this.pane.getValue();
},
getAllValue: function() {
return this.buildCompleteTree(this.combo.getValue());
},
populate: function () {
this.pane.populate.apply(this.pane, arguments);
}

9
src/component/valuechooser/combo.valuechooser.insert.js

@ -77,6 +77,15 @@ BI.ValueChooserInsertCombo = BI.inherit(BI.AbstractValueChooser, {
};
},
getAllValue: function() {
var val = this.combo.getValue() || {};
if (val.type === BI.Selection.Multi) {
return val.value || [];
}
return BI.difference(BI.map(this.items, "value"), val.value || []);
},
populate: function (items) {
// 直接用combo的populate不会作用到AbstractValueChooser上
this.items = items;

9
src/component/valuechooser/combo.valuechooser.js

@ -81,6 +81,15 @@ BI.ValueChooserCombo = BI.inherit(BI.AbstractValueChooser, {
};
},
getAllValue: function() {
var val = this.combo.getValue() || {};
if (val.type === BI.Selection.Multi) {
return val.value || [];
}
return BI.difference(BI.map(this.items, "value"), val.value || []);
},
populate: function (items) {
// 直接用combo的populate不会作用到AbstractValueChooser上
this.items = items;

9
src/component/valuechooser/pane.valuechooser.js

@ -49,6 +49,15 @@ BI.ValueChooserPane = BI.inherit(BI.AbstractValueChooser, {
};
},
getAllValue: function() {
var val = this.combo.getValue() || {};
if (val.type === BI.Selection.Multi) {
return val.value || [];
}
return BI.difference(BI.map(this.items, "value"), val.value || []);
},
populate: function (items) {
// 直接用combo的populate不会作用到AbstractValueChooser上
items && (this.items = items);

Loading…
Cancel
Save