From f033567b65afc7df3a442a291a8a7eec91212d81 Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Mon, 14 Sep 2020 14:52:02 +0800 Subject: [PATCH] =?UTF-8?q?BI-71788=20fix:=20=E5=B0=86=E6=89=80=E6=9C=89?= =?UTF-8?q?=E5=80=BCsetValue=E8=BF=9B=E5=85=A5=E5=90=8C=E6=AD=A5=E5=A4=8D?= =?UTF-8?q?=E9=80=89=E4=B8=8B=E6=8B=89=E5=90=8E=E8=A7=A6=E5=8F=91=E5=99=A8?= =?UTF-8?q?=E4=B8=8D=E6=98=BE=E7=A4=BA=E5=85=A8=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- changelog.md | 3 +++ .../valuechooser/combo.valuechooser.insert.js | 19 +++++++++++++++++-- .../valuechooser/combo.valuechooser.js | 19 +++++++++++++++++-- 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/changelog.md b/changelog.md index 4865f27b5c..bc702c9dff 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 b86963806f..7007944594 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 f7a1c6a351..e39515b983 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 () {