diff --git a/changelog.md b/changelog.md index 4865f27b5..bc702c9df 100644 --- a/changelog.md +++ b/changelog.md @@ -1,4 +1,7 @@ # 更新日志 +2.0(2020-09) +- 修复同步复选下拉框系列setValue所有值后触发器不显示全选的问题 + 2.0(2020-08) - bi.sign_editor支持显示值居左/居中/居右显示 - bi.iframe新增EVENT_LOADED事件 diff --git a/src/component/valuechooser/combo.valuechooser.insert.js b/src/component/valuechooser/combo.valuechooser.insert.js index b86963806..700794459 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, @@ -65,8 +65,23 @@ BI.ValueChooserInsertCombo = BI.inherit(BI.AbstractValueChooser, { }); }, + _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; + }, + 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..e39515b98 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, @@ -69,8 +69,23 @@ BI.ValueChooserCombo = BI.inherit(BI.AbstractValueChooser, { }); }, + _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; + }, + setValue: function (v) { - this.combo.setValue(v); + this.combo.setValue(this._assertValue(v)); }, getValue: function () {