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,
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
}
]
});
},

90
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,
}
]
});
},

87
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
}
]
});
},

30
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
}
]
});
},

35
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
}
]
});
},

32
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)
};
});
},

23
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();
},

23
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();
},

Loading…
Cancel
Save