From 1b1832c843d8ed007c432bdf55e359ed57753354 Mon Sep 17 00:00:00 2001 From: guy Date: Fri, 9 Sep 2022 14:33:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=95=E9=80=89=E4=B8=8B=E6=8B=89=E6=A1=86?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=A4=9A=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../combo/textvaluecombo/combo.textvalue.js | 23 +++++++++++++++++-- .../combo/textvaluecombo/popup.textvalue.js | 2 +- src/case/trigger/trigger.text.select.js | 4 ++-- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/case/combo/textvaluecombo/combo.textvalue.js b/src/case/combo/textvaluecombo/combo.textvalue.js index d6c80ac95..f027474dd 100644 --- a/src/case/combo/textvaluecombo/combo.textvalue.js +++ b/src/case/combo/textvaluecombo/combo.textvalue.js @@ -72,6 +72,7 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { } ], }; + let changeTag = false; const popup = { type: "bi.text_value_combo_popup", ref: ref => this.popup = ref, @@ -81,9 +82,12 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { { eventName: BI.TextValueComboPopup.EVENT_CHANGE, action: (...args) => { + changeTag = true; this.setValue(this.popup.getValue()); - this.combo.hideView(); - this.fireEvent(BI.TextValueCombo.EVENT_CHANGE, ...args); + if (o.chooseType === BI.ButtonGroup.CHOOSE_TYPE_SINGLE) { + this.combo.hideView(); + this.fireEvent(BI.TextValueCombo.EVENT_CHANGE, ...args); + } } }, { eventName: BI.Controller.EVENT_CHANGE, @@ -101,6 +105,21 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { direction: o.direction, adjustLength: 2, el: trigger, + listeners: [ + { + eventName: BI.Combo.EVENT_BEFORE_POPUPVIEW, + action: (...args) => { + changeTag = false; + } + }, { + eventName: BI.Combo.EVENT_AFTER_HIDEVIEW, + action: (...args) => { + if (changeTag) { + this.fireEvent(BI.TextValueCombo.EVENT_CHANGE, ...args); + } + } + } + ], popup: { el: popup, value: o.value, diff --git a/src/case/combo/textvaluecombo/popup.textvalue.js b/src/case/combo/textvaluecombo/popup.textvalue.js index 6702f8bfa..1876c9a55 100644 --- a/src/case/combo/textvaluecombo/popup.textvalue.js +++ b/src/case/combo/textvaluecombo/popup.textvalue.js @@ -39,7 +39,7 @@ BI.TextValueComboPopup = BI.inherit(BI.Pane, { var o = this.options; return BI.map(items, function (i, item) { return BI.extend({ - type: "bi.single_select_item", + type: o.chooseType === BI.ButtonGroup.CHOOSE_TYPE_SINGLE ? "bi.single_select_item" : "bi.multi_select_item", textAlign: o.textAlign, title: item.title || item.text }, item); diff --git a/src/case/trigger/trigger.text.select.js b/src/case/trigger/trigger.text.select.js index 3be2d7757..c6c1b3923 100644 --- a/src/case/trigger/trigger.text.select.js +++ b/src/case/trigger/trigger.text.select.js @@ -52,7 +52,7 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, { _digest: function (val, items) { var o = this.options; - val = BI.isArray(val) ? val[0] : val; + val = BI.isArray(val) ? val : [val]; // 提升valueFormatter的优先级 if (o.valueFormatter !== BI.emptyFn && BI.isFunction(o.valueFormatter)) { @@ -65,7 +65,7 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, { var formatItems = BI.Tree.transformToArrayFormat(items); BI.each(formatItems, function (i, item) { - if (val === item.value && !BI.contains(result, item.text || item.value)) { + if (BI.contains(val, item.value) && !BI.contains(result, item.text || item.value)) { result.push(item.text || item.value); } });