diff --git a/changelog.md b/changelog.md index f1f088975..d480587b1 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,6 @@ # 更新日志 2.0(2020-09) +- 修复同步复选下拉框系列setValue所有值后触发器不显示全选的问题 - BI.Tree.traversal方法迭代函数增加父节点参数 2.0(2020-08) diff --git a/src/component/valuechooser/abstract.valuechooser.js b/src/component/valuechooser/abstract.valuechooser.js index ac4b08ae5..bd1ab309c 100644 --- a/src/component/valuechooser/abstract.valuechooser.js +++ b/src/component/valuechooser/abstract.valuechooser.js @@ -88,5 +88,20 @@ BI.AbstractValueChooser = BI.inherit(BI.Widget, { hasNext: self._hasNextByTimes(resultItems, options.times) }); } - } + }, + + _assertValue: function (v) { + v = v || {}; + var value = v; + if (v.type === BI.Selection.Multi && BI.isNotNull(this.items)) { + var isAllSelect = BI.difference(BI.map(this.items, "value"), v.value).length === 0; + if (isAllSelect) { + value = { + type: BI.Selection.All, + value: [], + }; + } + } + return value; + }, }); \ No newline at end of file diff --git a/src/component/valuechooser/combo.valuechooser.insert.js b/src/component/valuechooser/combo.valuechooser.insert.js index b86963806..cc64d15b6 100644 --- a/src/component/valuechooser/combo.valuechooser.insert.js +++ b/src/component/valuechooser/combo.valuechooser.insert.js @@ -26,7 +26,7 @@ BI.ValueChooserInsertCombo = BI.inherit(BI.AbstractValueChooser, { element: this, allowEdit: o.allowEdit, text: o.text, - value: o.value, + value: this._assertValue(o.value), itemsCreator: BI.bind(this._itemsCreator, this), valueFormatter: BI.bind(this._valueFormatter, this), width: o.width, @@ -66,7 +66,7 @@ BI.ValueChooserInsertCombo = BI.inherit(BI.AbstractValueChooser, { }, setValue: function (v) { - this.combo.setValue(v); + this.combo.setValue(this._assertValue(v)); }, getValue: function () { diff --git a/src/component/valuechooser/combo.valuechooser.js b/src/component/valuechooser/combo.valuechooser.js index f7a1c6a35..9f1a05f8d 100644 --- a/src/component/valuechooser/combo.valuechooser.js +++ b/src/component/valuechooser/combo.valuechooser.js @@ -30,7 +30,7 @@ BI.ValueChooserCombo = BI.inherit(BI.AbstractValueChooser, { element: this, allowEdit: o.allowEdit, text: o.text, - value: o.value, + value: this._assertValue(o.value), itemsCreator: BI.bind(this._itemsCreator, this), valueFormatter: BI.bind(this._valueFormatter, this), width: o.width, @@ -70,7 +70,7 @@ BI.ValueChooserCombo = BI.inherit(BI.AbstractValueChooser, { }, setValue: function (v) { - this.combo.setValue(v); + this.combo.setValue(this._assertValue(v)); }, getValue: function () {