Browse Source

单选下拉框支持多选

es6
guy 2 years ago
parent
commit
1b1832c843
  1. 23
      src/case/combo/textvaluecombo/combo.textvalue.js
  2. 2
      src/case/combo/textvaluecombo/popup.textvalue.js
  3. 4
      src/case/trigger/trigger.text.select.js

23
src/case/combo/textvaluecombo/combo.textvalue.js

@ -72,6 +72,7 @@ BI.TextValueCombo = BI.inherit(BI.Widget, {
} }
], ],
}; };
let changeTag = false;
const popup = { const popup = {
type: "bi.text_value_combo_popup", type: "bi.text_value_combo_popup",
ref: ref => this.popup = ref, ref: ref => this.popup = ref,
@ -81,9 +82,12 @@ BI.TextValueCombo = BI.inherit(BI.Widget, {
{ {
eventName: BI.TextValueComboPopup.EVENT_CHANGE, eventName: BI.TextValueComboPopup.EVENT_CHANGE,
action: (...args) => { action: (...args) => {
changeTag = true;
this.setValue(this.popup.getValue()); this.setValue(this.popup.getValue());
this.combo.hideView(); if (o.chooseType === BI.ButtonGroup.CHOOSE_TYPE_SINGLE) {
this.fireEvent(BI.TextValueCombo.EVENT_CHANGE, ...args); this.combo.hideView();
this.fireEvent(BI.TextValueCombo.EVENT_CHANGE, ...args);
}
} }
}, { }, {
eventName: BI.Controller.EVENT_CHANGE, eventName: BI.Controller.EVENT_CHANGE,
@ -101,6 +105,21 @@ BI.TextValueCombo = BI.inherit(BI.Widget, {
direction: o.direction, direction: o.direction,
adjustLength: 2, adjustLength: 2,
el: trigger, el: trigger,
listeners: [
{
eventName: BI.Combo.EVENT_BEFORE_POPUPVIEW,
action: (...args) => {
changeTag = false;
}
}, {
eventName: BI.Combo.EVENT_AFTER_HIDEVIEW,
action: (...args) => {
if (changeTag) {
this.fireEvent(BI.TextValueCombo.EVENT_CHANGE, ...args);
}
}
}
],
popup: { popup: {
el: popup, el: popup,
value: o.value, value: o.value,

2
src/case/combo/textvaluecombo/popup.textvalue.js

@ -39,7 +39,7 @@ BI.TextValueComboPopup = BI.inherit(BI.Pane, {
var o = this.options; var o = this.options;
return BI.map(items, function (i, item) { return BI.map(items, function (i, item) {
return BI.extend({ return BI.extend({
type: "bi.single_select_item", type: o.chooseType === BI.ButtonGroup.CHOOSE_TYPE_SINGLE ? "bi.single_select_item" : "bi.multi_select_item",
textAlign: o.textAlign, textAlign: o.textAlign,
title: item.title || item.text title: item.title || item.text
}, item); }, item);

4
src/case/trigger/trigger.text.select.js

@ -52,7 +52,7 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, {
_digest: function (val, items) { _digest: function (val, items) {
var o = this.options; var o = this.options;
val = BI.isArray(val) ? val[0] : val; val = BI.isArray(val) ? val : [val];
// 提升valueFormatter的优先级 // 提升valueFormatter的优先级
if (o.valueFormatter !== BI.emptyFn && BI.isFunction(o.valueFormatter)) { if (o.valueFormatter !== BI.emptyFn && BI.isFunction(o.valueFormatter)) {
@ -65,7 +65,7 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, {
var formatItems = BI.Tree.transformToArrayFormat(items); var formatItems = BI.Tree.transformToArrayFormat(items);
BI.each(formatItems, function (i, item) { BI.each(formatItems, function (i, item) {
if (val === item.value && !BI.contains(result, item.text || item.value)) { if (BI.contains(val, item.value) && !BI.contains(result, item.text || item.value)) {
result.push(item.text || item.value); result.push(item.text || item.value);
} }
}); });

Loading…
Cancel
Save