Browse Source

Merge branch 'master' of ssh://code.fineres.com:7999/~teller/fineui

es6
iapyang 2 years ago
parent
commit
8e55df2191
  1. 144
      demo/js/base/button/demo.button.js
  2. 71
      demo/js/case/combo/demo.text_value_combo.js
  3. 2
      package.json
  4. 24
      src/base/single/button/buttons/button.js
  5. 122
      src/case/combo/textvaluecombo/combo.textvalue.js
  6. 2
      src/case/trigger/trigger.text.select.js
  7. 24
      src/less/base/combo/combo.textvalue.less
  8. 2
      src/widget/multiselect/multiselect.combo.js
  9. 11
      src/widget/multiselect/multiselect.loader.js
  10. 8
      src/widget/multiselect/multiselect.loader.nobar.js
  11. 1
      src/widget/multiselect/multiselect.popup.view.js
  12. 1
      src/widget/multiselect/multiselect.popup.view.nobar.js
  13. 2
      src/widget/multiselect/search/multiselect.search.loader.js

144
demo/js/base/button/demo.button.js

@ -1,6 +1,29 @@
(function () {
var JokerIcon = BI.inherit(BI.Widget, {
render: function () {
var self = this;
return {
type: "bi.label",
cls: "anim-rotate",
ref: function(ref) {
self.text = ref;
},
};
},
loading: function () {
this.text.setText("🤡");
},
loaded: function () {
this.text.setText("");
},
});
BI.shortcut("demo.joker.icon", JokerIcon);
}());
Demo.Button = BI.inherit(BI.Widget, { Demo.Button = BI.inherit(BI.Widget, {
props: { props: {
baseCls: "demo-button" baseCls: "demo-button",
}, },
render: function () { render: function () {
var items = [{ var items = [{
@ -16,187 +39,187 @@ Demo.Button = BI.inherit(BI.Widget, {
setTimeout(() => { setTimeout(() => {
this.loaded(); this.loaded();
}, 5 * 1000); }, 5 * 1000);
} },
}, { }, {
type: "bi.button", type: "bi.button",
text: "表示成功状态按钮", text: "表示成功状态按钮",
level: "success", level: "success",
height: 30 height: 30,
}, { }, {
type: "bi.button", type: "bi.button",
text: "表示警告状态的按钮", text: "表示警告状态的按钮",
level: "warning", level: "warning",
height: 30 height: 30,
}, { }, {
type: "bi.button", type: "bi.button",
text: "表示错误状态的按钮", text: "表示错误状态的按钮",
level: "error", level: "error",
height: 30 height: 30,
}, { }, {
type: "bi.button", type: "bi.button",
text: "表示忽略状态的按钮", text: "表示忽略状态的按钮",
level: "ignore", level: "ignore",
height: 30 height: 30,
}, { }, {
type: "bi.button", type: "bi.button",
text: "普通灰化按钮", text: "普通灰化按钮",
disabled: true, disabled: true,
level: "success", level: "success",
height: 30 height: 30,
}, { }, {
type: "bi.button", type: "bi.button",
text: "忽略状态灰化按钮", text: "忽略状态灰化按钮",
disabled: true, disabled: true,
level: "ignore", level: "ignore",
height: 30 height: 30,
}, { }, {
type: "bi.button", type: "bi.button",
text: "带图标的按钮", text: "带图标的按钮",
// level: 'ignore', // level: 'ignore',
iconCls: "close-font", iconCls: "close-font",
height: 30 height: 30,
}, { }, {
type: "bi.button", type: "bi.button",
text: "一般按钮", text: "一般按钮",
block: true, block: true,
level: "common", level: "common",
height: 30 height: 30,
}, { }, {
type: "bi.button", type: "bi.button",
text: "表示成功状态按钮", text: "表示成功状态按钮",
block: true, block: true,
level: "success", level: "success",
height: 30 height: 30,
}, { }, {
type: "bi.button", type: "bi.button",
text: "表示警告状态的按钮", text: "表示警告状态的按钮",
block: true, block: true,
level: "warning", level: "warning",
height: 30 height: 30,
}, { }, {
type: "bi.button", type: "bi.button",
text: "表示忽略状态的按钮", text: "表示忽略状态的按钮",
block: true, block: true,
level: "ignore", level: "ignore",
height: 30 height: 30,
}, { }, {
type: "bi.button", type: "bi.button",
text: "普通灰化按钮", text: "普通灰化按钮",
block: true, block: true,
disabled: true, disabled: true,
level: "success", level: "success",
height: 30 height: 30,
}, { }, {
type: "bi.button", type: "bi.button",
text: "忽略状态灰化按钮", text: "忽略状态灰化按钮",
block: true, block: true,
disabled: true, disabled: true,
level: "ignore", level: "ignore",
height: 30 height: 30,
}, { }, {
type: "bi.button", type: "bi.button",
text: "带图标的按钮", text: "带图标的按钮",
block: true, block: true,
// level: 'ignore', // level: 'ignore',
iconCls: "close-font", iconCls: "close-font",
height: 30 height: 30,
}, { }, {
type: "bi.button", type: "bi.button",
text: "一般按钮", text: "一般按钮",
clear: true, clear: true,
level: "common", level: "common",
height: 30 height: 30,
}, { }, {
type: "bi.button", type: "bi.button",
text: "表示成功状态按钮", text: "表示成功状态按钮",
clear: true, clear: true,
level: "success", level: "success",
height: 30 height: 30,
}, { }, {
type: "bi.button", type: "bi.button",
text: "表示警告状态的按钮", text: "表示警告状态的按钮",
clear: true, clear: true,
level: "warning", level: "warning",
height: 30 height: 30,
}, { }, {
type: "bi.button", type: "bi.button",
text: "表示忽略状态的按钮", text: "表示忽略状态的按钮",
clear: true, clear: true,
level: "ignore", level: "ignore",
height: 30 height: 30,
}, { }, {
type: "bi.button", type: "bi.button",
text: "普通灰化按钮", text: "普通灰化按钮",
clear: true, clear: true,
disabled: true, disabled: true,
level: "success", level: "success",
height: 30 height: 30,
}, { }, {
type: "bi.button", type: "bi.button",
text: "忽略状态灰化按钮", text: "忽略状态灰化按钮",
clear: true, clear: true,
disabled: true, disabled: true,
level: "ignore", level: "ignore",
height: 30 height: 30,
}, { }, {
type: "bi.button", type: "bi.button",
text: "带图标的按钮", text: "带图标的按钮",
clear: true, clear: true,
// level: 'ignore', // level: 'ignore',
iconCls: "close-font", iconCls: "close-font",
height: 30 height: 30,
}, { }, {
type: "bi.text_button", type: "bi.text_button",
text: "文字按钮", text: "文字按钮",
height: 30 height: 30,
}, { }, {
type: "bi.button", type: "bi.button",
text: "幽灵按钮(common)", text: "幽灵按钮(common)",
ghost: true, ghost: true,
height: 30 height: 30,
}, { }, {
type: "bi.button", type: "bi.button",
iconCls: "plus-font", iconCls: "plus-font",
text: "幽灵按钮(common)", text: "幽灵按钮(common)",
ghost: true, ghost: true,
height: 30 height: 30,
}, { }, {
type: "bi.button", type: "bi.button",
iconCls: "plus-font", iconCls: "plus-font",
text: "幽灵按钮(common)", text: "幽灵按钮(common)",
ghost: true, ghost: true,
level: "warning", level: "warning",
height: 30 height: 30,
}, { }, {
type: "bi.button", type: "bi.button",
iconCls: "plus-font", iconCls: "plus-font",
text: "幽灵按钮(common)", text: "幽灵按钮(common)",
ghost: true, ghost: true,
level: "error", level: "error",
height: 30 height: 30,
}, { }, {
type: "bi.button", type: "bi.button",
iconCls: "plus-font", iconCls: "plus-font",
text: "幽灵按钮(common)", text: "幽灵按钮(common)",
ghost: true, ghost: true,
level: "success", level: "success",
height: 30 height: 30,
}, { }, {
type: "bi.button", type: "bi.button",
text: "幽灵按钮(common)灰化", text: "幽灵按钮(common)灰化",
disabled: true, disabled: true,
ghost: true, ghost: true,
height: 30 height: 30,
}, { }, {
type: "bi.button", type: "bi.button",
text: "弹出bubble", text: "弹出bubble",
bubble: function () { bubble: function () {
return BI.parseInt(Math.random() * 100) % 10 + "提示" return BI.parseInt(Math.random() * 100) % 10 + "提示";
}, },
handler: function () { handler: function () {
BI.Msg.toast("1111"); BI.Msg.toast("1111");
}, },
height: 30 height: 30,
}, { }, {
type: "bi.button", type: "bi.button",
text: "自动撑开", text: "自动撑开",
@ -206,76 +229,76 @@ Demo.Button = BI.inherit(BI.Widget, {
iconGap: 64, iconGap: 64,
vgap: 16, vgap: 16,
hgap: 100, hgap: 100,
iconPosition: "bottom" iconPosition: "bottom",
}, { }, {
type: "bi.button", type: "bi.button",
text: "图标在下面的按钮", text: "图标在下面的按钮",
iconCls: "close-font", iconCls: "close-font",
iconPosition: "bottom" iconPosition: "bottom",
}, { }, {
type: "bi.button", type: "bi.button",
text: "图标在左边的按钮", text: "图标在左边的按钮",
iconCls: "close-font", iconCls: "close-font",
iconPosition: "left" iconPosition: "left",
}, { }, {
type: "bi.button", type: "bi.button",
text: "图标在右边的按钮", text: "图标在右边的按钮",
iconCls: "close-font", iconCls: "close-font",
iconPosition: "right" iconPosition: "right",
}, { }, {
type: "bi.button", type: "bi.button",
text: "浅色的一般按钮", text: "浅色的一般按钮",
iconCls: "plus-font", iconCls: "plus-font",
light: true light: true,
}, { }, {
type: "bi.button", type: "bi.button",
text: "浅色的成功按钮", text: "浅色的成功按钮",
level: "success", level: "success",
iconCls: "plus-font", iconCls: "plus-font",
light: true light: true,
}, { }, {
type: "bi.button", type: "bi.button",
text: "浅色的警告按钮", text: "浅色的警告按钮",
level: "warning", level: "warning",
iconCls: "plus-font", iconCls: "plus-font",
light: true light: true,
}, { }, {
type: "bi.button", type: "bi.button",
iconCls: "plus-font", iconCls: "plus-font",
text: "浅色的失败按钮", text: "浅色的失败按钮",
level: "error", level: "error",
cls: "hover-mask", cls: "hover-mask",
light: true light: true,
}, { }, {
type: "bi.button", type: "bi.button",
iconCls: "plus-font", iconCls: "plus-font",
text: "朴素的按钮", text: "朴素的按钮",
level: "common", level: "common",
plain: true plain: true,
}, { }, {
type: "bi.button", type: "bi.button",
iconCls: "plus-font", iconCls: "plus-font",
text: "朴素的按钮", text: "朴素的按钮",
level: "success", level: "success",
plain: true plain: true,
}, { }, {
type: "bi.button", type: "bi.button",
iconCls: "plus-font", iconCls: "plus-font",
text: "朴素的按钮", text: "朴素的按钮",
level: "error", level: "error",
plain: true plain: true,
}, { }, {
type: "bi.button", type: "bi.button",
iconCls: "plus-font", iconCls: "plus-font",
text: "朴素的按钮", text: "朴素的按钮",
level: "warning", level: "warning",
plain: true plain: true,
}, { }, {
type: "bi.button", type: "bi.button",
iconCls: "plus-font", iconCls: "plus-font",
text: "朴素的按钮", text: "朴素的按钮",
level: "ignore", level: "ignore",
plain: true plain: true,
}, { }, {
type: "bi.button", type: "bi.button",
iconCls: "plus-font", iconCls: "plus-font",
@ -286,7 +309,7 @@ Demo.Button = BI.inherit(BI.Widget, {
iconCls: "plus-font", iconCls: "plus-font",
text: "朴素的按钮", text: "朴素的按钮",
plain: true, plain: true,
disabled: true disabled: true,
}, { }, {
type: "bi.button", type: "bi.button",
iconCls: "plus-font", iconCls: "plus-font",
@ -299,7 +322,7 @@ Demo.Button = BI.inherit(BI.Widget, {
} }
this.setIcon(arr[this.i]); this.setIcon(arr[this.i]);
}, },
height: 24 height: 24,
}, { }, {
type: "bi.button", type: "bi.button",
text: "带加载的按钮", text: "带加载的按钮",
@ -309,7 +332,7 @@ Demo.Button = BI.inherit(BI.Widget, {
setTimeout(() => { setTimeout(() => {
this.loaded(); this.loaded();
}, 5 * 1000); }, 5 * 1000);
} },
}, { }, {
type: "bi.button", type: "bi.button",
text: "带加载的按钮", text: "带加载的按钮",
@ -320,7 +343,7 @@ Demo.Button = BI.inherit(BI.Widget, {
setTimeout(() => { setTimeout(() => {
this.loaded(); this.loaded();
}, 5 * 1000); }, 5 * 1000);
} },
}, { }, {
type: "bi.button", type: "bi.button",
clear: true, clear: true,
@ -332,14 +355,27 @@ Demo.Button = BI.inherit(BI.Widget, {
setTimeout(() => { setTimeout(() => {
this.loaded(); this.loaded();
}, 5 * 1000); }, 5 * 1000);
} },
}, { }, {
type: "bi.button", type: "bi.button",
text: "加载中的按钮", text: "加载中的按钮",
loading: true, loading: true,
handler() { handler() {
console.log("我是无法被触发的!"); console.log("我是无法被触发的!");
} },
}, {
type: "bi.button",
text: "自定义图标按钮(点我修改)",
icon: {
type: "demo.joker.icon",
},
handler() {
console.log("触发点击事件");
this.loading();
setTimeout(() => {
this.loaded();
}, 5 * 1000);
},
}]; }];
return { return {
@ -349,10 +385,10 @@ Demo.Button = BI.inherit(BI.Widget, {
hgap: 20, hgap: 20,
items: BI.map(items, function (index, value) { items: BI.map(items, function (index, value) {
return { return {
el: value el: value,
}; };
}) }),
}; };
} },
}); });
BI.shortcut("demo.button", Demo.Button); BI.shortcut("demo.button", Demo.Button);

71
demo/js/case/combo/demo.text_value_combo.js

@ -6,7 +6,7 @@ Demo.TextValueCombo = BI.inherit(BI.Widget, {
baseCls: "" baseCls: ""
}, },
render: function () { render: function () {
var combo, wrapper; var combo1, combo2;
var items = [{ var items = [{
text: "MVC-1", text: "MVC-1",
@ -30,8 +30,8 @@ Demo.TextValueCombo = BI.inherit(BI.Widget, {
items: [ items: [
this.createCombo("无初始值,带提示文字", { this.createCombo("无初始值,带提示文字", {
type: "bi.text_value_combo", type: "bi.text_value_combo",
ref: function () { ref: (ref) => {
combo = this; this.combo1 = ref;
}, },
defaultText: "请选择", defaultText: "请选择",
width: 300, width: 300,
@ -100,16 +100,18 @@ Demo.TextValueCombo = BI.inherit(BI.Widget, {
} }
] ]
}), }),
this.createCombo("有初始值,value不匹配,自动标红,可以清空", { this.createCombo("有初始值,value不匹配,自动标红,指定标红文字", {
type: "bi.text_value_combo", type: "bi.text_value_combo",
ref: function () { ref: function () {
combo = this; combo = this;
}, },
defaultText: "请选择",
width: 300, width: 300,
text: "MVC-111",
value: 111, value: 111,
items: items, items: items,
allowClear: true, allowClear: true,
defaultText: "请选择",
warningTitle: "value值不合法",
listeners: [ listeners: [
{ {
eventName: BI.TextValueCombo.EVENT_CHANGE, eventName: BI.TextValueCombo.EVENT_CHANGE,
@ -119,17 +121,18 @@ Demo.TextValueCombo = BI.inherit(BI.Widget, {
} }
] ]
}), }),
this.createCombo("有初始值,value不匹配,自动标红,指定标红文字", { this.createCombo("无初始值,外部受控调用setValue", {
type: "bi.vertical",
items: [
{
type: "bi.text_value_combo", type: "bi.text_value_combo",
ref: function () { ref: function () {
combo = this; combo1 = this;
}, },
width: 300, width: 300,
text: "MVC-111",
value: 111,
items: items, items: items,
allowClear: true, allowClear: true,
defaultText: "df", defaultText: "请选择",
listeners: [ listeners: [
{ {
eventName: BI.TextValueCombo.EVENT_CHANGE, eventName: BI.TextValueCombo.EVENT_CHANGE,
@ -138,6 +141,49 @@ Demo.TextValueCombo = BI.inherit(BI.Widget, {
} }
} }
] ]
}, {
el: {
type: "bi.button",
text: "setValue(1)",
handler: function () {
combo1.setValue();
},
},
vgap: 10,
}
]
}),
this.createCombo("无初始值,外部受控调用setStatus", {
type: "bi.vertical",
items: [
{
type: "bi.text_value_combo",
ref: function () {
combo2 = this;
},
width: 300,
items: items,
allowClear: true,
defaultText: "请选择",
listeners: [
{
eventName: BI.TextValueCombo.EVENT_CHANGE,
action: function () {
console.log(this.getValue());
}
}
]
}, {
el: {
type: "bi.button",
text: "setStatus()",
handler: function () {
combo2.setStatus("error");
},
},
vgap: 10,
}
]
}) })
] ]
}; };
@ -155,8 +201,9 @@ Demo.TextValueCombo = BI.inherit(BI.Widget, {
}, },
bgap: 10 bgap: 10
}, { }, {
el: combo el: combo,
} bgap: 10,
},
] ]
}; };
} }

2
package.json

@ -1,6 +1,6 @@
{ {
"name": "fineui", "name": "fineui",
"version": "2.0.20220816172514", "version": "2.0.20220819140607",
"description": "fineui", "description": "fineui",
"main": "dist/fineui_without_conflict.min.js", "main": "dist/fineui_without_conflict.min.js",
"types": "dist/lib/index.d.ts", "types": "dist/lib/index.d.ts",

24
src/base/single/button/buttons/button.js

@ -62,6 +62,7 @@
bgap: 0, bgap: 0,
lgap: 0, lgap: 0,
rgap: 0, rgap: 0,
icon: "",
iconGap: 0, iconGap: 0,
iconPosition: "left", iconPosition: "left",
}); });
@ -89,10 +90,13 @@
} }
} }
var iconInvisible = !o.loading && !o.iconCls; var iconInvisible = !o.loading && !o.iconCls && !o.icon;
if (BI.isPlainObject(o.icon) && !o.loading) {
this.icon = BI.createWidget(o.icon);
} else {
this.icon = BI.createWidget({ this.icon = BI.createWidget({
type: "bi.icon_label", type: "bi.icon_label",
cls: o.loading ? loadingCls : o.iconCls, cls: o.loading ? loadingCls : (o.iconCls || o.icon),
width: this._const.iconWidth, width: this._const.iconWidth,
height: lineHeight, height: lineHeight,
lineHeight: lineHeight, lineHeight: lineHeight,
@ -101,6 +105,8 @@
iconHeight: o.iconHeight, iconHeight: o.iconHeight,
invisible: iconInvisible, invisible: iconInvisible,
}); });
}
// 用于 whiteSpace // 用于 whiteSpace
var textWidth = iconInvisible && o.width ? o.width - o.hgap * 2 : null; var textWidth = iconInvisible && o.width ? o.width - o.hgap * 2 : null;
if (BI.isNotNull(o.textWidth)) { if (BI.isNotNull(o.textWidth)) {
@ -179,23 +185,31 @@
return this.isLoading(); return this.isLoading();
}, },
isLoading() { isLoading: function () {
return this._loading === undefined ? this.options.loading : this._loading; return this._loading === undefined ? this.options.loading : this._loading;
}, },
loading: function (loading) { loading: function () {
this._loading = true; this._loading = true;
this.element.addClass("loading"); this.element.addClass("loading");
if (this.icon.loading) {
this.icon.loading();
} else {
// loadingCls 可以覆盖 iconCls 所以不需要移除 iconCls // loadingCls 可以覆盖 iconCls 所以不需要移除 iconCls
this.icon.element.addClass(loadingCls); this.icon.element.addClass(loadingCls);
this.icon.setVisible(true); this.icon.setVisible(true);
}
}, },
loaded() { loaded: function () {
this._loading = false; this._loading = false;
this.element.removeClass("loading"); this.element.removeClass("loading");
if (this.icon.loaded) {
this.icon.loaded();
} else {
this.icon.element.removeClass(loadingCls); this.icon.element.removeClass(loadingCls);
this.icon.setVisible(!!this.options.iconCls); this.icon.setVisible(!!this.options.iconCls);
}
}, },
setText: function (text) { setText: function (text) {

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

@ -14,6 +14,7 @@ BI.TextValueCombo = BI.inherit(BI.Widget, {
value: "", value: "",
defaultText: "", defaultText: "",
allowClear: false, allowClear: false,
status: "success", // success | warning | error
}); });
}, },
@ -28,98 +29,137 @@ BI.TextValueCombo = BI.inherit(BI.Widget, {
self.populate(newValue); self.populate(newValue);
}) : o.items; }) : o.items;
BI.TextValueCombo.superclass._init.apply(this, arguments); BI.TextValueCombo.superclass._init.apply(this, arguments);
this.trigger = BI.createWidget({ },
render: function () {
const o = this.options;
const trigger = {
type: "bi.select_text_trigger", type: "bi.select_text_trigger",
ref: ref => this.trigger = ref,
cls: "text-value-trigger", cls: "text-value-trigger",
items: o.items, items: o.items,
height: o.height, height: o.height,
text: o.text, text: o.text,
value: o.value, value: o.value,
warningTitle: o.warningTitle, title: () => {
if (this.options.status === "error") {
return {
level: "warning",
text: o.warningTitle,
};
}
return {
level: "success",
};
},
allowClear: o.allowClear, allowClear: o.allowClear,
defaultText: o.defaultText, defaultText: o.defaultText,
listeners: [ listeners: [
{ {
eventName: BI.SelectTextTrigger.EVENT_CLEAR, eventName: BI.SelectTextTrigger.EVENT_CLEAR,
action: function () { action: () => {
self._clear(); this._clear();
self.fireEvent(BI.TextValueCombo.EVENT_CHANGE); this.fireEvent(BI.TextValueCombo.EVENT_CHANGE);
} }
} }
], ],
}); };
this.popup = BI.createWidget({ const popup = {
type: "bi.text_value_combo_popup", type: "bi.text_value_combo_popup",
ref: ref => this.popup = ref,
chooseType: o.chooseType, chooseType: o.chooseType,
value: o.value, value: o.value,
items: o.items items: o.items,
}); listeners: [
this.popup.on(BI.TextValueComboPopup.EVENT_CHANGE, function () { {
self.setValue(self.popup.getValue()); eventName: BI.TextValueComboPopup.EVENT_CHANGE,
self.textIconCombo.hideView(); action: (...args) => {
self.fireEvent(BI.TextValueCombo.EVENT_CHANGE, arguments); this.setValue(this.popup.getValue());
}); this.combo.hideView();
this.popup.on(BI.Controller.EVENT_CHANGE, function () { this.fireEvent(BI.TextValueCombo.EVENT_CHANGE, ...args);
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); }
}); }, {
this.textIconCombo = BI.createWidget({ eventName: BI.Controller.EVENT_CHANGE,
action: (...args) => {
this.fireEvent(BI.Controller.EVENT_CHANGE, ...args);
}
}
]
};
return {
type: "bi.combo", type: "bi.combo",
ref: ref => this.combo = ref,
container: o.container, container: o.container,
direction: o.direction, direction: o.direction,
element: this,
adjustLength: 2, adjustLength: 2,
el: this.trigger, el: trigger,
popup: { popup: {
el: this.popup, el: popup,
value: o.value,
maxHeight: 240, maxHeight: 240,
minHeight: 25 minHeight: 25
} }
}); };
},
mounted: function () {
const o = this.options;
if (BI.isKey(o.value)) { if (BI.isKey(o.value)) {
this._checkError(o.value); this._checkError(o.value);
} }
}, },
_clear: function () { _clear: function () {
this.trigger.setValue(); this.combo.setValue();
this.popup.setValue(); this.setStatus("success");
this.element.removeClass("error");
this.trigger.element.removeClass("error");
}, },
_checkError: function (v) { _checkError: function (v) {
v = BI.isArray(v) ? v[0] : v;
var tipType = null; if (BI.isNull(v)) {
this.setStatus("success");
return;
}
var vals = BI.isArray(v) ? v : [v];
var result = BI.find(this.options.items, function (idx, item) { var result = BI.find(this.options.items, function (idx, item) {
return v === item.value; return BI.contains(vals, item.value);
}); });
if (BI.isNull(result)) { if (BI.isNull(result)) {
if (this.isEnabled()) { this.setStatus("error");
tipType = "warning";
}
this.element.addClass("error");
this.trigger.element.addClass("error");
} else { } else {
this.element.removeClass("error"); this.setStatus("success");
this.trigger.element.removeClass("error");
} }
this.trigger.setTipType(tipType); },
clear: function () {
this._clear();
}, },
setValue: function (v) { setValue: function (v) {
this.trigger.setValue(v); this.combo.setValue(v);
this.popup.setValue(v);
this._checkError(v); this._checkError(v);
}, },
setStatus: function (status) {
this.element.removeClass(`bi-status-${this.options.status}`);
this.element.addClass(`bi-status-${status}`);
this.options.status = status;
},
getValue: function () { getValue: function () {
var value = this.popup.getValue(); var value = this.combo.getValue();
return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]);
}, },
populate: function (items) { populate: function (items) {
this.options.items = items; this.options.items = items;
this.textIconCombo.populate(items); this.combo.populate(items);
} }
}); });
BI.TextValueCombo.EVENT_CHANGE = "EVENT_CHANGE"; BI.TextValueCombo.EVENT_CHANGE = "EVENT_CHANGE";

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

