Browse Source

Pull request #3236: KERNEL-13662 feat: text_value_combo 复选,支持不带全选 - from Richie

Merge in VISUAL/fineui from ~DAILER/fineui:master to master

* commit 'd42f8f7dc7ea33b64b44e6ee86edeaa690ead29a':
  KERNEL-13662 feat: text_value_combo 复选,支持不带全选 - from Richie
es6
Dailer-刘荣歆 2 years ago
parent
commit
d70b107ac4
  1. 8
      demo/js/case/combo/demo.text_value_combo.js
  2. 4
      src/case/combo/textvaluecombo/combo.textvalue.js
  3. 77
      src/case/combo/textvaluecombo/popup.textvalue.js

8
demo/js/case/combo/demo.text_value_combo.js

@ -8,7 +8,8 @@ Demo.TextValueCombo = BI.inherit(BI.Widget, {
render: function () { render: function () {
var combo1, combo2; var combo1, combo2;
var items = [{ var items = [
{
text: "MVC-1", text: "MVC-1",
iconCls: "date-font", iconCls: "date-font",
value: 1 value: 1
@ -20,7 +21,8 @@ Demo.TextValueCombo = BI.inherit(BI.Widget, {
text: "MVC-3", text: "MVC-3",
iconCls: "pull-right-font", iconCls: "pull-right-font",
value: 3 value: 3
}]; }
];
// 创建下拉框各种场景用例 // 创建下拉框各种场景用例
return { return {
@ -195,6 +197,8 @@ Demo.TextValueCombo = BI.inherit(BI.Widget, {
allowClear: true, allowClear: true,
defaultText: "请选择", defaultText: "请选择",
chooseType: BI.Selection.Multi, chooseType: BI.Selection.Multi,
value: [1],
// allowSelectAll: false,
listeners: [ listeners: [
{ {
eventName: BI.TextValueCombo.EVENT_CHANGE, eventName: BI.TextValueCombo.EVENT_CHANGE,

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

@ -16,7 +16,8 @@ BI.TextValueCombo = BI.inherit(BI.Widget, {
el: {}, el: {},
allowClear: false, allowClear: false,
status: "success", // success | warning | error, status: "success", // success | warning | error,
title: null title: null,
allowSelectAll: true,
}); });
}, },
@ -78,6 +79,7 @@ BI.TextValueCombo = BI.inherit(BI.Widget, {
ref: ref => this.popup = ref, ref: ref => this.popup = ref,
chooseType: o.chooseType, chooseType: o.chooseType,
items: o.items, items: o.items,
allowSelectAll: o.allowSelectAll,
listeners: [ listeners: [
{ {
eventName: BI.TextValueComboPopup.EVENT_CHANGE, eventName: BI.TextValueComboPopup.EVENT_CHANGE,

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

@ -2,7 +2,8 @@ BI.TextValueComboPopup = BI.inherit(BI.Pane, {
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend(BI.TextValueComboPopup.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.TextValueComboPopup.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-text-icon-popup", baseCls: "bi-text-icon-popup",
chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE,
allowSelectAll: true,
}); });
}, },
@ -12,18 +13,22 @@ BI.TextValueComboPopup = BI.inherit(BI.Pane, {
return { return {
type: "bi.vertical", type: "bi.vertical",
vgap: 5, vgap: 5,
items: [{ items: [
{
type: "bi.button_group", type: "bi.button_group",
ref: (_ref) => { ref: (_ref) => {
this.popup = _ref; this.popup = _ref;
}, },
items: this._formatItems(o.items), items: this._formatItems(o.items),
chooseType: o.chooseType, chooseType: o.chooseType,
layouts: [{ layouts: [
{
type: "bi.vertical" type: "bi.vertical"
}], }
],
value: o.value, value: o.value,
listeners: [{ listeners: [
{
eventName: BI.Controller.EVENT_CHANGE, eventName: BI.Controller.EVENT_CHANGE,
action: function (type, val, obj) { action: function (type, val, obj) {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
@ -31,15 +36,19 @@ BI.TextValueComboPopup = BI.inherit(BI.Pane, {
self.fireEvent(BI.TextValueComboPopup.EVENT_CHANGE, val, obj); self.fireEvent(BI.TextValueComboPopup.EVENT_CHANGE, val, obj);
} }
} }
}] }
}] ]
}
]
}; };
} }
return { return {
type: "bi.vertical", type: "bi.vertical",
verticalAlign: BI.VerticalAlign.Stretch, verticalAlign: BI.VerticalAlign.Stretch,
rowSize: ["fill", ""], rowSize: ["fill", ""],
items: [{ items: [
{
el: o.allowSelectAll ? {
type: "bi.select_list", type: "bi.select_list",
logic: { logic: {
dynamic: true, dynamic: true,
@ -52,7 +61,7 @@ BI.TextValueComboPopup = BI.inherit(BI.Pane, {
}, },
el: { el: {
el: { el: {
chooseType: o.chooseType chooseType: o.chooseType,
} }
}, },
items: this._formatItems(o.items), items: this._formatItems(o.items),
@ -60,17 +69,46 @@ BI.TextValueComboPopup = BI.inherit(BI.Pane, {
type: BI.ButtonGroup.CHOOSE_TYPE_MULTI, type: BI.ButtonGroup.CHOOSE_TYPE_MULTI,
value: o.value value: o.value
}, },
listeners: [{ listeners: [
{
eventName: BI.SelectList.EVENT_CHANGE, eventName: BI.SelectList.EVENT_CHANGE,
action: function (val) { action: function (val) {
self.fireEvent(BI.TextValueComboPopup.EVENT_CHANGE, val); self.fireEvent(BI.TextValueComboPopup.EVENT_CHANGE, val);
} }
}] }
}, { ]
} : {
type: "bi.list_pane",
logic: {
dynamic: true,
innerVgap: 5,
rowSize: ["", "fill"],
verticalAlign: BI.VerticalAlign.Stretch
},
ref: (_ref) => {
this.popup = _ref;
},
el: {
chooseType: o.chooseType,
},
items: this._formatItems(o.items),
value: o.value,
listeners: [
{
eventName: BI.ListPane.EVENT_CHANGE,
action: function (val) {
self.fireEvent(BI.TextValueComboPopup.EVENT_CHANGE, val);
}
}
]
}
},
{
type: "bi.center", type: "bi.center",
cls: "list-view-toolbar bi-high-light bi-split-top", cls: "list-view-toolbar bi-high-light bi-split-top",
height: 24, height: 24,
items: BI.createItems([{ items: BI.createItems([
{
type: "bi.text_button", type: "bi.text_button",
text: BI.i18nText("BI-Basic_Clears"), text: BI.i18nText("BI-Basic_Clears"),
handler: function () { handler: function () {
@ -82,12 +120,14 @@ BI.TextValueComboPopup = BI.inherit(BI.Pane, {
handler: function () { handler: function () {
self.fireEvent(BI.TextValueComboPopup.EVENT_CONFIRM); self.fireEvent(BI.TextValueComboPopup.EVENT_CONFIRM);
} }
}], { }
], {
once: false, once: false,
shadow: true, shadow: true,
isShadowShowingOnSelected: true isShadowShowingOnSelected: true
}) })
}] }
]
}; };
}, },
@ -117,6 +157,9 @@ BI.TextValueComboPopup = BI.inherit(BI.Pane, {
return this.popup.getValue(); return this.popup.getValue();
} }
var val = this.popup.getValue(); var val = this.popup.getValue();
if (!this.options.allowSelectAll) {
return val;
}
if (val.type === BI.ButtonGroup.CHOOSE_TYPE_MULTI) { if (val.type === BI.ButtonGroup.CHOOSE_TYPE_MULTI) {
return val.value; return val.value;
} else { } else {
@ -128,6 +171,10 @@ BI.TextValueComboPopup = BI.inherit(BI.Pane, {
if (this.options.chooseType !== BI.ButtonGroup.CHOOSE_TYPE_MULTI) { if (this.options.chooseType !== BI.ButtonGroup.CHOOSE_TYPE_MULTI) {
return this.popup.setValue(v); return this.popup.setValue(v);
} }
if (!this.options.allowSelectAll) {
this.popup.setValue(v);
return;
}
this.popup.setValue({ this.popup.setValue({
type: BI.ButtonGroup.CHOOSE_TYPE_MULTI, type: BI.ButtonGroup.CHOOSE_TYPE_MULTI,
value: v value: v

Loading…
Cancel
Save