Browse Source

无JIRA feat: text_value_combo多选功能完善

es6
zsmj 2 years ago
parent
commit
2f91a2c93f
  1. 26
      demo/js/case/combo/demo.text_value_combo.js
  2. 3
      src/case/combo/textvaluecombo/combo.textvalue.js
  3. 26
      src/case/trigger/trigger.text.select.js

26
demo/js/case/combo/demo.text_value_combo.js

@ -146,7 +146,7 @@ Demo.TextValueCombo = BI.inherit(BI.Widget, {
type: "bi.button", type: "bi.button",
text: "setValue(1)", text: "setValue(1)",
handler: function () { handler: function () {
combo1.setValue(); combo1.setValue(1);
}, },
}, },
vgap: 10, vgap: 10,
@ -184,6 +184,30 @@ Demo.TextValueCombo = BI.inherit(BI.Widget, {
vgap: 10, vgap: 10,
} }
] ]
}),
this.createCombo("支持复选", {
type: "bi.vertical",
items: [
{
type: "bi.text_value_combo",
ref: function () {
combo2 = this;
},
width: 300,
items: items,
allowClear: true,
defaultText: "请选择",
chooseType: BI.Selection.Multi,
listeners: [
{
eventName: BI.TextValueCombo.EVENT_CHANGE,
action: function () {
console.log(this.getValue());
}
}
]
}
]
}) })
] ]
}; };

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

@ -100,7 +100,7 @@ BI.TextValueCombo = BI.inherit(BI.Widget, {
eventName: BI.TextValueComboPopup.EVENT_CLEAR, eventName: BI.TextValueComboPopup.EVENT_CLEAR,
action: (...args) => { action: (...args) => {
changeTag = true; changeTag = true;
this.setValue([]); this._clear();
this.combo.hideView(); this.combo.hideView();
} }
}, { }, {
@ -151,6 +151,7 @@ BI.TextValueCombo = BI.inherit(BI.Widget, {
}, },
_clear: function () { _clear: function () {
this.trigger.setText("");
this.combo.setValue(); this.combo.setValue();
this.setStatus("success"); this.setStatus("success");
}, },

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

@ -20,15 +20,14 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, {
_init: function () { _init: function () {
BI.SelectTextTrigger.superclass._init.apply(this, arguments); BI.SelectTextTrigger.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
var obj = this._digest(o.value, o.items); var text = this._digest(o.value, o.items);
this.trigger = BI.createWidget({ this.trigger = BI.createWidget({
type: "bi.text_trigger", type: "bi.text_trigger",
element: this, element: this,
height: o.height, height: o.height,
readonly: o.readonly, readonly: o.readonly,
text: obj.text, text: text,
defaultText: o.defaultText, defaultText: o.defaultText,
textCls: obj.textCls,
textHgap: o.textHgap, textHgap: o.textHgap,
textVgap: o.textVgap, textVgap: o.textVgap,
textLgap: o.textLgap, textLgap: o.textLgap,
@ -73,21 +72,9 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, {
}); });
if (result.length > 0 && val.length === 0) { if (result.length > 0 && val.length === 0) {
return { return result.join(",");
textCls: "",
text: result.join(","),
};
} else { } else {
var text = BI.isFunction(o.text) ? o.text() : o.text; return BI.isFunction(o.text) ? o.text() : o.text;
if (BI.isEmptyString(text)) {
return {
textCls: "bi-tips",
text: ""
};
}
return {
text,
};
} }
}, },
@ -97,9 +84,8 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, {
}, },
setValue: function (val) { setValue: function (val) {
var formatValue = this._digest(val, this.options.items); var formatText = this._digest(val, this.options.items);
this.trigger.setTextCls(formatValue.textCls); this.trigger.setText(formatText);
this.trigger.setText(formatValue.text);
}, },
setTipType: function (v) { setTipType: function (v) {

Loading…
Cancel
Save