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多选功能完善
master
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",
text: "setValue(1)",
handler: function () {
combo1.setValue();
combo1.setValue(1);
},
},
vgap: 10,
@ -184,6 +184,27 @@ Demo.TextValueCombo = BI.inherit(BI.Widget, {
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,
action: (...args) => {
changeTag = true;
this.setValue(this.popup.getValue());
const value = this.popup.getValue();
this.setValue(value);
if (o.chooseType === BI.ButtonGroup.CHOOSE_TYPE_SINGLE) {
this.combo.hideView(...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,
@ -100,7 +104,7 @@ BI.TextValueCombo = BI.inherit(BI.Widget, {
eventName: BI.TextValueComboPopup.EVENT_CLEAR,
action: (...args) => {
changeTag = true;
this.setValue([]);
this._clear();
this.combo.hideView();
}
}, {
@ -151,6 +155,7 @@ BI.TextValueCombo = BI.inherit(BI.Widget, {
},
_clear: function () {
this.trigger.setText("");
this.combo.setValue();
this.setStatus("success");
},
@ -164,7 +169,7 @@ BI.TextValueCombo = BI.inherit(BI.Widget, {
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) {
this.setStatus("error");
@ -177,6 +182,10 @@ BI.TextValueCombo = BI.inherit(BI.Widget, {
this._clear();
},
setText: function (text) {
this.trigger.setText(text);
},
setValue: function (v) {
this.combo.setValue(v);
this._checkError(v);

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

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

Loading…
Cancel
Save