Browse Source

BI-119658 feat: MultiSelectCombo支持搜索自定义itemFormatter

master
zsmj 2 years ago
parent
commit
a105c140ec
  1. 89
      src/widget/multiselect/multiselect.combo.nobar.js
  2. 90
      src/widget/multiselect/multiselect.insert.combo.js
  3. 87
      src/widget/multiselect/multiselect.insert.combo.nobar.js
  4. 30
      src/widget/multiselect/multiselect.insert.trigger.js
  5. 35
      src/widget/multiselect/multiselect.trigger.js
  6. 32
      src/widget/multiselect/search/multiselect.search.loader.js
  7. 23
      src/widget/multiselect/trigger/searcher.multiselect.insert.js
  8. 23
      src/widget/multiselect/trigger/searcher.multiselect.js

89
src/widget/multiselect/multiselect.combo.nobar.js

@ -54,6 +54,7 @@ BI.MultiSelectNoBarCombo = BI.inherit(BI.Single, {
}, },
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
itemsCreator: BI.bind(this._itemsCreator4Trigger, this), itemsCreator: BI.bind(this._itemsCreator4Trigger, this),
itemFormatter: o.itemFormatter,
itemHeight: o.itemHeight, itemHeight: o.itemHeight,
value: { value: {
type: BI.Selection.Multi, type: BI.Selection.Multi,
@ -134,29 +135,31 @@ BI.MultiSelectNoBarCombo = BI.inherit(BI.Single, {
self.trigger.setAdapter(this); self.trigger.setAdapter(this);
self.numberCounter.setAdapter(this); self.numberCounter.setAdapter(this);
}, },
listeners: [{ listeners: [
eventName: BI.MultiSelectPopupView.EVENT_CHANGE, {
action: function () { eventName: BI.MultiSelectPopupView.EVENT_CHANGE,
self._dataChange = true; action: function () {
self.storeValue = this.getValue(); self._dataChange = true;
self._adjust(function () { self.storeValue = this.getValue();
assertShowValue(); self._adjust(function () {
}); assertShowValue();
self.fireEvent(BI.MultiSelectNoBarCombo.EVENT_CLICK_ITEM); });
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, itemsCreator: o.itemsCreator,
itemHeight: o.itemHeight, itemHeight: o.itemHeight,
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
@ -262,26 +265,28 @@ BI.MultiSelectNoBarCombo = BI.inherit(BI.Single, {
BI.createWidget({ BI.createWidget({
type: "bi.absolute", type: "bi.absolute",
element: this, element: this,
items: [{ items: [
el: this.combo, {
left: 0, el: this.combo,
right: 0, left: 0,
top: 0, right: 0,
bottom: 0 top: 0,
}, { bottom: 0
el: triggerBtn, }, {
right: 0, el: triggerBtn,
top: 0, right: 0,
bottom: 0 top: 0,
}, { bottom: 0
el: { }, {
type: "bi.vertical_adapt", el: {
items: [this.numberCounter] type: "bi.vertical_adapt",
}, items: [this.numberCounter]
right: o.height, },
top: 0, right: o.height,
height: o.height top: 0,
}] height: o.height
}
]
}); });
}, },

90
src/widget/multiselect/multiselect.insert.combo.js

@ -55,6 +55,7 @@ BI.MultiSelectInsertCombo = BI.inherit(BI.Single, {
}, },
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
itemsCreator: BI.bind(this._itemsCreator4Trigger, this), itemsCreator: BI.bind(this._itemsCreator4Trigger, this),
itemFormatter: o.itemFormatter,
itemHeight: o.itemHeight, itemHeight: o.itemHeight,
value: this.storeValue, value: this.storeValue,
}); });
@ -138,31 +139,34 @@ BI.MultiSelectInsertCombo = BI.inherit(BI.Single, {
self.trigger.setAdapter(this); self.trigger.setAdapter(this);
self.numberCounter.setAdapter(this); self.numberCounter.setAdapter(this);
}, },
listeners: [{ listeners: [
eventName: BI.MultiSelectPopupView.EVENT_CHANGE, {
action: function () { eventName: BI.MultiSelectPopupView.EVENT_CHANGE,
self._dataChange = true; action: function () {
self.storeValue = this.getValue(); self._dataChange = true;
self._adjust(function () { self.storeValue = this.getValue();
assertShowValue(); self._adjust(function () {
}); assertShowValue();
self.fireEvent(BI.MultiSelectInsertCombo.EVENT_CLICK_ITEM); });
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, itemsCreator: o.itemsCreator,
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
itemFormatter: o.itemFormatter,
itemHeight: o.itemHeight, itemHeight: o.itemHeight,
onLoaded: function () { onLoaded: function () {
BI.nextTick(function () { BI.nextTick(function () {
@ -260,26 +264,28 @@ BI.MultiSelectInsertCombo = BI.inherit(BI.Single, {
BI.createWidget({ BI.createWidget({
type: "bi.absolute", type: "bi.absolute",
element: this, element: this,
items: [{ items: [
el: this.combo, {
left: 0, el: this.combo,
right: 0, left: 0,
top: 0, right: 0,
bottom: 0 top: 0,
}, { bottom: 0
el: triggerBtn, }, {
right: 0, el: triggerBtn,
top: 0, right: 0,
bottom: 0 top: 0,
}, { bottom: 0
el: { }, {
type: "bi.vertical_adapt", el: {
items: [this.numberCounter] type: "bi.vertical_adapt",
}, items: [this.numberCounter]
right: o.height, },
top: 0, right: o.height,
height: o.height, top: 0,
}] height: o.height,
}
]
}); });
}, },

87
src/widget/multiselect/multiselect.insert.combo.nobar.js

@ -54,6 +54,7 @@ BI.MultiSelectInsertNoBarCombo = BI.inherit(BI.Single, {
}, },
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
itemsCreator: BI.bind(this._itemsCreator4Trigger, this), itemsCreator: BI.bind(this._itemsCreator4Trigger, this),
itemFormatter: o.itemFormatter,
itemHeight: o.itemHeight, itemHeight: o.itemHeight,
value: { value: {
type: BI.Selection.Multi, type: BI.Selection.Multi,
@ -129,28 +130,30 @@ BI.MultiSelectInsertNoBarCombo = BI.inherit(BI.Single, {
self.trigger.setAdapter(this); self.trigger.setAdapter(this);
self.numberCounter.setAdapter(this); self.numberCounter.setAdapter(this);
}, },
listeners: [{ listeners: [
eventName: BI.MultiSelectPopupView.EVENT_CHANGE, {
action: function () { eventName: BI.MultiSelectPopupView.EVENT_CHANGE,
self._dataChange = true; action: function () {
self.storeValue = this.getValue(); self._dataChange = true;
self._adjust(function () { self.storeValue = this.getValue();
assertShowValue(); 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, itemsCreator: o.itemsCreator,
itemHeight: o.itemHeight, itemHeight: o.itemHeight,
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
@ -256,26 +259,28 @@ BI.MultiSelectInsertNoBarCombo = BI.inherit(BI.Single, {
BI.createWidget({ BI.createWidget({
type: "bi.absolute", type: "bi.absolute",
element: this, element: this,
items: [{ items: [
el: this.combo, {
left: 0, el: this.combo,
right: 0, left: 0,
top: 0, right: 0,
bottom: 0 top: 0,
}, { bottom: 0
el: triggerBtn, }, {
right: 0, el: triggerBtn,
top: 0, right: 0,
bottom: 0 top: 0,
}, { bottom: 0
el: { }, {
type: "bi.vertical_adapt", el: {
items: [this.numberCounter] type: "bi.vertical_adapt",
}, items: [this.numberCounter]
right: o.height, },
top: 0, right: o.height,
height: o.height top: 0,
}] height: o.height
}
]
}); });
}, },

30
src/widget/multiselect/multiselect.insert.trigger.js

@ -40,6 +40,7 @@ BI.MultiSelectInsertTrigger = BI.inherit(BI.Trigger, {
defaultText: o.defaultText, defaultText: o.defaultText,
itemsCreator: o.itemsCreator, itemsCreator: o.itemsCreator,
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
itemFormatter: o.itemFormatter,
itemHeight: o.itemHeight, itemHeight: o.itemHeight,
watermark: o.watermark, watermark: o.watermark,
popup: {}, popup: {},
@ -86,24 +87,27 @@ BI.MultiSelectInsertTrigger = BI.inherit(BI.Trigger, {
}, { }, {
el: BI.createWidget(), el: BI.createWidget(),
width: 24 width: 24
}] }
]
}); });
!o.allowEdit && BI.createWidget({ !o.allowEdit && BI.createWidget({
type: "bi.absolute", type: "bi.absolute",
element: this, element: this,
items: [{ items: [
el: { {
type: "bi.text", el: {
title: function () { type: "bi.text",
return self.searcher.getState(); title: function () {
} return self.searcher.getState();
}, }
left: 0, },
right: 24, left: 0,
top: 0, right: 24,
bottom: 0 top: 0,
}] bottom: 0
}
]
}); });
}, },

35
src/widget/multiselect/multiselect.trigger.js

@ -41,6 +41,7 @@ BI.MultiSelectTrigger = BI.inherit(BI.Trigger, {
itemsCreator: o.itemsCreator, itemsCreator: o.itemsCreator,
itemHeight: o.itemHeight, itemHeight: o.itemHeight,
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
itemFormatter: o.itemFormatter,
watermark: o.watermark, watermark: o.watermark,
popup: {}, popup: {},
adapter: o.adapter, adapter: o.adapter,
@ -88,23 +89,25 @@ BI.MultiSelectTrigger = BI.inherit(BI.Trigger, {
!o.allowEdit && BI.createWidget({ !o.allowEdit && BI.createWidget({
type: "bi.absolute", type: "bi.absolute",
element: this, element: this,
items: [{ items: [
el: { {
type: "bi.text", el: {
title: function () { type: "bi.text",
/** 修正REPORT-73699引入,需要考虑到传递过来的值是方法的情况 */ title: function () {
var state = self.searcher.getState(); /** 修正REPORT-73699引入,需要考虑到传递过来的值是方法的情况 */
if (BI.isFunction(state)) { var state = self.searcher.getState();
return state(); if (BI.isFunction(state)) {
return state();
}
return state;
} }
return state; },
} left: 0,
}, right: 24,
left: 0, top: 0,
right: 24, bottom: 0
top: 0, }
bottom: 0 ]
}]
}); });
}, },

32
src/widget/multiselect/search/multiselect.search.loader.js

@ -51,9 +51,11 @@ BI.MultiSelectSearchLoader = BI.inherit(BI.Widget, {
return true; return true;
} }
}, },
layouts: [{ layouts: [
type: "bi.vertical" {
}] type: "bi.vertical"
}
]
} }
} }
}, },
@ -92,15 +94,21 @@ BI.MultiSelectSearchLoader = BI.inherit(BI.Widget, {
_createItems: function (items) { _createItems: function (items) {
var allSelected = this.isAllSelected(); var allSelected = this.isAllSelected();
return BI.createItems(items, { var itemFormatter = this.options.itemFormatter;
type: "bi.multi_select_item",
logic: { return BI.map(items, (index, item) => {
dynamic: false return {
}, type: "bi.multi_select_item",
height: this.options.itemHeight || BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, logic: {
selected: allSelected, dynamic: false
cls: "bi-list-item-active", },
iconWrapperWidth: 36 height: this.options.itemHeight || BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
selected: allSelected,
cls: "bi-list-item-active",
iconWrapperWidth: 36,
...item,
...itemFormatter(item)
};
}); });
}, },

23
src/widget/multiselect/trigger/searcher.multiselect.insert.js

@ -29,17 +29,19 @@ BI.MultiSelectInsertSearcher = BI.inherit(BI.Widget, {
height: o.height, height: o.height,
text: o.text, text: o.text,
defaultText: o.defaultText, defaultText: o.defaultText,
listeners: [{ listeners: [
eventName: BI.MultiSelectEditor.EVENT_FOCUS, {
action: function () { eventName: BI.MultiSelectEditor.EVENT_FOCUS,
self.fireEvent(BI.MultiSelectInsertSearcher.EVENT_FOCUS); action: function () {
} self.fireEvent(BI.MultiSelectInsertSearcher.EVENT_FOCUS);
}, { }
eventName: BI.MultiSelectEditor.EVENT_BLUR, }, {
action: function () { eventName: BI.MultiSelectEditor.EVENT_BLUR,
self.fireEvent(BI.MultiSelectInsertSearcher.EVENT_BLUR); action: function () {
self.fireEvent(BI.MultiSelectInsertSearcher.EVENT_BLUR);
}
} }
}] ]
}); });
this.searcher = BI.createWidget({ this.searcher = BI.createWidget({
@ -56,6 +58,7 @@ BI.MultiSelectInsertSearcher = BI.inherit(BI.Widget, {
popup: BI.extend({ popup: BI.extend({
type: "bi.multi_select_search_insert_pane", type: "bi.multi_select_search_insert_pane",
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
itemFormatter: o.itemFormatter,
keywordGetter: function () { keywordGetter: function () {
return self.editor.getKeyword(); return self.editor.getKeyword();
}, },

23
src/widget/multiselect/trigger/searcher.multiselect.js

@ -29,17 +29,19 @@ BI.MultiSelectSearcher = BI.inherit(BI.Widget, {
text: o.text, text: o.text,
defaultText: o.defaultText, defaultText: o.defaultText,
watermark: o.watermark, watermark: o.watermark,
listeners: [{ listeners: [
eventName: BI.MultiSelectEditor.EVENT_FOCUS, {
action: function () { eventName: BI.MultiSelectEditor.EVENT_FOCUS,
self.fireEvent(BI.MultiSelectSearcher.EVENT_FOCUS); action: function () {
} self.fireEvent(BI.MultiSelectSearcher.EVENT_FOCUS);
}, { }
eventName: BI.MultiSelectEditor.EVENT_BLUR, }, {
action: function () { eventName: BI.MultiSelectEditor.EVENT_BLUR,
self.fireEvent(BI.MultiSelectSearcher.EVENT_BLUR); action: function () {
self.fireEvent(BI.MultiSelectSearcher.EVENT_BLUR);
}
} }
}] ]
}); });
this.searcher = BI.createWidget({ this.searcher = BI.createWidget({
@ -55,6 +57,7 @@ BI.MultiSelectSearcher = BI.inherit(BI.Widget, {
popup: BI.extend({ popup: BI.extend({
type: "bi.multi_select_search_pane", type: "bi.multi_select_search_pane",
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
itemFormatter: o.itemFormatter,
keywordGetter: function () { keywordGetter: function () {
return self.editor.getValue(); return self.editor.getValue();
}, },

Loading…
Cancel
Save