From 87355e8689acf9d781377dccdb6a15143f95cbe6 Mon Sep 17 00:00:00 2001 From: zsmj Date: Tue, 29 Nov 2022 17:52:58 +0800 Subject: [PATCH] =?UTF-8?q?KERNEL-13662=20feat:=20text=5Fvalue=5Fcombo=20?= =?UTF-8?q?=E5=A4=8D=E9=80=89,=E6=94=AF=E6=8C=81=E4=B8=8D=E5=B8=A6?= =?UTF-8?q?=E5=85=A8=E9=80=89=20-=20from=20Richie?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/js/case/combo/demo.text_value_combo.js | 30 +-- .../combo/textvaluecombo/combo.textvalue.js | 4 +- .../combo/textvaluecombo/popup.textvalue.js | 185 +++++++++++------- 3 files changed, 136 insertions(+), 83 deletions(-) diff --git a/demo/js/case/combo/demo.text_value_combo.js b/demo/js/case/combo/demo.text_value_combo.js index 15df83c54..cf6b30feb 100644 --- a/demo/js/case/combo/demo.text_value_combo.js +++ b/demo/js/case/combo/demo.text_value_combo.js @@ -8,19 +8,21 @@ Demo.TextValueCombo = BI.inherit(BI.Widget, { render: function () { var combo1, combo2; - var items = [{ - text: "MVC-1", - iconCls: "date-font", - value: 1 - }, { - text: "MVC-2", - iconCls: "search-font", - value: 2 - }, { - text: "MVC-3", - iconCls: "pull-right-font", - value: 3 - }]; + var items = [ + { + text: "MVC-1", + iconCls: "date-font", + value: 1 + }, { + text: "MVC-2", + iconCls: "search-font", + value: 2 + }, { + text: "MVC-3", + iconCls: "pull-right-font", + value: 3 + } + ]; // 创建下拉框各种场景用例 return { @@ -195,6 +197,8 @@ Demo.TextValueCombo = BI.inherit(BI.Widget, { allowClear: true, defaultText: "请选择", chooseType: BI.Selection.Multi, + value: [1], + // allowSelectAll: false, listeners: [ { eventName: BI.TextValueCombo.EVENT_CHANGE, diff --git a/src/case/combo/textvaluecombo/combo.textvalue.js b/src/case/combo/textvaluecombo/combo.textvalue.js index 1128f4ed8..02642da1a 100644 --- a/src/case/combo/textvaluecombo/combo.textvalue.js +++ b/src/case/combo/textvaluecombo/combo.textvalue.js @@ -16,7 +16,8 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { el: {}, allowClear: false, status: "success", // success | warning | error, - title: null + title: null, + allowSelectAll: true, }); }, @@ -78,6 +79,7 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { ref: ref => this.popup = ref, chooseType: o.chooseType, items: o.items, + allowSelectAll: o.allowSelectAll, listeners: [ { eventName: BI.TextValueComboPopup.EVENT_CHANGE, diff --git a/src/case/combo/textvaluecombo/popup.textvalue.js b/src/case/combo/textvaluecombo/popup.textvalue.js index 3f50089af..fa0de7c23 100644 --- a/src/case/combo/textvaluecombo/popup.textvalue.js +++ b/src/case/combo/textvaluecombo/popup.textvalue.js @@ -2,92 +2,132 @@ BI.TextValueComboPopup = BI.inherit(BI.Pane, { _defaultConfig: function () { return BI.extend(BI.TextValueComboPopup.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-text-icon-popup", - chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE + chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, + allowSelectAll: true, }); }, - render () { + render() { var o = this.options, self = this; if (o.chooseType !== BI.ButtonGroup.CHOOSE_TYPE_MULTI) { return { type: "bi.vertical", vgap: 5, - items: [{ - type: "bi.button_group", - ref: (_ref) => { - this.popup = _ref; - }, - items: this._formatItems(o.items), - chooseType: o.chooseType, - layouts: [{ - type: "bi.vertical" - }], - value: o.value, - listeners: [{ - eventName: BI.Controller.EVENT_CHANGE, - action: function (type, val, obj) { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - if (type === BI.Events.CLICK) { - self.fireEvent(BI.TextValueComboPopup.EVENT_CHANGE, val, obj); + items: [ + { + type: "bi.button_group", + ref: (_ref) => { + this.popup = _ref; + }, + items: this._formatItems(o.items), + chooseType: o.chooseType, + layouts: [ + { + type: "bi.vertical" } - } - }] - }] + ], + value: o.value, + listeners: [ + { + eventName: BI.Controller.EVENT_CHANGE, + action: function (type, val, obj) { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + if (type === BI.Events.CLICK) { + self.fireEvent(BI.TextValueComboPopup.EVENT_CHANGE, val, obj); + } + } + } + ] + } + ] }; } return { type: "bi.vertical", verticalAlign: BI.VerticalAlign.Stretch, rowSize: ["fill", ""], - items: [{ - type: "bi.select_list", - logic: { - dynamic: true, - innerVgap: 5, - rowSize: ["", "fill"], - verticalAlign: BI.VerticalAlign.Stretch - }, - ref: (_ref) => { - this.popup = _ref; - }, - el: { - el: { - chooseType: o.chooseType + items: [ + { + el: o.allowSelectAll ? { + type: "bi.select_list", + logic: { + dynamic: true, + innerVgap: 5, + rowSize: ["", "fill"], + verticalAlign: BI.VerticalAlign.Stretch + }, + ref: (_ref) => { + this.popup = _ref; + }, + el: { + el: { + chooseType: o.chooseType, + } + }, + items: this._formatItems(o.items), + value: { + type: BI.ButtonGroup.CHOOSE_TYPE_MULTI, + value: o.value + }, + listeners: [ + { + eventName: BI.SelectList.EVENT_CHANGE, + action: function (val) { + self.fireEvent(BI.TextValueComboPopup.EVENT_CHANGE, val); + } + } + ] + } : { + type: "bi.list_pane", + logic: { + dynamic: true, + innerVgap: 5, + rowSize: ["", "fill"], + verticalAlign: BI.VerticalAlign.Stretch + }, + ref: (_ref) => { + this.popup = _ref; + }, + el: { + chooseType: o.chooseType, + }, + items: this._formatItems(o.items), + value: o.value, + listeners: [ + { + eventName: BI.ListPane.EVENT_CHANGE, + action: function (val) { + self.fireEvent(BI.TextValueComboPopup.EVENT_CHANGE, val); + } + } + ] } }, - items: this._formatItems(o.items), - value: { - type: BI.ButtonGroup.CHOOSE_TYPE_MULTI, - value: o.value - }, - listeners: [{ - eventName: BI.SelectList.EVENT_CHANGE, - action: function (val) { - self.fireEvent(BI.TextValueComboPopup.EVENT_CHANGE, val); - } - }] - }, { - type: "bi.center", - cls: "list-view-toolbar bi-high-light bi-split-top", - height: 24, - items: BI.createItems([{ - type: "bi.text_button", - text: BI.i18nText("BI-Basic_Clears"), - handler: function () { - self.fireEvent(BI.TextValueComboPopup.EVENT_CLEAR); - } - }, { - type: "bi.text_button", - text: BI.i18nText("BI-Basic_OK"), - handler: function () { - self.fireEvent(BI.TextValueComboPopup.EVENT_CONFIRM); - } - }], { - once: false, - shadow: true, - isShadowShowingOnSelected: true - }) - }] + { + type: "bi.center", + cls: "list-view-toolbar bi-high-light bi-split-top", + height: 24, + items: BI.createItems([ + { + type: "bi.text_button", + text: BI.i18nText("BI-Basic_Clears"), + handler: function () { + self.fireEvent(BI.TextValueComboPopup.EVENT_CLEAR); + } + }, { + type: "bi.text_button", + text: BI.i18nText("BI-Basic_OK"), + handler: function () { + self.fireEvent(BI.TextValueComboPopup.EVENT_CONFIRM); + } + } + ], { + once: false, + shadow: true, + isShadowShowingOnSelected: true + }) + } + ] }; }, @@ -117,6 +157,9 @@ BI.TextValueComboPopup = BI.inherit(BI.Pane, { return this.popup.getValue(); } var val = this.popup.getValue(); + if (!this.options.allowSelectAll) { + return val; + } if (val.type === BI.ButtonGroup.CHOOSE_TYPE_MULTI) { return val.value; } else { @@ -128,6 +171,10 @@ BI.TextValueComboPopup = BI.inherit(BI.Pane, { if (this.options.chooseType !== BI.ButtonGroup.CHOOSE_TYPE_MULTI) { return this.popup.setValue(v); } + if (!this.options.allowSelectAll) { + this.popup.setValue(v); + return; + } this.popup.setValue({ type: BI.ButtonGroup.CHOOSE_TYPE_MULTI, value: v