diff --git a/demo/js/base/button/demo.button.js b/demo/js/base/button/demo.button.js index 32d8b86b4..e36544710 100644 --- a/demo/js/base/button/demo.button.js +++ b/demo/js/base/button/demo.button.js @@ -177,6 +177,28 @@ Demo.Button = BI.inherit(BI.Widget, { iconClass: "close-font", height: 30 } + }, { + el: { + type: "bi.multi_select_bar", + selected: true, + halfSelected: true + } + }, { + el: { + type: "bi.multi_select_bar", + selected: true, + halfSelected: false + } + }, { + el: { + type: "bi.multi_select_bar", + selected: false, + halfSelected: true + } + }, { + el: { + type: "bi.multi_select_bar" + } } ]; BI.each(items, function (i, item) { diff --git a/demo/js/base/editor/demo.editor.js b/demo/js/base/editor/demo.editor.js index 6ce05ef11..0cfba21cf 100644 --- a/demo/js/base/editor/demo.editor.js +++ b/demo/js/base/editor/demo.editor.js @@ -35,6 +35,7 @@ Demo.Editor = BI.inherit(BI.Widget, { cls: "mvc-border", watermark: "输入'a'会有错误信息且回车键不能退出编辑", errorText: "字段不可重名", + value: "a", validationChecker: function (v) { if (v == "a") { return false; diff --git a/demo/js/base/editor/demo.sql_editor.js b/demo/js/base/editor/demo.sql_editor.js index 8be6fdf80..5a708adb0 100644 --- a/demo/js/base/editor/demo.sql_editor.js +++ b/demo/js/base/editor/demo.sql_editor.js @@ -9,6 +9,7 @@ Demo.SQLEditor = BI.inherit(BI.Widget, { var self = this; this.formula = BI.createWidget({ type : 'bi.sql_editor', + supportParam: true, width : 300, height : 200, value : "select * from DEMO_CONTRACT where 合同类型 = ${长期协议} and 购买数量 = sum([1,2,3,4])" diff --git a/demo/js/case/combo/demo.icon_text_value_combo.js b/demo/js/case/combo/demo.icon_text_value_combo.js index ed8455e7a..594beaff8 100644 --- a/demo/js/case/combo/demo.icon_text_value_combo.js +++ b/demo/js/case/combo/demo.icon_text_value_combo.js @@ -11,7 +11,8 @@ Demo.IconTextValueCombo = BI.inherit(BI.Widget, { type: "bi.horizontal_auto", items: [{ type: "bi.icon_text_value_combo", - value: "默认值", + text: "默认值", + value: 1, width: 300, items: [{ text: "MVC-1", diff --git a/dist/base.js b/dist/base.js index ae7109dd5..c616285d2 100644 --- a/dist/base.js +++ b/dist/base.js @@ -1021,6 +1021,7 @@ BI.ButtonGroup = BI.inherit(BI.Widget, { baseCls: "bi-button-group", behaviors: {}, items: [], + value: "", chooseType: BI.Selection.Single, layouts: [{ type: "bi.center", @@ -1032,14 +1033,18 @@ BI.ButtonGroup = BI.inherit(BI.Widget, { _init: function () { BI.ButtonGroup.superclass._init.apply(this, arguments); + var o = this.options; var behaviors = {}; - BI.each(this.options.behaviors, function (key, rule) { + BI.each(o.behaviors, function (key, rule) { behaviors[key] = BI.BehaviorFactory.createBehavior(key, { rule: rule }); }); this.behaviors = behaviors; - this.populate(this.options.items); + this.populate(o.items); + if(BI.isKey(o.value) || BI.isNotEmptyArray(o.value)){ + this.setValue(o.value); + } }, _createBtns: function (items) { @@ -18071,6 +18076,7 @@ BI.Editor = BI.inherit(BI.Single, { type: "bi.input", element: "", root: true, + value: o.value, watermark: o.watermark, validationChecker: o.validationChecker, quitChecker: o.quitChecker, @@ -18213,7 +18219,8 @@ BI.Editor = BI.inherit(BI.Single, { return false; }); if (BI.isKey(this.options.value) || BI.isEmptyString(this.options.value)) { - this.setValue(this.options.value); + this._checkError(); + this._checkWaterMark(); } else { this._checkWaterMark(); } @@ -19417,6 +19424,9 @@ BI.Input = BI.inherit(BI.Single, { .focusout(function (e) { self._blurDebounce(); }); + if (BI.isKey(this.options.value) || BI.isEmptyString(this.options.value)) { + this.setValue(this.options.value); + } }, _focus: function () { @@ -21067,7 +21077,8 @@ BI.SQLEditor = BI.inherit(BI.Widget, { value: "", lineHeight: 2, showHint: true, - supportFunction: false + supportFunction: false, + supportParam: false }); }, _init: function () { @@ -21191,14 +21202,14 @@ BI.SQLEditor = BI.inherit(BI.Widget, { }, setValue: function (v) { - var self = this, result; + var self = this, result, o = this.options; this.refresh(); self.editor.setValue(""); result = this._analyzeContent(v || ""); BI.each(result, function (i, item) { var fieldRegx = /\$[\{][^\}]*[\}]/; var str = item.match(fieldRegx); - if (BI.isNotEmptyArray(str)) { + if (BI.isNotEmptyArray(str) && o.supportParam) { self.insertParam(str[0].substring(2, item.length - 1)); } else { self.insertString(item); diff --git a/dist/bundle.js b/dist/bundle.js index 789625210..a3e130c7d 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -26894,6 +26894,7 @@ BI.ButtonGroup = BI.inherit(BI.Widget, { baseCls: "bi-button-group", behaviors: {}, items: [], + value: "", chooseType: BI.Selection.Single, layouts: [{ type: "bi.center", @@ -26905,14 +26906,18 @@ BI.ButtonGroup = BI.inherit(BI.Widget, { _init: function () { BI.ButtonGroup.superclass._init.apply(this, arguments); + var o = this.options; var behaviors = {}; - BI.each(this.options.behaviors, function (key, rule) { + BI.each(o.behaviors, function (key, rule) { behaviors[key] = BI.BehaviorFactory.createBehavior(key, { rule: rule }); }); this.behaviors = behaviors; - this.populate(this.options.items); + this.populate(o.items); + if(BI.isKey(o.value) || BI.isNotEmptyArray(o.value)){ + this.setValue(o.value); + } }, _createBtns: function (items) { @@ -43944,6 +43949,7 @@ BI.Editor = BI.inherit(BI.Single, { type: "bi.input", element: "", root: true, + value: o.value, watermark: o.watermark, validationChecker: o.validationChecker, quitChecker: o.quitChecker, @@ -44086,7 +44092,8 @@ BI.Editor = BI.inherit(BI.Single, { return false; }); if (BI.isKey(this.options.value) || BI.isEmptyString(this.options.value)) { - this.setValue(this.options.value); + this._checkError(); + this._checkWaterMark(); } else { this._checkWaterMark(); } @@ -45290,6 +45297,9 @@ BI.Input = BI.inherit(BI.Single, { .focusout(function (e) { self._blurDebounce(); }); + if (BI.isKey(this.options.value) || BI.isEmptyString(this.options.value)) { + this.setValue(this.options.value); + } }, _focus: function () { @@ -46940,7 +46950,8 @@ BI.SQLEditor = BI.inherit(BI.Widget, { value: "", lineHeight: 2, showHint: true, - supportFunction: false + supportFunction: false, + supportParam: false }); }, _init: function () { @@ -47064,14 +47075,14 @@ BI.SQLEditor = BI.inherit(BI.Widget, { }, setValue: function (v) { - var self = this, result; + var self = this, result, o = this.options; this.refresh(); self.editor.setValue(""); result = this._analyzeContent(v || ""); BI.each(result, function (i, item) { var fieldRegx = /\$[\{][^\}]*[\}]/; var str = item.match(fieldRegx); - if (BI.isNotEmptyArray(str)) { + if (BI.isNotEmptyArray(str) && o.supportParam) { self.insertParam(str[0].substring(2, item.length - 1)); } else { self.insertString(item); @@ -67687,6 +67698,7 @@ BI.IconTextValueCombo = BI.inherit(BI.Widget, { type: "bi.select_icon_text_trigger", items: o.items, height: o.height, + text: o.text, value: o.value }); this.popup = BI.createWidget({ @@ -67813,6 +67825,7 @@ BI.StaticCombo = BI.inherit(BI.Widget, { type: "bi.text_icon_item", cls: "bi-select-text-trigger bi-border pull-down-font", text: o.text, + value: o.value, readonly: true, textLgap: 5, height: o.height - 2 @@ -67821,7 +67834,8 @@ BI.StaticCombo = BI.inherit(BI.Widget, { type: "bi.text_value_combo_popup", textAlign: o.textAlign, chooseType: o.chooseType, - items: o.items + items: o.items, + value: o.value }); this.popup.on(BI.Controller.EVENT_CHANGE, function () { self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); @@ -68205,7 +68219,8 @@ BI.shortcut("bi.small_text_value_combo", BI.SmallTextValueCombo);BI.TextValueCom chooseType: o.chooseType, layouts: [{ type: "bi.vertical" - }] + }], + value: o.value }); this.popup.on(BI.Controller.EVENT_CHANGE, function (type, val, obj) { @@ -74636,25 +74651,31 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, { disableSelected: true, isHalfCheckedBySelectedValue: function (selectedValues) { return selectedValues.length > 0; - } + }, + halfSelected: false }); }, _init: function () { BI.MultiSelectBar.superclass._init.apply(this, arguments); var self = this, o = this.options; + var isSelect = o.selected === true; + var isHalfSelect = !o.selected && o.halfSelected; this.checkbox = BI.createWidget({ type: "bi.checkbox", stopPropagation: true, handler: function () { self.setSelected(self.isSelected()); - } + }, + selected: isSelect, + invisible: isHalfSelect }); this.half = BI.createWidget({ type: "bi.half_icon_button", stopPropagation: true, handler: function () { self.setSelected(true); - } + }, + invisible: isSelect || !isHalfSelect }); this.checkbox.on(BI.Controller.EVENT_CHANGE, function () { self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.CLICK, self.isSelected(), self); @@ -74693,7 +74714,10 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, { el: this.text }] }); - this.half.invisible(); + }, + + _setSelected: function (v) { + this.checkbox.setSelected(!!v); }, // 自己手动控制选中 @@ -74712,8 +74736,9 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, { }, setHalfSelected: function (b) { - this._half = !!b; + this.halfSelected = !!b; if (b === true) { + this.checkbox.setSelected(false); this.half.visible(); this.checkbox.invisible(); } else { @@ -74723,7 +74748,7 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, { }, isHalfSelected: function () { - return !!this._half; + return !this.isSelected() && !!this.halfSelected; }, isSelected: function () { @@ -74733,7 +74758,7 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, { setValue: function (selectedValues) { BI.MultiSelectBar.superclass.setValue.apply(this, arguments); var isAllChecked = this.options.isAllCheckedBySelectedValue.apply(this, arguments); - this.setSelected(isAllChecked); + this._setSelected(isAllChecked); !isAllChecked && this.setHalfSelected(this.options.isHalfCheckedBySelectedValue.apply(this, arguments)); } }); @@ -76027,7 +76052,7 @@ BI.SelectIconTextTrigger = BI.inherit(BI.Trigger, { }; } else { return { - text: o.value, + text: o.text, iconClass: "" }; } diff --git a/dist/case.js b/dist/case.js index 90cbb79a6..3a0a835c0 100644 --- a/dist/case.js +++ b/dist/case.js @@ -5458,6 +5458,7 @@ BI.IconTextValueCombo = BI.inherit(BI.Widget, { type: "bi.select_icon_text_trigger", items: o.items, height: o.height, + text: o.text, value: o.value }); this.popup = BI.createWidget({ @@ -5584,6 +5585,7 @@ BI.StaticCombo = BI.inherit(BI.Widget, { type: "bi.text_icon_item", cls: "bi-select-text-trigger bi-border pull-down-font", text: o.text, + value: o.value, readonly: true, textLgap: 5, height: o.height - 2 @@ -5592,7 +5594,8 @@ BI.StaticCombo = BI.inherit(BI.Widget, { type: "bi.text_value_combo_popup", textAlign: o.textAlign, chooseType: o.chooseType, - items: o.items + items: o.items, + value: o.value }); this.popup.on(BI.Controller.EVENT_CHANGE, function () { self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); @@ -5976,7 +5979,8 @@ BI.shortcut("bi.small_text_value_combo", BI.SmallTextValueCombo);BI.TextValueCom chooseType: o.chooseType, layouts: [{ type: "bi.vertical" - }] + }], + value: o.value }); this.popup.on(BI.Controller.EVENT_CHANGE, function (type, val, obj) { @@ -12407,25 +12411,31 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, { disableSelected: true, isHalfCheckedBySelectedValue: function (selectedValues) { return selectedValues.length > 0; - } + }, + halfSelected: false }); }, _init: function () { BI.MultiSelectBar.superclass._init.apply(this, arguments); var self = this, o = this.options; + var isSelect = o.selected === true; + var isHalfSelect = !o.selected && o.halfSelected; this.checkbox = BI.createWidget({ type: "bi.checkbox", stopPropagation: true, handler: function () { self.setSelected(self.isSelected()); - } + }, + selected: isSelect, + invisible: isHalfSelect }); this.half = BI.createWidget({ type: "bi.half_icon_button", stopPropagation: true, handler: function () { self.setSelected(true); - } + }, + invisible: isSelect || !isHalfSelect }); this.checkbox.on(BI.Controller.EVENT_CHANGE, function () { self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.CLICK, self.isSelected(), self); @@ -12464,7 +12474,10 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, { el: this.text }] }); - this.half.invisible(); + }, + + _setSelected: function (v) { + this.checkbox.setSelected(!!v); }, // 自己手动控制选中 @@ -12483,8 +12496,9 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, { }, setHalfSelected: function (b) { - this._half = !!b; + this.halfSelected = !!b; if (b === true) { + this.checkbox.setSelected(false); this.half.visible(); this.checkbox.invisible(); } else { @@ -12494,7 +12508,7 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, { }, isHalfSelected: function () { - return !!this._half; + return !this.isSelected() && !!this.halfSelected; }, isSelected: function () { @@ -12504,7 +12518,7 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, { setValue: function (selectedValues) { BI.MultiSelectBar.superclass.setValue.apply(this, arguments); var isAllChecked = this.options.isAllCheckedBySelectedValue.apply(this, arguments); - this.setSelected(isAllChecked); + this._setSelected(isAllChecked); !isAllChecked && this.setHalfSelected(this.options.isHalfCheckedBySelectedValue.apply(this, arguments)); } }); @@ -13798,7 +13812,7 @@ BI.SelectIconTextTrigger = BI.inherit(BI.Trigger, { }; } else { return { - text: o.value, + text: o.text, iconClass: "" }; } diff --git a/dist/demo.js b/dist/demo.js index 7be427cf3..e67631a2e 100644 --- a/dist/demo.js +++ b/dist/demo.js @@ -196,6 +196,28 @@ $(function () { iconClass: "close-font", height: 30 } + }, { + el: { + type: "bi.multi_select_bar", + selected: true, + halfSelected: true + } + }, { + el: { + type: "bi.multi_select_bar", + selected: true, + halfSelected: false + } + }, { + el: { + type: "bi.multi_select_bar", + selected: false, + halfSelected: true + } + }, { + el: { + type: "bi.multi_select_bar" + } } ]; BI.each(items, function (i, item) { @@ -704,6 +726,7 @@ BI.shortcut("demo.code_editor", Demo.CodeEditor);Demo.Editor = BI.inherit(BI.Wid cls: "mvc-border", watermark: "输入'a'会有错误信息且回车键不能退出编辑", errorText: "字段不可重名", + value: "a", validationChecker: function (v) { if (v == "a") { return false; @@ -842,6 +865,7 @@ Demo.SQLEditor = BI.inherit(BI.Widget, { var self = this; this.formula = BI.createWidget({ type : 'bi.sql_editor', + supportParam: true, width : 300, height : 200, value : "select * from DEMO_CONTRACT where 合同类型 = ${长期协议} and 购买数量 = sum([1,2,3,4])" @@ -1808,7 +1832,8 @@ Demo.IconTextValueCombo = BI.inherit(BI.Widget, { type: "bi.horizontal_auto", items: [{ type: "bi.icon_text_value_combo", - value: "默认值", + text: "默认值", + value: 1, width: 300, items: [{ text: "MVC-1", diff --git a/dist/fineui.js b/dist/fineui.js index fe4751bb4..df9584968 100644 --- a/dist/fineui.js +++ b/dist/fineui.js @@ -28588,6 +28588,7 @@ BI.ButtonGroup = BI.inherit(BI.Widget, { baseCls: "bi-button-group", behaviors: {}, items: [], + value: "", chooseType: BI.Selection.Single, layouts: [{ type: "bi.center", @@ -28599,14 +28600,18 @@ BI.ButtonGroup = BI.inherit(BI.Widget, { _init: function () { BI.ButtonGroup.superclass._init.apply(this, arguments); + var o = this.options; var behaviors = {}; - BI.each(this.options.behaviors, function (key, rule) { + BI.each(o.behaviors, function (key, rule) { behaviors[key] = BI.BehaviorFactory.createBehavior(key, { rule: rule }); }); this.behaviors = behaviors; - this.populate(this.options.items); + this.populate(o.items); + if(BI.isKey(o.value) || BI.isNotEmptyArray(o.value)){ + this.setValue(o.value); + } }, _createBtns: function (items) { @@ -45638,6 +45643,7 @@ BI.Editor = BI.inherit(BI.Single, { type: "bi.input", element: "", root: true, + value: o.value, watermark: o.watermark, validationChecker: o.validationChecker, quitChecker: o.quitChecker, @@ -45780,7 +45786,8 @@ BI.Editor = BI.inherit(BI.Single, { return false; }); if (BI.isKey(this.options.value) || BI.isEmptyString(this.options.value)) { - this.setValue(this.options.value); + this._checkError(); + this._checkWaterMark(); } else { this._checkWaterMark(); } @@ -46984,6 +46991,9 @@ BI.Input = BI.inherit(BI.Single, { .focusout(function (e) { self._blurDebounce(); }); + if (BI.isKey(this.options.value) || BI.isEmptyString(this.options.value)) { + this.setValue(this.options.value); + } }, _focus: function () { @@ -48634,7 +48644,8 @@ BI.SQLEditor = BI.inherit(BI.Widget, { value: "", lineHeight: 2, showHint: true, - supportFunction: false + supportFunction: false, + supportParam: false }); }, _init: function () { @@ -48758,14 +48769,14 @@ BI.SQLEditor = BI.inherit(BI.Widget, { }, setValue: function (v) { - var self = this, result; + var self = this, result, o = this.options; this.refresh(); self.editor.setValue(""); result = this._analyzeContent(v || ""); BI.each(result, function (i, item) { var fieldRegx = /\$[\{][^\}]*[\}]/; var str = item.match(fieldRegx); - if (BI.isNotEmptyArray(str)) { + if (BI.isNotEmptyArray(str) && o.supportParam) { self.insertParam(str[0].substring(2, item.length - 1)); } else { self.insertString(item); @@ -69381,6 +69392,7 @@ BI.IconTextValueCombo = BI.inherit(BI.Widget, { type: "bi.select_icon_text_trigger", items: o.items, height: o.height, + text: o.text, value: o.value }); this.popup = BI.createWidget({ @@ -69507,6 +69519,7 @@ BI.StaticCombo = BI.inherit(BI.Widget, { type: "bi.text_icon_item", cls: "bi-select-text-trigger bi-border pull-down-font", text: o.text, + value: o.value, readonly: true, textLgap: 5, height: o.height - 2 @@ -69515,7 +69528,8 @@ BI.StaticCombo = BI.inherit(BI.Widget, { type: "bi.text_value_combo_popup", textAlign: o.textAlign, chooseType: o.chooseType, - items: o.items + items: o.items, + value: o.value }); this.popup.on(BI.Controller.EVENT_CHANGE, function () { self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); @@ -69899,7 +69913,8 @@ BI.shortcut("bi.small_text_value_combo", BI.SmallTextValueCombo);BI.TextValueCom chooseType: o.chooseType, layouts: [{ type: "bi.vertical" - }] + }], + value: o.value }); this.popup.on(BI.Controller.EVENT_CHANGE, function (type, val, obj) { @@ -76330,25 +76345,31 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, { disableSelected: true, isHalfCheckedBySelectedValue: function (selectedValues) { return selectedValues.length > 0; - } + }, + halfSelected: false }); }, _init: function () { BI.MultiSelectBar.superclass._init.apply(this, arguments); var self = this, o = this.options; + var isSelect = o.selected === true; + var isHalfSelect = !o.selected && o.halfSelected; this.checkbox = BI.createWidget({ type: "bi.checkbox", stopPropagation: true, handler: function () { self.setSelected(self.isSelected()); - } + }, + selected: isSelect, + invisible: isHalfSelect }); this.half = BI.createWidget({ type: "bi.half_icon_button", stopPropagation: true, handler: function () { self.setSelected(true); - } + }, + invisible: isSelect || !isHalfSelect }); this.checkbox.on(BI.Controller.EVENT_CHANGE, function () { self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.CLICK, self.isSelected(), self); @@ -76387,7 +76408,10 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, { el: this.text }] }); - this.half.invisible(); + }, + + _setSelected: function (v) { + this.checkbox.setSelected(!!v); }, // 自己手动控制选中 @@ -76406,8 +76430,9 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, { }, setHalfSelected: function (b) { - this._half = !!b; + this.halfSelected = !!b; if (b === true) { + this.checkbox.setSelected(false); this.half.visible(); this.checkbox.invisible(); } else { @@ -76417,7 +76442,7 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, { }, isHalfSelected: function () { - return !!this._half; + return !this.isSelected() && !!this.halfSelected; }, isSelected: function () { @@ -76427,7 +76452,7 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, { setValue: function (selectedValues) { BI.MultiSelectBar.superclass.setValue.apply(this, arguments); var isAllChecked = this.options.isAllCheckedBySelectedValue.apply(this, arguments); - this.setSelected(isAllChecked); + this._setSelected(isAllChecked); !isAllChecked && this.setHalfSelected(this.options.isHalfCheckedBySelectedValue.apply(this, arguments)); } }); @@ -77721,7 +77746,7 @@ BI.SelectIconTextTrigger = BI.inherit(BI.Trigger, { }; } else { return { - text: o.value, + text: o.text, iconClass: "" }; } diff --git a/src/base/combination/group.button.js b/src/base/combination/group.button.js index 27cfa7439..3a13f6d6e 100644 --- a/src/base/combination/group.button.js +++ b/src/base/combination/group.button.js @@ -10,6 +10,7 @@ BI.ButtonGroup = BI.inherit(BI.Widget, { baseCls: "bi-button-group", behaviors: {}, items: [], + value: "", chooseType: BI.Selection.Single, layouts: [{ type: "bi.center", @@ -21,14 +22,18 @@ BI.ButtonGroup = BI.inherit(BI.Widget, { _init: function () { BI.ButtonGroup.superclass._init.apply(this, arguments); + var o = this.options; var behaviors = {}; - BI.each(this.options.behaviors, function (key, rule) { + BI.each(o.behaviors, function (key, rule) { behaviors[key] = BI.BehaviorFactory.createBehavior(key, { rule: rule }); }); this.behaviors = behaviors; - this.populate(this.options.items); + this.populate(o.items); + if(BI.isKey(o.value) || BI.isNotEmptyArray(o.value)){ + this.setValue(o.value); + } }, _createBtns: function (items) { diff --git a/src/base/single/editor/editor.js b/src/base/single/editor/editor.js index 96d90c5a0..15a4e9c0a 100644 --- a/src/base/single/editor/editor.js +++ b/src/base/single/editor/editor.js @@ -32,6 +32,7 @@ BI.Editor = BI.inherit(BI.Single, { type: "bi.input", element: "", root: true, + value: o.value, watermark: o.watermark, validationChecker: o.validationChecker, quitChecker: o.quitChecker, @@ -174,7 +175,8 @@ BI.Editor = BI.inherit(BI.Single, { return false; }); if (BI.isKey(this.options.value) || BI.isEmptyString(this.options.value)) { - this.setValue(this.options.value); + this._checkError(); + this._checkWaterMark(); } else { this._checkWaterMark(); } diff --git a/src/base/single/input/input.js b/src/base/single/input/input.js index a88499f2f..1b2d29e42 100644 --- a/src/base/single/input/input.js +++ b/src/base/single/input/input.js @@ -57,6 +57,9 @@ BI.Input = BI.inherit(BI.Single, { .focusout(function (e) { self._blurDebounce(); }); + if (BI.isKey(this.options.value) || BI.isEmptyString(this.options.value)) { + this.setValue(this.options.value); + } }, _focus: function () { diff --git a/src/base/sql/editor.sql.js b/src/base/sql/editor.sql.js index f4c4815de..1870c4a18 100644 --- a/src/base/sql/editor.sql.js +++ b/src/base/sql/editor.sql.js @@ -8,7 +8,8 @@ BI.SQLEditor = BI.inherit(BI.Widget, { value: "", lineHeight: 2, showHint: true, - supportFunction: false + supportFunction: false, + supportParam: false }); }, _init: function () { @@ -132,14 +133,14 @@ BI.SQLEditor = BI.inherit(BI.Widget, { }, setValue: function (v) { - var self = this, result; + var self = this, result, o = this.options; this.refresh(); self.editor.setValue(""); result = this._analyzeContent(v || ""); BI.each(result, function (i, item) { var fieldRegx = /\$[\{][^\}]*[\}]/; var str = item.match(fieldRegx); - if (BI.isNotEmptyArray(str)) { + if (BI.isNotEmptyArray(str) && o.supportParam) { self.insertParam(str[0].substring(2, item.length - 1)); } else { self.insertString(item); diff --git a/src/case/combo/icontextvaluecombo/combo.icontextvalue.js b/src/case/combo/icontextvaluecombo/combo.icontextvalue.js index 259ab4886..ecf4be7ca 100644 --- a/src/case/combo/icontextvaluecombo/combo.icontextvalue.js +++ b/src/case/combo/icontextvaluecombo/combo.icontextvalue.js @@ -19,6 +19,7 @@ BI.IconTextValueCombo = BI.inherit(BI.Widget, { type: "bi.select_icon_text_trigger", items: o.items, height: o.height, + text: o.text, value: o.value }); this.popup = BI.createWidget({ diff --git a/src/case/combo/staticcombo/combo.static.js b/src/case/combo/staticcombo/combo.static.js index f0c196171..95d350514 100644 --- a/src/case/combo/staticcombo/combo.static.js +++ b/src/case/combo/staticcombo/combo.static.js @@ -23,6 +23,7 @@ BI.StaticCombo = BI.inherit(BI.Widget, { type: "bi.text_icon_item", cls: "bi-select-text-trigger bi-border pull-down-font", text: o.text, + value: o.value, readonly: true, textLgap: 5, height: o.height - 2 @@ -31,7 +32,8 @@ BI.StaticCombo = BI.inherit(BI.Widget, { type: "bi.text_value_combo_popup", textAlign: o.textAlign, chooseType: o.chooseType, - items: o.items + items: o.items, + value: o.value }); this.popup.on(BI.Controller.EVENT_CHANGE, function () { self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); diff --git a/src/case/combo/textvaluecombo/popup.textvalue.js b/src/case/combo/textvaluecombo/popup.textvalue.js index b65038358..1efea30e8 100644 --- a/src/case/combo/textvaluecombo/popup.textvalue.js +++ b/src/case/combo/textvaluecombo/popup.textvalue.js @@ -19,7 +19,8 @@ BI.TextValueComboPopup = BI.inherit(BI.Pane, { chooseType: o.chooseType, layouts: [{ type: "bi.vertical" - }] + }], + value: o.value }); this.popup.on(BI.Controller.EVENT_CHANGE, function (type, val, obj) { diff --git a/src/case/toolbar/toolbar.multiselect.js b/src/case/toolbar/toolbar.multiselect.js index 0c536148f..c36a53cc6 100644 --- a/src/case/toolbar/toolbar.multiselect.js +++ b/src/case/toolbar/toolbar.multiselect.js @@ -16,25 +16,31 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, { disableSelected: true, isHalfCheckedBySelectedValue: function (selectedValues) { return selectedValues.length > 0; - } + }, + halfSelected: false }); }, _init: function () { BI.MultiSelectBar.superclass._init.apply(this, arguments); var self = this, o = this.options; + var isSelect = o.selected === true; + var isHalfSelect = !o.selected && o.halfSelected; this.checkbox = BI.createWidget({ type: "bi.checkbox", stopPropagation: true, handler: function () { self.setSelected(self.isSelected()); - } + }, + selected: isSelect, + invisible: isHalfSelect }); this.half = BI.createWidget({ type: "bi.half_icon_button", stopPropagation: true, handler: function () { self.setSelected(true); - } + }, + invisible: isSelect || !isHalfSelect }); this.checkbox.on(BI.Controller.EVENT_CHANGE, function () { self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.CLICK, self.isSelected(), self); @@ -73,7 +79,10 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, { el: this.text }] }); - this.half.invisible(); + }, + + _setSelected: function (v) { + this.checkbox.setSelected(!!v); }, // 自己手动控制选中 @@ -92,8 +101,9 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, { }, setHalfSelected: function (b) { - this._half = !!b; + this.halfSelected = !!b; if (b === true) { + this.checkbox.setSelected(false); this.half.visible(); this.checkbox.invisible(); } else { @@ -103,7 +113,7 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, { }, isHalfSelected: function () { - return !!this._half; + return !this.isSelected() && !!this.halfSelected; }, isSelected: function () { @@ -113,7 +123,7 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, { setValue: function (selectedValues) { BI.MultiSelectBar.superclass.setValue.apply(this, arguments); var isAllChecked = this.options.isAllCheckedBySelectedValue.apply(this, arguments); - this.setSelected(isAllChecked); + this._setSelected(isAllChecked); !isAllChecked && this.setHalfSelected(this.options.isHalfCheckedBySelectedValue.apply(this, arguments)); } }); diff --git a/src/case/trigger/trigger.icon.text.select.js b/src/case/trigger/trigger.icon.text.select.js index d957d90fd..3b3c7fb1e 100644 --- a/src/case/trigger/trigger.icon.text.select.js +++ b/src/case/trigger/trigger.icon.text.select.js @@ -46,7 +46,7 @@ BI.SelectIconTextTrigger = BI.inherit(BI.Trigger, { }; } else { return { - text: o.value, + text: o.text, iconClass: "" }; }