From a105c140ec6a0440c532ad7d3b08f64809760146 Mon Sep 17 00:00:00 2001 From: zsmj Date: Wed, 4 Jan 2023 16:19:26 +0800 Subject: [PATCH] =?UTF-8?q?BI-119658=20feat:=20MultiSelectCombo=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E6=90=9C=E7=B4=A2=E8=87=AA=E5=AE=9A=E4=B9=89itemForma?= =?UTF-8?q?tter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../multiselect/multiselect.combo.nobar.js | 89 +++++++++--------- .../multiselect/multiselect.insert.combo.js | 90 ++++++++++--------- .../multiselect.insert.combo.nobar.js | 87 +++++++++--------- .../multiselect/multiselect.insert.trigger.js | 30 ++++--- src/widget/multiselect/multiselect.trigger.js | 35 ++++---- .../search/multiselect.search.loader.js | 32 ++++--- .../trigger/searcher.multiselect.insert.js | 23 ++--- .../trigger/searcher.multiselect.js | 23 ++--- 8 files changed, 223 insertions(+), 186 deletions(-) diff --git a/src/widget/multiselect/multiselect.combo.nobar.js b/src/widget/multiselect/multiselect.combo.nobar.js index ce84a730e..d757ebbca 100644 --- a/src/widget/multiselect/multiselect.combo.nobar.js +++ b/src/widget/multiselect/multiselect.combo.nobar.js @@ -54,6 +54,7 @@ BI.MultiSelectNoBarCombo = BI.inherit(BI.Single, { }, valueFormatter: o.valueFormatter, itemsCreator: BI.bind(this._itemsCreator4Trigger, this), + itemFormatter: o.itemFormatter, itemHeight: o.itemHeight, value: { type: BI.Selection.Multi, @@ -134,29 +135,31 @@ BI.MultiSelectNoBarCombo = BI.inherit(BI.Single, { self.trigger.setAdapter(this); self.numberCounter.setAdapter(this); }, - listeners: [{ - eventName: BI.MultiSelectPopupView.EVENT_CHANGE, - action: function () { - self._dataChange = true; - self.storeValue = this.getValue(); - self._adjust(function () { - assertShowValue(); - }); - self.fireEvent(BI.MultiSelectNoBarCombo.EVENT_CLICK_ITEM); + listeners: [ + { + eventName: BI.MultiSelectPopupView.EVENT_CHANGE, + action: function () { + self._dataChange = true; + self.storeValue = this.getValue(); + self._adjust(function () { + assertShowValue(); + }); + self.fireEvent(BI.MultiSelectNoBarCombo.EVENT_CLICK_ITEM); + } + }, { + eventName: BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM, + action: function () { + self._defaultState(); + } + }, { + eventName: BI.MultiSelectPopupView.EVENT_CLICK_CLEAR, + action: function () { + self._dataChange = true; + self.setValue(); + self._defaultState(); + } } - }, { - eventName: BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM, - action: function () { - self._defaultState(); - } - }, { - eventName: BI.MultiSelectPopupView.EVENT_CLICK_CLEAR, - action: function () { - self._dataChange = true; - self.setValue(); - self._defaultState(); - } - }], + ], itemsCreator: o.itemsCreator, itemHeight: o.itemHeight, valueFormatter: o.valueFormatter, @@ -262,26 +265,28 @@ BI.MultiSelectNoBarCombo = BI.inherit(BI.Single, { BI.createWidget({ type: "bi.absolute", element: this, - items: [{ - el: this.combo, - left: 0, - right: 0, - top: 0, - bottom: 0 - }, { - el: triggerBtn, - right: 0, - top: 0, - bottom: 0 - }, { - el: { - type: "bi.vertical_adapt", - items: [this.numberCounter] - }, - right: o.height, - top: 0, - height: o.height - }] + items: [ + { + el: this.combo, + left: 0, + right: 0, + top: 0, + bottom: 0 + }, { + el: triggerBtn, + right: 0, + top: 0, + bottom: 0 + }, { + el: { + type: "bi.vertical_adapt", + items: [this.numberCounter] + }, + right: o.height, + top: 0, + height: o.height + } + ] }); }, diff --git a/src/widget/multiselect/multiselect.insert.combo.js b/src/widget/multiselect/multiselect.insert.combo.js index 6540e0dc9..c18aa6d90 100644 --- a/src/widget/multiselect/multiselect.insert.combo.js +++ b/src/widget/multiselect/multiselect.insert.combo.js @@ -55,6 +55,7 @@ BI.MultiSelectInsertCombo = BI.inherit(BI.Single, { }, valueFormatter: o.valueFormatter, itemsCreator: BI.bind(this._itemsCreator4Trigger, this), + itemFormatter: o.itemFormatter, itemHeight: o.itemHeight, value: this.storeValue, }); @@ -138,31 +139,34 @@ BI.MultiSelectInsertCombo = BI.inherit(BI.Single, { self.trigger.setAdapter(this); self.numberCounter.setAdapter(this); }, - listeners: [{ - eventName: BI.MultiSelectPopupView.EVENT_CHANGE, - action: function () { - self._dataChange = true; - self.storeValue = this.getValue(); - self._adjust(function () { - assertShowValue(); - }); - self.fireEvent(BI.MultiSelectInsertCombo.EVENT_CLICK_ITEM); + listeners: [ + { + eventName: BI.MultiSelectPopupView.EVENT_CHANGE, + action: function () { + self._dataChange = true; + self.storeValue = this.getValue(); + self._adjust(function () { + assertShowValue(); + }); + self.fireEvent(BI.MultiSelectInsertCombo.EVENT_CLICK_ITEM); + } + }, { + eventName: BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM, + action: function () { + self._defaultState(); + } + }, { + eventName: BI.MultiSelectPopupView.EVENT_CLICK_CLEAR, + action: function () { + self._dataChange = true; + self.setValue(); + self._defaultState(); + } } - }, { - eventName: BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM, - action: function () { - self._defaultState(); - } - }, { - eventName: BI.MultiSelectPopupView.EVENT_CLICK_CLEAR, - action: function () { - self._dataChange = true; - self.setValue(); - self._defaultState(); - } - }], + ], itemsCreator: o.itemsCreator, valueFormatter: o.valueFormatter, + itemFormatter: o.itemFormatter, itemHeight: o.itemHeight, onLoaded: function () { BI.nextTick(function () { @@ -260,26 +264,28 @@ BI.MultiSelectInsertCombo = BI.inherit(BI.Single, { BI.createWidget({ type: "bi.absolute", element: this, - items: [{ - el: this.combo, - left: 0, - right: 0, - top: 0, - bottom: 0 - }, { - el: triggerBtn, - right: 0, - top: 0, - bottom: 0 - }, { - el: { - type: "bi.vertical_adapt", - items: [this.numberCounter] - }, - right: o.height, - top: 0, - height: o.height, - }] + items: [ + { + el: this.combo, + left: 0, + right: 0, + top: 0, + bottom: 0 + }, { + el: triggerBtn, + right: 0, + top: 0, + bottom: 0 + }, { + el: { + type: "bi.vertical_adapt", + items: [this.numberCounter] + }, + right: o.height, + top: 0, + height: o.height, + } + ] }); }, diff --git a/src/widget/multiselect/multiselect.insert.combo.nobar.js b/src/widget/multiselect/multiselect.insert.combo.nobar.js index c7ff2109d..d3fbc3862 100644 --- a/src/widget/multiselect/multiselect.insert.combo.nobar.js +++ b/src/widget/multiselect/multiselect.insert.combo.nobar.js @@ -54,6 +54,7 @@ BI.MultiSelectInsertNoBarCombo = BI.inherit(BI.Single, { }, valueFormatter: o.valueFormatter, itemsCreator: BI.bind(this._itemsCreator4Trigger, this), + itemFormatter: o.itemFormatter, itemHeight: o.itemHeight, value: { type: BI.Selection.Multi, @@ -129,28 +130,30 @@ BI.MultiSelectInsertNoBarCombo = BI.inherit(BI.Single, { self.trigger.setAdapter(this); self.numberCounter.setAdapter(this); }, - listeners: [{ - eventName: BI.MultiSelectPopupView.EVENT_CHANGE, - action: function () { - self._dataChange = true; - self.storeValue = this.getValue(); - self._adjust(function () { - assertShowValue(); - }); + listeners: [ + { + eventName: BI.MultiSelectPopupView.EVENT_CHANGE, + action: function () { + self._dataChange = true; + self.storeValue = this.getValue(); + self._adjust(function () { + assertShowValue(); + }); + } + }, { + eventName: BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM, + action: function () { + self._defaultState(); + } + }, { + eventName: BI.MultiSelectPopupView.EVENT_CLICK_CLEAR, + action: function () { + self._dataChange = true; + self.setValue(); + self._defaultState(); + } } - }, { - eventName: BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM, - action: function () { - self._defaultState(); - } - }, { - eventName: BI.MultiSelectPopupView.EVENT_CLICK_CLEAR, - action: function () { - self._dataChange = true; - self.setValue(); - self._defaultState(); - } - }], + ], itemsCreator: o.itemsCreator, itemHeight: o.itemHeight, valueFormatter: o.valueFormatter, @@ -256,26 +259,28 @@ BI.MultiSelectInsertNoBarCombo = BI.inherit(BI.Single, { BI.createWidget({ type: "bi.absolute", element: this, - items: [{ - el: this.combo, - left: 0, - right: 0, - top: 0, - bottom: 0 - }, { - el: triggerBtn, - right: 0, - top: 0, - bottom: 0 - }, { - el: { - type: "bi.vertical_adapt", - items: [this.numberCounter] - }, - right: o.height, - top: 0, - height: o.height - }] + items: [ + { + el: this.combo, + left: 0, + right: 0, + top: 0, + bottom: 0 + }, { + el: triggerBtn, + right: 0, + top: 0, + bottom: 0 + }, { + el: { + type: "bi.vertical_adapt", + items: [this.numberCounter] + }, + right: o.height, + top: 0, + height: o.height + } + ] }); }, diff --git a/src/widget/multiselect/multiselect.insert.trigger.js b/src/widget/multiselect/multiselect.insert.trigger.js index b04aebd07..4ed1b19ef 100644 --- a/src/widget/multiselect/multiselect.insert.trigger.js +++ b/src/widget/multiselect/multiselect.insert.trigger.js @@ -40,6 +40,7 @@ BI.MultiSelectInsertTrigger = BI.inherit(BI.Trigger, { defaultText: o.defaultText, itemsCreator: o.itemsCreator, valueFormatter: o.valueFormatter, + itemFormatter: o.itemFormatter, itemHeight: o.itemHeight, watermark: o.watermark, popup: {}, @@ -86,24 +87,27 @@ BI.MultiSelectInsertTrigger = BI.inherit(BI.Trigger, { }, { el: BI.createWidget(), width: 24 - }] + } + ] }); !o.allowEdit && BI.createWidget({ type: "bi.absolute", element: this, - items: [{ - el: { - type: "bi.text", - title: function () { - return self.searcher.getState(); - } - }, - left: 0, - right: 24, - top: 0, - bottom: 0 - }] + items: [ + { + el: { + type: "bi.text", + title: function () { + return self.searcher.getState(); + } + }, + left: 0, + right: 24, + top: 0, + bottom: 0 + } + ] }); }, diff --git a/src/widget/multiselect/multiselect.trigger.js b/src/widget/multiselect/multiselect.trigger.js index 937e83804..f8f95c02b 100644 --- a/src/widget/multiselect/multiselect.trigger.js +++ b/src/widget/multiselect/multiselect.trigger.js @@ -41,6 +41,7 @@ BI.MultiSelectTrigger = BI.inherit(BI.Trigger, { itemsCreator: o.itemsCreator, itemHeight: o.itemHeight, valueFormatter: o.valueFormatter, + itemFormatter: o.itemFormatter, watermark: o.watermark, popup: {}, adapter: o.adapter, @@ -88,23 +89,25 @@ BI.MultiSelectTrigger = BI.inherit(BI.Trigger, { !o.allowEdit && BI.createWidget({ type: "bi.absolute", element: this, - items: [{ - el: { - type: "bi.text", - title: function () { - /** 修正REPORT-73699引入,需要考虑到传递过来的值是方法的情况 */ - var state = self.searcher.getState(); - if (BI.isFunction(state)) { - return state(); + items: [ + { + el: { + type: "bi.text", + title: function () { + /** 修正REPORT-73699引入,需要考虑到传递过来的值是方法的情况 */ + var state = self.searcher.getState(); + if (BI.isFunction(state)) { + return state(); + } + return state; } - return state; - } - }, - left: 0, - right: 24, - top: 0, - bottom: 0 - }] + }, + left: 0, + right: 24, + top: 0, + bottom: 0 + } + ] }); }, diff --git a/src/widget/multiselect/search/multiselect.search.loader.js b/src/widget/multiselect/search/multiselect.search.loader.js index 89e4cb318..5f6d09f54 100644 --- a/src/widget/multiselect/search/multiselect.search.loader.js +++ b/src/widget/multiselect/search/multiselect.search.loader.js @@ -51,9 +51,11 @@ BI.MultiSelectSearchLoader = BI.inherit(BI.Widget, { return true; } }, - layouts: [{ - type: "bi.vertical" - }] + layouts: [ + { + type: "bi.vertical" + } + ] } } }, @@ -92,15 +94,21 @@ BI.MultiSelectSearchLoader = BI.inherit(BI.Widget, { _createItems: function (items) { var allSelected = this.isAllSelected(); - return BI.createItems(items, { - type: "bi.multi_select_item", - logic: { - dynamic: false - }, - height: this.options.itemHeight || BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, - selected: allSelected, - cls: "bi-list-item-active", - iconWrapperWidth: 36 + var itemFormatter = this.options.itemFormatter; + + return BI.map(items, (index, item) => { + return { + type: "bi.multi_select_item", + logic: { + dynamic: false + }, + height: this.options.itemHeight || BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, + selected: allSelected, + cls: "bi-list-item-active", + iconWrapperWidth: 36, + ...item, + ...itemFormatter(item) + }; }); }, diff --git a/src/widget/multiselect/trigger/searcher.multiselect.insert.js b/src/widget/multiselect/trigger/searcher.multiselect.insert.js index bf77db1e7..ec31d3d31 100644 --- a/src/widget/multiselect/trigger/searcher.multiselect.insert.js +++ b/src/widget/multiselect/trigger/searcher.multiselect.insert.js @@ -29,17 +29,19 @@ BI.MultiSelectInsertSearcher = BI.inherit(BI.Widget, { height: o.height, text: o.text, defaultText: o.defaultText, - listeners: [{ - eventName: BI.MultiSelectEditor.EVENT_FOCUS, - action: function () { - self.fireEvent(BI.MultiSelectInsertSearcher.EVENT_FOCUS); - } - }, { - eventName: BI.MultiSelectEditor.EVENT_BLUR, - action: function () { - self.fireEvent(BI.MultiSelectInsertSearcher.EVENT_BLUR); + listeners: [ + { + eventName: BI.MultiSelectEditor.EVENT_FOCUS, + action: function () { + self.fireEvent(BI.MultiSelectInsertSearcher.EVENT_FOCUS); + } + }, { + eventName: BI.MultiSelectEditor.EVENT_BLUR, + action: function () { + self.fireEvent(BI.MultiSelectInsertSearcher.EVENT_BLUR); + } } - }] + ] }); this.searcher = BI.createWidget({ @@ -56,6 +58,7 @@ BI.MultiSelectInsertSearcher = BI.inherit(BI.Widget, { popup: BI.extend({ type: "bi.multi_select_search_insert_pane", valueFormatter: o.valueFormatter, + itemFormatter: o.itemFormatter, keywordGetter: function () { return self.editor.getKeyword(); }, diff --git a/src/widget/multiselect/trigger/searcher.multiselect.js b/src/widget/multiselect/trigger/searcher.multiselect.js index 5744cd1de..e7ed00874 100644 --- a/src/widget/multiselect/trigger/searcher.multiselect.js +++ b/src/widget/multiselect/trigger/searcher.multiselect.js @@ -29,17 +29,19 @@ BI.MultiSelectSearcher = BI.inherit(BI.Widget, { text: o.text, defaultText: o.defaultText, watermark: o.watermark, - listeners: [{ - eventName: BI.MultiSelectEditor.EVENT_FOCUS, - action: function () { - self.fireEvent(BI.MultiSelectSearcher.EVENT_FOCUS); - } - }, { - eventName: BI.MultiSelectEditor.EVENT_BLUR, - action: function () { - self.fireEvent(BI.MultiSelectSearcher.EVENT_BLUR); + listeners: [ + { + eventName: BI.MultiSelectEditor.EVENT_FOCUS, + action: function () { + self.fireEvent(BI.MultiSelectSearcher.EVENT_FOCUS); + } + }, { + eventName: BI.MultiSelectEditor.EVENT_BLUR, + action: function () { + self.fireEvent(BI.MultiSelectSearcher.EVENT_BLUR); + } } - }] + ] }); this.searcher = BI.createWidget({ @@ -55,6 +57,7 @@ BI.MultiSelectSearcher = BI.inherit(BI.Widget, { popup: BI.extend({ type: "bi.multi_select_search_pane", valueFormatter: o.valueFormatter, + itemFormatter: o.itemFormatter, keywordGetter: function () { return self.editor.getValue(); },