Browse Source

Merge pull request #179138 in DEC/fineui from master to feature/x

* commit 'e732d87b1ab0d9d7c621ba21d0db5ac145ef3e5f':
  无JIRA feat: text_value_combo多选功能完善
  无JIRA feat: text_value_combo多选功能完善
  无JIRA feat: text_value_combo多选功能完善
research/test
superman 2 years ago
parent
commit
679e65598f
  1. 23
      demo/js/case/combo/demo.text_value_combo.js
  2. 15
      src/case/combo/textvaluecombo/combo.textvalue.js
  3. 26
      src/case/trigger/trigger.text.select.js

23
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,27 @@ Demo.TextValueCombo = BI.inherit(BI.Widget, {
vgap: 10, vgap: 10,
} }
] ]
}),
this.createCombo("支持复选", {
type: "bi.vertical",
items: [
{
type: "bi.text_value_combo",
width: 300,
items: items,
allowClear: true,
defaultText: "请选择",
chooseType: BI.Selection.Multi,
listeners: [
{
eventName: BI.TextValueCombo.EVENT_CHANGE,
action: function () {
console.log(this.getValue());
}
}
]
}
]
}) })
] ]
}; };

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

@ -85,11 +85,15 @@ BI.TextValueCombo = BI.inherit(BI.Widget, {
eventName: BI.TextValueComboPopup.EVENT_CHANGE, eventName: BI.TextValueComboPopup.EVENT_CHANGE,
action: (...args) => { action: (...args) => {
changeTag = true; changeTag = true;
this.setValue(this.popup.getValue()); const value = this.popup.getValue();
this.setValue(value);
if (o.chooseType === BI.ButtonGroup.CHOOSE_TYPE_SINGLE) { if (o.chooseType === BI.ButtonGroup.CHOOSE_TYPE_SINGLE) {
this.combo.hideView(...args); this.combo.hideView(...args);
this.fireEvent(BI.TextValueCombo.EVENT_CHANGE, ...args); this.fireEvent(BI.TextValueCombo.EVENT_CHANGE, ...args);
} }
if (o.chooseType === BI.ButtonGroup.CHOOSE_TYPE_MULTI && BI.isEmptyArray(value)) {
this._clear();
}
} }
}, { }, {
eventName: BI.Controller.EVENT_CHANGE, eventName: BI.Controller.EVENT_CHANGE,
@ -100,7 +104,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 +155,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");
}, },
@ -164,7 +169,7 @@ BI.TextValueCombo = BI.inherit(BI.Widget, {
var vals = BI.isArray(v) ? v : [v]; var vals = BI.isArray(v) ? v : [v];
var result = BI.intersection(BI.map(this.options.items, (i, item) => item.value), vals); var result = BI.intersection(BI.map(this.options.items, "value"), vals);
if (result.length !== vals.length) { if (result.length !== vals.length) {
this.setStatus("error"); this.setStatus("error");
@ -177,6 +182,10 @@ BI.TextValueCombo = BI.inherit(BI.Widget, {
this._clear(); this._clear();
}, },
setText: function (text) {
this.trigger.setText(text);
},
setValue: function (v) { setValue: function (v) {
this.combo.setValue(v); this.combo.setValue(v);
this._checkError(v); this._checkError(v);

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