From 2f91a2c93f8b2b71dcc106e16a45331ac6ca127c Mon Sep 17 00:00:00 2001 From: zsmj Date: Mon, 19 Sep 2022 19:25:32 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=97=A0JIRA=20feat:=20text=5Fvalue=5Fcomb?= =?UTF-8?q?o=E5=A4=9A=E9=80=89=E5=8A=9F=E8=83=BD=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/js/case/combo/demo.text_value_combo.js | 26 ++++++++++++++++++- .../combo/textvaluecombo/combo.textvalue.js | 3 ++- src/case/trigger/trigger.text.select.js | 26 +++++-------------- 3 files changed, 33 insertions(+), 22 deletions(-) diff --git a/demo/js/case/combo/demo.text_value_combo.js b/demo/js/case/combo/demo.text_value_combo.js index 50e3fea43..44847adae 100644 --- a/demo/js/case/combo/demo.text_value_combo.js +++ b/demo/js/case/combo/demo.text_value_combo.js @@ -146,7 +146,7 @@ Demo.TextValueCombo = BI.inherit(BI.Widget, { type: "bi.button", text: "setValue(1)", handler: function () { - combo1.setValue(); + combo1.setValue(1); }, }, vgap: 10, @@ -184,6 +184,30 @@ Demo.TextValueCombo = BI.inherit(BI.Widget, { vgap: 10, } ] + }), + this.createCombo("支持复选", { + type: "bi.vertical", + items: [ + { + type: "bi.text_value_combo", + ref: function () { + combo2 = this; + }, + width: 300, + items: items, + allowClear: true, + defaultText: "请选择", + chooseType: BI.Selection.Multi, + listeners: [ + { + eventName: BI.TextValueCombo.EVENT_CHANGE, + action: function () { + console.log(this.getValue()); + } + } + ] + } + ] }) ] }; diff --git a/src/case/combo/textvaluecombo/combo.textvalue.js b/src/case/combo/textvaluecombo/combo.textvalue.js index 9a708cc83..7f726bd13 100644 --- a/src/case/combo/textvaluecombo/combo.textvalue.js +++ b/src/case/combo/textvaluecombo/combo.textvalue.js @@ -100,7 +100,7 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { eventName: BI.TextValueComboPopup.EVENT_CLEAR, action: (...args) => { changeTag = true; - this.setValue([]); + this._clear(); this.combo.hideView(); } }, { @@ -151,6 +151,7 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { }, _clear: function () { + this.trigger.setText(""); this.combo.setValue(); this.setStatus("success"); }, diff --git a/src/case/trigger/trigger.text.select.js b/src/case/trigger/trigger.text.select.js index 5a171be2e..cf1e2cdd9 100644 --- a/src/case/trigger/trigger.text.select.js +++ b/src/case/trigger/trigger.text.select.js @@ -20,15 +20,14 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, { _init: function () { BI.SelectTextTrigger.superclass._init.apply(this, arguments); var self = this, o = this.options; - var obj = this._digest(o.value, o.items); + var text = this._digest(o.value, o.items); this.trigger = BI.createWidget({ type: "bi.text_trigger", element: this, height: o.height, readonly: o.readonly, - text: obj.text, + text: text, defaultText: o.defaultText, - textCls: obj.textCls, textHgap: o.textHgap, textVgap: o.textVgap, textLgap: o.textLgap, @@ -73,21 +72,9 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, { }); if (result.length > 0 && val.length === 0) { - return { - textCls: "", - text: result.join(","), - }; + return result.join(","); } else { - var text = BI.isFunction(o.text) ? o.text() : o.text; - if (BI.isEmptyString(text)) { - return { - textCls: "bi-tips", - text: "" - }; - } - return { - text, - }; + return BI.isFunction(o.text) ? o.text() : o.text; } }, @@ -97,9 +84,8 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, { }, setValue: function (val) { - var formatValue = this._digest(val, this.options.items); - this.trigger.setTextCls(formatValue.textCls); - this.trigger.setText(formatValue.text); + var formatText = this._digest(val, this.options.items); + this.trigger.setText(formatText); }, setTipType: function (v) { From 8b35f6aed2db0c582afad5b446096aeaccd94d47 Mon Sep 17 00:00:00 2001 From: zsmj Date: Tue, 20 Sep 2022 10:18:25 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=97=A0JIRA=20feat:=20text=5Fvalue=5Fcomb?= =?UTF-8?q?o=E5=A4=9A=E9=80=89=E5=8A=9F=E8=83=BD=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/js/case/combo/demo.text_value_combo.js | 3 --- src/case/combo/textvaluecombo/combo.textvalue.js | 12 ++++++++++-- src/case/trigger/trigger.text.select.js | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/demo/js/case/combo/demo.text_value_combo.js b/demo/js/case/combo/demo.text_value_combo.js index 44847adae..15df83c54 100644 --- a/demo/js/case/combo/demo.text_value_combo.js +++ b/demo/js/case/combo/demo.text_value_combo.js @@ -190,9 +190,6 @@ Demo.TextValueCombo = BI.inherit(BI.Widget, { items: [ { type: "bi.text_value_combo", - ref: function () { - combo2 = this; - }, width: 300, items: items, allowClear: true, diff --git a/src/case/combo/textvaluecombo/combo.textvalue.js b/src/case/combo/textvaluecombo/combo.textvalue.js index 7f726bd13..ac39d5158 100644 --- a/src/case/combo/textvaluecombo/combo.textvalue.js +++ b/src/case/combo/textvaluecombo/combo.textvalue.js @@ -85,11 +85,15 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { eventName: BI.TextValueComboPopup.EVENT_CHANGE, action: (...args) => { changeTag = true; - this.setValue(this.popup.getValue()); + const value = this.popup.getValue(); + this.setValue(value); if (o.chooseType === BI.ButtonGroup.CHOOSE_TYPE_SINGLE) { this.combo.hideView(); this.fireEvent(BI.TextValueCombo.EVENT_CHANGE, ...args); } + if (o.chooseType === BI.ButtonGroup.CHOOSE_TYPE_MULTI && BI.isEmptyArray(value)) { + this._clear(); + } } }, { eventName: BI.Controller.EVENT_CHANGE, @@ -165,7 +169,7 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { var vals = BI.isArray(v) ? v : [v]; - var result = BI.intersection(BI.map(this.options.items, (i, item) => item.value), vals); + var result = BI.intersection(BI.map(this.options.items, "value"), vals); if (result.length !== vals.length) { this.setStatus("error"); @@ -178,6 +182,10 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { this._clear(); }, + setText: function (text) { + this.trigger.setText(text); + }, + setValue: function (v) { this.combo.setValue(v); this._checkError(v); diff --git a/src/case/trigger/trigger.text.select.js b/src/case/trigger/trigger.text.select.js index cf1e2cdd9..b20b4f1b5 100644 --- a/src/case/trigger/trigger.text.select.js +++ b/src/case/trigger/trigger.text.select.js @@ -85,7 +85,7 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, { setValue: function (val) { var formatText = this._digest(val, this.options.items); - this.trigger.setText(formatText); + this.setText(formatText); }, setTipType: function (v) { From d6c9f0c4181aedffe79963d0ba4da8982bd23afe Mon Sep 17 00:00:00 2001 From: zsmj Date: Tue, 20 Sep 2022 11:22:33 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=97=A0JIRA=20feat:=20text=5Fvalue=5Fcomb?= =?UTF-8?q?o=E5=A4=9A=E9=80=89=E5=8A=9F=E8=83=BD=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/case/trigger/trigger.text.select.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/case/trigger/trigger.text.select.js b/src/case/trigger/trigger.text.select.js index b20b4f1b5..cf1e2cdd9 100644 --- a/src/case/trigger/trigger.text.select.js +++ b/src/case/trigger/trigger.text.select.js @@ -85,7 +85,7 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, { setValue: function (val) { var formatText = this._digest(val, this.options.items); - this.setText(formatText); + this.trigger.setText(formatText); }, setTipType: function (v) {