From ddc7127096f015e5b1d947a631bfaa19516a5fdb Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Thu, 31 Dec 2020 14:38:22 +0800 Subject: [PATCH 1/3] =?UTF-8?q?BI-77753=20=E6=96=B0=E5=A2=9E=E4=B8=8D?= =?UTF-8?q?=E5=B8=A6=E5=85=A8=E9=80=89=E7=9A=84=E5=90=8C=E6=AD=A5=E5=A4=8D?= =?UTF-8?q?=E9=80=89=E4=B8=8B=E6=8B=89=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- changelog.md | 1 + demo/js/component/demo.valuechoosercombo.js | 10 +- .../valuechooser/combo.valuechooser.nobar.js | 96 +++++++++++++++++++ 3 files changed, 105 insertions(+), 2 deletions(-) create mode 100644 src/component/valuechooser/combo.valuechooser.nobar.js diff --git a/changelog.md b/changelog.md index a4910b145..3e69fb307 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,6 @@ # 更新日志 2.0(2020-12) +- 新增不带全选的同步复选下拉框 - 日期选择控件为年月选择器子组件新增POPUP弹出前事件 - 文件上传控件新增API(setMaxFileLength)以动态设置最大上传文件数量 - 复选下拉树显示查看已选效果改成和复选下拉列表一致 diff --git a/demo/js/component/demo.valuechoosercombo.js b/demo/js/component/demo.valuechoosercombo.js index bd0d84112..1fd1485cd 100644 --- a/demo/js/component/demo.valuechoosercombo.js +++ b/demo/js/component/demo.valuechoosercombo.js @@ -4,10 +4,16 @@ Demo.ValueChooserCombo = BI.inherit(BI.Widget, { }, render: function () { var widget = BI.createWidget({ - type: "bi.value_chooser_combo", + type: "bi.value_chooser_no_bar_combo", itemsCreator: function (op, callback) { callback(BI.deepClone(Demo.CONSTANTS.ITEMS)); - } + }, + listeners: [{ + eventName: "EVENT_CONFIRM", + action: function () { + BI.Msg.toast(widget.getValue()); + } + }] }); return { type: "bi.vertical", diff --git a/src/component/valuechooser/combo.valuechooser.nobar.js b/src/component/valuechooser/combo.valuechooser.nobar.js new file mode 100644 index 000000000..72c190e38 --- /dev/null +++ b/src/component/valuechooser/combo.valuechooser.nobar.js @@ -0,0 +1,96 @@ +/** + * @author windy + * @version 2.0 + * Created by windy on 2020/12/31 + */ +BI.ValueChooserNoBarCombo = BI.inherit(BI.AbstractValueChooser, { + + _defaultConfig: function () { + return BI.extend(BI.ValueChooserNoBarCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-value-chooser-combo", + width: 200, + height: 24, + items: null, + itemsCreator: BI.emptyFn, + cache: true + }); + }, + + _init: function () { + BI.ValueChooserNoBarCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + if (BI.isNotNull(o.items)) { + this.items = o.items; + } + this.combo = BI.createWidget({ + type: "bi.multi_select_no_bar_combo", + element: this, + allowEdit: o.allowEdit, + text: o.text, + value: this._assertValue(o.value), + itemsCreator: BI.bind(this._itemsCreator, this), + valueFormatter: BI.bind(this._valueFormatter, this), + width: o.width, + height: o.height, + listeners: [{ + eventName: BI.MultiSelectCombo.EVENT_FOCUS, + action: function () { + self.fireEvent(BI.ValueChooserNoBarCombo.EVENT_FOCUS); + } + }, { + eventName: BI.MultiSelectCombo.EVENT_BLUR, + action: function () { + self.fireEvent(BI.ValueChooserNoBarCombo.EVENT_BLUR); + } + }, { + eventName: BI.MultiSelectCombo.EVENT_STOP, + action: function () { + self.fireEvent(BI.ValueChooserNoBarCombo.EVENT_STOP); + } + }, { + eventName: BI.MultiSelectCombo.EVENT_CLICK_ITEM, + action: function () { + self.fireEvent(BI.ValueChooserNoBarCombo.EVENT_CLICK_ITEM); + } + }, { + eventName: BI.MultiSelectCombo.EVENT_SEARCHING, + action: function () { + self.fireEvent(BI.ValueChooserNoBarCombo.EVENT_SEARCHING); + } + }, { + eventName: BI.MultiSelectCombo.EVENT_CONFIRM, + action: function () { + self.fireEvent(BI.ValueChooserNoBarCombo.EVENT_CONFIRM); + } + }] + }); + }, + + setValue: function (v) { + this.combo.setValue(v); + }, + + getValue: function () { + return this.combo.getValue(); + }, + + getAllValue: function() { + return this.getValue(); + }, + + populate: function (items) { + // 直接用combo的populate不会作用到AbstractValueChooser上 + if (BI.isNotNull(items)) { + this.items = items; + } + this.combo.populate(); + } +}); + +BI.ValueChooserNoBarCombo.EVENT_BLUR = "EVENT_BLUR"; +BI.ValueChooserNoBarCombo.EVENT_FOCUS = "EVENT_FOCUS"; +BI.ValueChooserNoBarCombo.EVENT_STOP = "EVENT_STOP"; +BI.ValueChooserNoBarCombo.EVENT_SEARCHING = "EVENT_SEARCHING"; +BI.ValueChooserNoBarCombo.EVENT_CLICK_ITEM = "EVENT_CLICK_ITEM"; +BI.ValueChooserNoBarCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.shortcut("bi.value_chooser_no_bar_combo", BI.ValueChooserNoBarCombo); From cfd96d4dbc9f38667bf13d05b8774d64287ac305 Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Thu, 31 Dec 2020 14:38:51 +0800 Subject: [PATCH 2/3] update --- demo/js/component/demo.valuechoosercombo.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/demo/js/component/demo.valuechoosercombo.js b/demo/js/component/demo.valuechoosercombo.js index 1fd1485cd..bd0d84112 100644 --- a/demo/js/component/demo.valuechoosercombo.js +++ b/demo/js/component/demo.valuechoosercombo.js @@ -4,16 +4,10 @@ Demo.ValueChooserCombo = BI.inherit(BI.Widget, { }, render: function () { var widget = BI.createWidget({ - type: "bi.value_chooser_no_bar_combo", + type: "bi.value_chooser_combo", itemsCreator: function (op, callback) { callback(BI.deepClone(Demo.CONSTANTS.ITEMS)); - }, - listeners: [{ - eventName: "EVENT_CONFIRM", - action: function () { - BI.Msg.toast(widget.getValue()); - } - }] + } }); return { type: "bi.vertical", From 8a2ad961b7182f26b0ec1a5acaf2cf3007f4a3fc Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Thu, 31 Dec 2020 15:57:05 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=8C=89=E7=85=A7comment=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../valuechooser/combo.valuechooser.nobar.js | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/component/valuechooser/combo.valuechooser.nobar.js b/src/component/valuechooser/combo.valuechooser.nobar.js index 72c190e38..3fc381df3 100644 --- a/src/component/valuechooser/combo.valuechooser.nobar.js +++ b/src/component/valuechooser/combo.valuechooser.nobar.js @@ -5,26 +5,23 @@ */ BI.ValueChooserNoBarCombo = BI.inherit(BI.AbstractValueChooser, { - _defaultConfig: function () { - return BI.extend(BI.ValueChooserNoBarCombo.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-value-chooser-combo", - width: 200, - height: 24, - items: null, - itemsCreator: BI.emptyFn, - cache: true - }); + props: { + baseCls: "bi-value-chooser-combo", + width: 200, + height: 24, + items: null, + itemsCreator: BI.emptyFn, + cache: true }, - _init: function () { - BI.ValueChooserNoBarCombo.superclass._init.apply(this, arguments); + render: function () { var self = this, o = this.options; if (BI.isNotNull(o.items)) { this.items = o.items; } - this.combo = BI.createWidget({ + + return { type: "bi.multi_select_no_bar_combo", - element: this, allowEdit: o.allowEdit, text: o.text, value: this._assertValue(o.value), @@ -32,6 +29,9 @@ BI.ValueChooserNoBarCombo = BI.inherit(BI.AbstractValueChooser, { valueFormatter: BI.bind(this._valueFormatter, this), width: o.width, height: o.height, + ref: function(_ref) { + self.combo = _ref; + }, listeners: [{ eventName: BI.MultiSelectCombo.EVENT_FOCUS, action: function () { @@ -63,7 +63,7 @@ BI.ValueChooserNoBarCombo = BI.inherit(BI.AbstractValueChooser, { self.fireEvent(BI.ValueChooserNoBarCombo.EVENT_CONFIRM); } }] - }); + } }, setValue: function (v) {