@ -36,7 +36,7 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, {
textTgap: o.textTgap, textTgap: o.textTgap,
textBgap: o.textBgap, textBgap: o.textBgap,
tipType: o.tipType, tipType: o.tipType,
warningTitle: o.warningTitle, title: null,
allowClear: o.allowClear, allowClear: o.allowClear,
listeners: [ listeners: [
{ {

24
src/less/base/combo/combo.textvalue.less

@ -0,0 +1,24 @@
@import "../../index.less";
.bi-text-value-combo {
//将来统一变成combo的特性
&.bi-status-error {
&.bi-border, &.bi-border-bottom {
border-color: @border-color-negative;
}
.bi-trigger .select-text-label {
color: @color-bi-text-error-text-trigger;
}
}
&.bi-status-warning {
&.bi-border, &.bi-border-bottom {
border-color: @border-color-warning;
}
.bi-trigger .select-text-label {
color: @font-color-warning;
}
}
}

2
src/widget/multiselect/multiselect.combo.js

@ -57,6 +57,7 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, {
}, },
}, },
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
itemFormatter: o.itemFormatter,
itemsCreator: BI.bind(this._itemsCreator4Trigger, this), itemsCreator: BI.bind(this._itemsCreator4Trigger, this),
itemHeight: o.itemHeight, itemHeight: o.itemHeight,
value: this.storeValue, value: this.storeValue,
@ -162,6 +163,7 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, {
itemsCreator: o.itemsCreator, itemsCreator: o.itemsCreator,
itemHeight: o.itemHeight, itemHeight: o.itemHeight,
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
itemFormatter: o.itemFormatter,
onLoaded: function () { onLoaded: function () {
BI.nextTick(function () { BI.nextTick(function () {
self.combo.adjustWidth(); self.combo.adjustWidth();

11
src/widget/multiselect/multiselect.loader.js

@ -64,7 +64,6 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, {
value: v, value: v,
title: txt, title: txt,
selected: self.storeValue.type === BI.Selection.Multi, selected: self.storeValue.type === BI.Selection.Multi,
...opts.itemFormatter(v),
}; };
}); });
if (BI.isKey(self._startValue) && !BI.contains(self.storeValue.value, self._startValue)) { if (BI.isKey(self._startValue) && !BI.contains(self.storeValue.value, self._startValue)) {
@ -74,7 +73,6 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, {
value: startValue, value: startValue,
title: txt, title: txt,
selected: true, selected: true,
...opts.itemFormatter(startValue),
}); });
} }
firstItems = self._createItems(json); firstItems = self._createItems(json);
@ -111,13 +109,18 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, {
_createItems: function (items) { _createItems: function (items) {
var allSelected = this.isAllSelected(); var allSelected = this.isAllSelected();
return BI.createItems(items, { var itemFormatter = this.options.itemFormatter;
return BI.map(items, (i, item) => {
return {
type: "bi.multi_select_item", type: "bi.multi_select_item",
logic: this.options.logic, logic: this.options.logic,
cls: "bi-list-item-active", cls: "bi-list-item-active",
height: this.options.itemHeight || BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, height: this.options.itemHeight || BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
selected: allSelected, selected: allSelected,
iconWrapperWidth: 36 iconWrapperWidth: 36,
...item,
...itemFormatter(item),
};
}); });
}, },

8
src/widget/multiselect/multiselect.loader.nobar.js

@ -113,12 +113,16 @@ BI.MultiSelectNoBarLoader = BI.inherit(BI.Widget, {
}, },
_createItems: function (items) { _createItems: function (items) {
return BI.createItems(items, { return BI.map(items, (index, item) => {
return {
type: "bi.multi_select_item", type: "bi.multi_select_item",
cls: "bi-list-item-active", cls: "bi-list-item-active",
logic: this.options.logic, logic: this.options.logic,
height: this.options.itemHeight || BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, height: this.options.itemHeight || BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
iconWrapperWidth: 36 iconWrapperWidth: 36,
...item,
...this.options.itemFormatter(item),
};
}); });
}, },

1
src/widget/multiselect/multiselect.popup.view.js

@ -27,6 +27,7 @@ BI.MultiSelectPopupView = BI.inherit(BI.Widget, {
itemsCreator: opts.itemsCreator, itemsCreator: opts.itemsCreator,
itemHeight: opts.itemHeight, itemHeight: opts.itemHeight,
valueFormatter: opts.valueFormatter, valueFormatter: opts.valueFormatter,
itemFormatter: opts.itemFormatter,
onLoaded: opts.onLoaded, onLoaded: opts.onLoaded,
value: opts.value value: opts.value
}); });

1
src/widget/multiselect/multiselect.popup.view.nobar.js

@ -27,6 +27,7 @@ BI.MultiSelectNoBarPopupView = BI.inherit(BI.Widget, {
itemsCreator: opts.itemsCreator, itemsCreator: opts.itemsCreator,
itemHeight: opts.itemHeight, itemHeight: opts.itemHeight,
valueFormatter: opts.valueFormatter, valueFormatter: opts.valueFormatter,
itemFormatter: opts.itemFormatter,
onLoaded: opts.onLoaded, onLoaded: opts.onLoaded,
value: opts.value value: opts.value
}); });

2
src/widget/multiselect/search/multiselect.search.loader.js

@ -128,7 +128,7 @@ BI.MultiSelectSearchLoader = BI.inherit(BI.Widget, {
title: v.text, title: v.text,
value: v.value, value: v.value,
selected: src.type === BI.Selection.All, selected: src.type === BI.Selection.All,
...o.itemFormatter(v.value), ...o.itemFormatter(v),
}; };
}); });
}, },

Loading…
Cancel
Save