From 8d94280ef2f1adc01668d1e0fe41de96e2954b3b Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Fri, 19 Jan 2018 11:03:07 +0800 Subject: [PATCH] =?UTF-8?q?value=E7=9A=84=E4=B8=80=E4=BA=9B=E5=B0=8F?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../combo/demo.text_value_down_list_combo.js | 9 ++++ .../case/combo/demo.text_vlaue_check_combo.js | 14 +++++- dist/bundle.js | 48 +++++++++++++------ dist/case.js | 24 ++++++---- dist/demo.js | 23 ++++++++- dist/fineui.js | 48 +++++++++++++------ dist/widget.js | 24 +++++++--- src/case/combo/iconcombo/combo.icon.js | 3 +- src/case/combo/iconcombo/trigger.iconcombo.js | 3 +- .../icontextvaluecombo/combo.icontextvalue.js | 6 ++- .../icontextvaluecombo/popup.icontextvalue.js | 3 +- src/case/combo/staticcombo/combo.static.js | 3 +- .../combo.textvaluecheck.js | 3 +- .../combo/textvaluecombo/combo.textvalue.js | 3 +- src/widget/downlist/popup.downlist.js | 24 +++++++--- 15 files changed, 178 insertions(+), 60 deletions(-) diff --git a/demo/js/case/combo/demo.text_value_down_list_combo.js b/demo/js/case/combo/demo.text_value_down_list_combo.js index 51a8c1a4c..7368ead34 100644 --- a/demo/js/case/combo/demo.text_value_down_list_combo.js +++ b/demo/js/case/combo/demo.text_value_down_list_combo.js @@ -41,9 +41,18 @@ Demo.TextValueDownListCombo = BI.inherit(BI.Widget, { type: "bi.button", width: 90, height: 25, + text: "setValue", handler: function () { self.refs.setValue(2); } + }, { + type: "bi.button", + width: 90, + height: 25, + text: "getValue", + handler: function () { + BI.Msg.alert("", JSON.stringify(self.refs.getValue())); + } }], vgap: 20 }; diff --git a/demo/js/case/combo/demo.text_vlaue_check_combo.js b/demo/js/case/combo/demo.text_vlaue_check_combo.js index 0d017f80d..607a060c9 100644 --- a/demo/js/case/combo/demo.text_vlaue_check_combo.js +++ b/demo/js/case/combo/demo.text_vlaue_check_combo.js @@ -6,13 +6,16 @@ Demo.TextValueCheckCombo = BI.inherit(BI.Widget, { baseCls: "" }, render: function () { - + var self = this; return { type: "bi.horizontal_auto", items: [{ type: "bi.text_value_check_combo", + ref: function () { + self.combo = this; + }, text: "默认值", - value: 1, + //value: 1, width: 300, items: [{ text: "MVC-1", @@ -24,6 +27,13 @@ Demo.TextValueCheckCombo = BI.inherit(BI.Widget, { text: "MVC-3", value: 3 }] + }, { + type: "bi.button", + width: 90, + height: 25, + handler: function () { + BI.Msg.alert("", JSON.stringify(self.combo.getValue())); + } }], vgap: 20 }; diff --git a/dist/bundle.js b/dist/bundle.js index 58041d7f5..febdd979e 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -67585,7 +67585,8 @@ BI.IconCombo = BI.inherit(BI.Widget, { }, getValue: function () { - return this.iconCombo.getValue(); + var value = this.iconCombo.getValue(); + return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); }, populate: function (items) { @@ -67686,7 +67687,8 @@ BI.IconComboTrigger = BI.inherit(BI.Trigger, { } this.button = BI.createWidget(o.el, { type: "bi.icon_change_button", - cls: "icon-combo-trigger-icon " + iconCls, + cls: "icon-combo-trigger-icon", + iconCls: iconCls, disableSelected: true, width: o.width, height: o.height, @@ -67783,7 +67785,8 @@ BI.IconTextValueCombo = BI.inherit(BI.Widget, { }); this.popup = BI.createWidget({ type: "bi.icon_text_value_combo_popup", - items: o.items + items: o.items, + value: o.value }); this.popup.on(BI.IconTextValueComboPopup.EVENT_CHANGE, function () { self.setValue(self.popup.getValue()); @@ -67813,7 +67816,8 @@ BI.IconTextValueCombo = BI.inherit(BI.Widget, { }, getValue: function () { - return this.textIconCombo.getValue(); + var value = this.textIconCombo.getValue(); + return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); }, populate: function (items) { @@ -67844,7 +67848,8 @@ BI.IconTextValueComboPopup = BI.inherit(BI.Pane, { chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, layouts: [{ type: "bi.vertical" - }] + }], + value: o.value }); this.popup.on(BI.Controller.EVENT_CHANGE, function (type, val, obj) { @@ -67944,7 +67949,8 @@ BI.StaticCombo = BI.inherit(BI.Widget, { }, getValue: function () { - return this.combo.getValue(); + var value = this.combo.getValue(); + return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); } }); BI.StaticCombo.EVENT_CHANGE = "EVENT_CHANGE"; @@ -68017,7 +68023,8 @@ BI.TextValueCheckCombo = BI.inherit(BI.Widget, { }, getValue: function () { - return this.textIconCheckCombo.getValue(); + var value = this.textIconCheckCombo.getValue(); + return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); }, populate: function (items) { @@ -68210,7 +68217,8 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { }, getValue: function () { - return this.textIconCombo.getValue(); + var value = this.textIconCombo.getValue(); + return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); }, populate: function (items) { @@ -80391,23 +80399,35 @@ BI.DownListPopup = BI.inherit(BI.Pane, { }, _checkValues: function (values) { - var self = this; + var self = this, o = this.options; var value = []; - BI.each(this.options.items, function (idx, itemGroup) { + BI.each(o.items, function (idx, itemGroup) { BI.each(itemGroup, function (id, item) { if(BI.isNotNull(item.children)){ var childValues = BI.pluck(item.children, "value"); - if(BI.contains(childValues, values[idx])){ - value.push(values[idx]); + if(BI.contains(childValues, valueGetter(idx))){ + value.push(valueGetter(idx)); } }else{ - if(item.value === values[idx]){ - value.push(values[idx]); + if(item.value === valueGetter(idx)){ + value.push(valueGetter(idx)); } } }) }); return value; + + function valueGetter(index) { + switch (o.chooseType) { + case BI.Selection.Single: + return values[0]; + break; + case BI.Selection.Multi: + return values[index]; + default: + break; + } + } }, populate: function (items) { diff --git a/dist/case.js b/dist/case.js index 0c36f02d0..5b09100de 100644 --- a/dist/case.js +++ b/dist/case.js @@ -5291,7 +5291,8 @@ BI.IconCombo = BI.inherit(BI.Widget, { }, getValue: function () { - return this.iconCombo.getValue(); + var value = this.iconCombo.getValue(); + return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); }, populate: function (items) { @@ -5392,7 +5393,8 @@ BI.IconComboTrigger = BI.inherit(BI.Trigger, { } this.button = BI.createWidget(o.el, { type: "bi.icon_change_button", - cls: "icon-combo-trigger-icon " + iconCls, + cls: "icon-combo-trigger-icon", + iconCls: iconCls, disableSelected: true, width: o.width, height: o.height, @@ -5489,7 +5491,8 @@ BI.IconTextValueCombo = BI.inherit(BI.Widget, { }); this.popup = BI.createWidget({ type: "bi.icon_text_value_combo_popup", - items: o.items + items: o.items, + value: o.value }); this.popup.on(BI.IconTextValueComboPopup.EVENT_CHANGE, function () { self.setValue(self.popup.getValue()); @@ -5519,7 +5522,8 @@ BI.IconTextValueCombo = BI.inherit(BI.Widget, { }, getValue: function () { - return this.textIconCombo.getValue(); + var value = this.textIconCombo.getValue(); + return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); }, populate: function (items) { @@ -5550,7 +5554,8 @@ BI.IconTextValueComboPopup = BI.inherit(BI.Pane, { chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, layouts: [{ type: "bi.vertical" - }] + }], + value: o.value }); this.popup.on(BI.Controller.EVENT_CHANGE, function (type, val, obj) { @@ -5650,7 +5655,8 @@ BI.StaticCombo = BI.inherit(BI.Widget, { }, getValue: function () { - return this.combo.getValue(); + var value = this.combo.getValue(); + return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); } }); BI.StaticCombo.EVENT_CHANGE = "EVENT_CHANGE"; @@ -5723,7 +5729,8 @@ BI.TextValueCheckCombo = BI.inherit(BI.Widget, { }, getValue: function () { - return this.textIconCheckCombo.getValue(); + var value = this.textIconCheckCombo.getValue(); + return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); }, populate: function (items) { @@ -5916,7 +5923,8 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { }, getValue: function () { - return this.textIconCombo.getValue(); + var value = this.textIconCombo.getValue(); + return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); }, populate: function (items) { diff --git a/dist/demo.js b/dist/demo.js index 5c75e6a27..703f3292c 100644 --- a/dist/demo.js +++ b/dist/demo.js @@ -1997,9 +1997,18 @@ Demo.TextValueDownListCombo = BI.inherit(BI.Widget, { type: "bi.button", width: 90, height: 25, + text: "setValue", handler: function () { self.refs.setValue(2); } + }, { + type: "bi.button", + width: 90, + height: 25, + text: "getValue", + handler: function () { + BI.Msg.alert("", JSON.stringify(self.refs.getValue())); + } }], vgap: 20 }; @@ -2014,13 +2023,16 @@ Demo.TextValueCheckCombo = BI.inherit(BI.Widget, { baseCls: "" }, render: function () { - + var self = this; return { type: "bi.horizontal_auto", items: [{ type: "bi.text_value_check_combo", + ref: function () { + self.combo = this; + }, text: "默认值", - value: 1, + //value: 1, width: 300, items: [{ text: "MVC-1", @@ -2032,6 +2044,13 @@ Demo.TextValueCheckCombo = BI.inherit(BI.Widget, { text: "MVC-3", value: 3 }] + }, { + type: "bi.button", + width: 90, + height: 25, + handler: function () { + BI.Msg.alert("", JSON.stringify(self.combo.getValue())); + } }], vgap: 20 }; diff --git a/dist/fineui.js b/dist/fineui.js index 84fc13e89..e831391a3 100644 --- a/dist/fineui.js +++ b/dist/fineui.js @@ -69279,7 +69279,8 @@ BI.IconCombo = BI.inherit(BI.Widget, { }, getValue: function () { - return this.iconCombo.getValue(); + var value = this.iconCombo.getValue(); + return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); }, populate: function (items) { @@ -69380,7 +69381,8 @@ BI.IconComboTrigger = BI.inherit(BI.Trigger, { } this.button = BI.createWidget(o.el, { type: "bi.icon_change_button", - cls: "icon-combo-trigger-icon " + iconCls, + cls: "icon-combo-trigger-icon", + iconCls: iconCls, disableSelected: true, width: o.width, height: o.height, @@ -69477,7 +69479,8 @@ BI.IconTextValueCombo = BI.inherit(BI.Widget, { }); this.popup = BI.createWidget({ type: "bi.icon_text_value_combo_popup", - items: o.items + items: o.items, + value: o.value }); this.popup.on(BI.IconTextValueComboPopup.EVENT_CHANGE, function () { self.setValue(self.popup.getValue()); @@ -69507,7 +69510,8 @@ BI.IconTextValueCombo = BI.inherit(BI.Widget, { }, getValue: function () { - return this.textIconCombo.getValue(); + var value = this.textIconCombo.getValue(); + return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); }, populate: function (items) { @@ -69538,7 +69542,8 @@ BI.IconTextValueComboPopup = BI.inherit(BI.Pane, { chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, layouts: [{ type: "bi.vertical" - }] + }], + value: o.value }); this.popup.on(BI.Controller.EVENT_CHANGE, function (type, val, obj) { @@ -69638,7 +69643,8 @@ BI.StaticCombo = BI.inherit(BI.Widget, { }, getValue: function () { - return this.combo.getValue(); + var value = this.combo.getValue(); + return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); } }); BI.StaticCombo.EVENT_CHANGE = "EVENT_CHANGE"; @@ -69711,7 +69717,8 @@ BI.TextValueCheckCombo = BI.inherit(BI.Widget, { }, getValue: function () { - return this.textIconCheckCombo.getValue(); + var value = this.textIconCheckCombo.getValue(); + return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); }, populate: function (items) { @@ -69904,7 +69911,8 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { }, getValue: function () { - return this.textIconCombo.getValue(); + var value = this.textIconCombo.getValue(); + return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); }, populate: function (items) { @@ -82085,23 +82093,35 @@ BI.DownListPopup = BI.inherit(BI.Pane, { }, _checkValues: function (values) { - var self = this; + var self = this, o = this.options; var value = []; - BI.each(this.options.items, function (idx, itemGroup) { + BI.each(o.items, function (idx, itemGroup) { BI.each(itemGroup, function (id, item) { if(BI.isNotNull(item.children)){ var childValues = BI.pluck(item.children, "value"); - if(BI.contains(childValues, values[idx])){ - value.push(values[idx]); + if(BI.contains(childValues, valueGetter(idx))){ + value.push(valueGetter(idx)); } }else{ - if(item.value === values[idx]){ - value.push(values[idx]); + if(item.value === valueGetter(idx)){ + value.push(valueGetter(idx)); } } }) }); return value; + + function valueGetter(index) { + switch (o.chooseType) { + case BI.Selection.Single: + return values[0]; + break; + case BI.Selection.Multi: + return values[index]; + default: + break; + } + } }, populate: function (items) { diff --git a/dist/widget.js b/dist/widget.js index 34b5989da..532308592 100644 --- a/dist/widget.js +++ b/dist/widget.js @@ -3977,23 +3977,35 @@ BI.DownListPopup = BI.inherit(BI.Pane, { }, _checkValues: function (values) { - var self = this; + var self = this, o = this.options; var value = []; - BI.each(this.options.items, function (idx, itemGroup) { + BI.each(o.items, function (idx, itemGroup) { BI.each(itemGroup, function (id, item) { if(BI.isNotNull(item.children)){ var childValues = BI.pluck(item.children, "value"); - if(BI.contains(childValues, values[idx])){ - value.push(values[idx]); + if(BI.contains(childValues, valueGetter(idx))){ + value.push(valueGetter(idx)); } }else{ - if(item.value === values[idx]){ - value.push(values[idx]); + if(item.value === valueGetter(idx)){ + value.push(valueGetter(idx)); } } }) }); return value; + + function valueGetter(index) { + switch (o.chooseType) { + case BI.Selection.Single: + return values[0]; + break; + case BI.Selection.Multi: + return values[index]; + default: + break; + } + } }, populate: function (items) { diff --git a/src/case/combo/iconcombo/combo.icon.js b/src/case/combo/iconcombo/combo.icon.js index 39799527f..cea1e89b9 100644 --- a/src/case/combo/iconcombo/combo.icon.js +++ b/src/case/combo/iconcombo/combo.icon.js @@ -85,7 +85,8 @@ BI.IconCombo = BI.inherit(BI.Widget, { }, getValue: function () { - return this.iconCombo.getValue(); + var value = this.iconCombo.getValue(); + return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); }, populate: function (items) { diff --git a/src/case/combo/iconcombo/trigger.iconcombo.js b/src/case/combo/iconcombo/trigger.iconcombo.js index 0f3f7d635..71c3bbb86 100644 --- a/src/case/combo/iconcombo/trigger.iconcombo.js +++ b/src/case/combo/iconcombo/trigger.iconcombo.js @@ -27,7 +27,8 @@ BI.IconComboTrigger = BI.inherit(BI.Trigger, { } this.button = BI.createWidget(o.el, { type: "bi.icon_change_button", - cls: "icon-combo-trigger-icon " + iconCls, + cls: "icon-combo-trigger-icon", + iconCls: iconCls, disableSelected: true, width: o.width, height: o.height, diff --git a/src/case/combo/icontextvaluecombo/combo.icontextvalue.js b/src/case/combo/icontextvaluecombo/combo.icontextvalue.js index ecf4be7ca..2b317ed38 100644 --- a/src/case/combo/icontextvaluecombo/combo.icontextvalue.js +++ b/src/case/combo/icontextvaluecombo/combo.icontextvalue.js @@ -24,7 +24,8 @@ BI.IconTextValueCombo = BI.inherit(BI.Widget, { }); this.popup = BI.createWidget({ type: "bi.icon_text_value_combo_popup", - items: o.items + items: o.items, + value: o.value }); this.popup.on(BI.IconTextValueComboPopup.EVENT_CHANGE, function () { self.setValue(self.popup.getValue()); @@ -54,7 +55,8 @@ BI.IconTextValueCombo = BI.inherit(BI.Widget, { }, getValue: function () { - return this.textIconCombo.getValue(); + var value = this.textIconCombo.getValue(); + return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); }, populate: function (items) { diff --git a/src/case/combo/icontextvaluecombo/popup.icontextvalue.js b/src/case/combo/icontextvaluecombo/popup.icontextvalue.js index 2f1c30537..f9a6b6507 100644 --- a/src/case/combo/icontextvaluecombo/popup.icontextvalue.js +++ b/src/case/combo/icontextvaluecombo/popup.icontextvalue.js @@ -20,7 +20,8 @@ BI.IconTextValueComboPopup = BI.inherit(BI.Pane, { chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, layouts: [{ type: "bi.vertical" - }] + }], + value: o.value }); this.popup.on(BI.Controller.EVENT_CHANGE, function (type, val, obj) { diff --git a/src/case/combo/staticcombo/combo.static.js b/src/case/combo/staticcombo/combo.static.js index 95d350514..e7599b71c 100644 --- a/src/case/combo/staticcombo/combo.static.js +++ b/src/case/combo/staticcombo/combo.static.js @@ -62,7 +62,8 @@ BI.StaticCombo = BI.inherit(BI.Widget, { }, getValue: function () { - return this.combo.getValue(); + var value = this.combo.getValue(); + return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); } }); BI.StaticCombo.EVENT_CHANGE = "EVENT_CHANGE"; diff --git a/src/case/combo/textvaluecheckcombo/combo.textvaluecheck.js b/src/case/combo/textvaluecheckcombo/combo.textvaluecheck.js index 7550fda40..be1434eaa 100644 --- a/src/case/combo/textvaluecheckcombo/combo.textvaluecheck.js +++ b/src/case/combo/textvaluecheckcombo/combo.textvaluecheck.js @@ -67,7 +67,8 @@ BI.TextValueCheckCombo = BI.inherit(BI.Widget, { }, getValue: function () { - return this.textIconCheckCombo.getValue(); + var value = this.textIconCheckCombo.getValue(); + return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); }, populate: function (items) { diff --git a/src/case/combo/textvaluecombo/combo.textvalue.js b/src/case/combo/textvaluecombo/combo.textvalue.js index 947009087..812a7fda6 100644 --- a/src/case/combo/textvaluecombo/combo.textvalue.js +++ b/src/case/combo/textvaluecombo/combo.textvalue.js @@ -57,7 +57,8 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { }, getValue: function () { - return this.textIconCombo.getValue(); + var value = this.textIconCombo.getValue(); + return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); }, populate: function (items) { diff --git a/src/widget/downlist/popup.downlist.js b/src/widget/downlist/popup.downlist.js index e0d984e57..4bacae9b9 100644 --- a/src/widget/downlist/popup.downlist.js +++ b/src/widget/downlist/popup.downlist.js @@ -194,23 +194,35 @@ BI.DownListPopup = BI.inherit(BI.Pane, { }, _checkValues: function (values) { - var self = this; + var self = this, o = this.options; var value = []; - BI.each(this.options.items, function (idx, itemGroup) { + BI.each(o.items, function (idx, itemGroup) { BI.each(itemGroup, function (id, item) { if(BI.isNotNull(item.children)){ var childValues = BI.pluck(item.children, "value"); - if(BI.contains(childValues, values[idx])){ - value.push(values[idx]); + if(BI.contains(childValues, valueGetter(idx))){ + value.push(valueGetter(idx)); } }else{ - if(item.value === values[idx]){ - value.push(values[idx]); + if(item.value === valueGetter(idx)){ + value.push(valueGetter(idx)); } } }) }); return value; + + function valueGetter(index) { + switch (o.chooseType) { + case BI.Selection.Single: + return values[0]; + break; + case BI.Selection.Multi: + return values[index]; + default: + break; + } + } }, populate: function (items) {