diff --git a/bi/widget.js b/bi/widget.js index e418ac9f0..5580c64d8 100644 --- a/bi/widget.js +++ b/bi/widget.js @@ -2360,7 +2360,7 @@ BI.DateTimeCombo = BI.inherit(BI.Widget, { o = this.options; this.trigger = BI.createWidget({ - type: "bi.date_trigger" + type: "bi.date_time_trigger1" }); this.trigger.on(BI.DateTrigger.EVENT_TRIGGER_CLICK, function () { @@ -2371,13 +2371,21 @@ BI.DateTimeCombo = BI.inherit(BI.Widget, { type: "bi.date_time_popup" }); - this.popup.on(BI.DateCalendarPopup.EVENT_CHANGE, function () { - self.setValue(self.popup.getValue()); + this.popup.on(BI.DateTimePopup.EVENT_CHANGE, function () { + //self.setValue(self.popup.getValue()); + }); + this.popup.on(BI.DateTimePopup.EVENT_CLICK_CONFIRM, function () { + //do something here + self.setValue(); + self.combo.hideView(); + }); + this.popup.on(BI.DateTimePopup.EVENT_CLICK_CANCEL, function () { + self.combo.hideView(); }); this.combo = BI.createWidget({ type: "bi.combo", - toggle: false, + toggle: true, element: this, isNeedAdjustHeight: false, isNeedAdjustWidth: false, @@ -2391,29 +2399,156 @@ BI.DateTimeCombo = BI.inherit(BI.Widget, { }, - _reviseMinute: function () { - this.m._finetuning(this.s.isNeedRevise); - this._reviseHour(); + getValue: function () { + return this.popup.getValue(); }, - _reviseHour: function () { - this.h._finetuning(this.m.isNeedRevise); + setStep: function (step) { + this.step = step || this.step; }, - getCurrentTime: function () { + setValue: function (v) { + this.trigger.setValue(this.popup.getValue()); + } + +}); +BI.DateTimeCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.shortcut("bi.date_time_combo", BI.DateTimeCombo);/** + * Created by dailer on 2017/7/18. + * 数值微调器练习 + */ +BI.NumberSpinner = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.NumberSpinner.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-fine-tuning-number-editor bi-border", + value: 0, + min: 0, + max: 100000, + step: 1, + formatter: BI.emptyFn, + parser: BI.emptyFn + }) + }, + + _init: function () { + BI.NumberSpinner.superclass._init.apply(this, arguments); + var self = this, + o = this.options; + if (o.formatter == BI.emptyFn) { + this.formatter = function (v) { + return v; + } + } else { + this.formatter = o.formatter; + } + + this.parser = o.parser; + this.step = o.step; + this.min = o.min; + this.max = o.max; + this.value = o.value; + this.isNeedRevise = 0; + + this.editor = BI.createWidget({ + type: "bi.sign_editor", + value: o.value, + errorText: BI.i18nText("BI-Please_Input_Natural_Number") + }); + this.editor.on(BI.TextEditor.EVENT_CONFIRM, function () { + self.setValue(self.editor.getValue()); + self.fireEvent(BI.NumberSpinner.EVENT_CONFIRM); + }); + + + this.topBtn = BI.createWidget({ + type: "bi.icon_button", + trigger: "lclick,", + cls: "column-pre-page-h-font top-button bi-border-left bi-border-bottom", + }); + this.topBtn.on(BI.IconButton.EVENT_CHANGE, function () { + + self._finetuning(1); + + self.fireEvent(BI.NumberSpinner.EVENT_CONFIRM); + }); + + this.bottomBtn = BI.createWidget({ + type: "bi.icon_button", + trigger: "lclick,", + cls: "column-next-page-h-font bottom-button bi-border-left bi-border-top" + }); + this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function () { + self._finetuning(-1); + self.fireEvent(BI.NumberSpinner.EVENT_CONFIRM); + }); + + this._finetuning(0); + + BI.createWidget({ + type: "bi.htape", + element: this, + items: [this.editor, { + el: { + type: "bi.grid", + columns: 1, + rows: 2, + items: [{ + column: 0, + row: 0, + el: this.topBtn + }, { + column: 0, + row: 1, + el: this.bottomBtn + }] + }, + width: 30 + }] + }); + }, + + //微调 + _finetuning: function (add) { + //窝是在不值该如何处理精度损失问题,所以迫不得已采取了这个方法 + var v = BI.parseFloat(this.editor.getValue()) * 1000000000000; + var addend = add * this.step * 1000000000000; + var result = (v + addend) / 1000000000000; + + if (result > this.max) { + this.editor.setValue(this.formatter(this.min)); + this.isNeedRevise = 1; + this.value = this.min; + return; + } + if (result < this.min) { + this.editor.setValue(this.formatter(this.max)); + this.isNeedRevise = -1; + this.value = this.max; + return; + } + this.value = result; + this.isNeedRevise = 0; + this.editor.setValue(this.formatter(result)); + + }, + + getIsNeedRevise: function () { + return this.isNeedRevise; + }, + + getMinAndMax: function () { return { - hour: this.h.getValue(), - minute: this.m.getValue(), - second: this.s.getValue() + min: this.min, + max: this.max }; }, - _format: function (p) { - return p < 10 ? ('0' + p) : p + getStep: function () { + return this.step; }, - getCurrentTimeStr: function () { - return this._format(this.h.getValue()) + ':' + this._format(this.m.getValue()) + ':' + this._format(this.s.getValue()) + getValue: function () { + return this.value; }, setStep: function (step) { @@ -2421,12 +2556,13 @@ BI.DateTimeCombo = BI.inherit(BI.Widget, { }, setValue: function (v) { - + this.value = v; + this.editor.setValue(this.formatter(v)); } }); -BI.DateTimeCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.shortcut("bi.date_time_combo", BI.DateTimeCombo);/** +BI.NumberSpinner.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.shortcut("bi.test_editor", BI.NumberSpinner);/** * Created by GUY on 2015/9/7. * @class BI.DateCalendarPopup * @extends BI.Widget @@ -2435,7 +2571,7 @@ BI.DateTimePopup = BI.inherit(BI.Widget, { _defaultConfig: function () { var conf = BI.DateTimePopup.superclass._defaultConfig.apply(this, arguments); return BI.extend(conf, { - baseCls: "bi-date-calendar-popup", + baseCls: "bi-date-calendar-popup demo-clolor", min: '1900-01-01', //最小日期 max: '2099-12-31', //最大日期 selectedTime: null @@ -2466,16 +2602,23 @@ BI.DateTimePopup = BI.inherit(BI.Widget, { this._year = this.today.getFullYear(); this._month = this.today.getMonth(); this._day = this.today.getDate(); + this._hour = this.today.getHours(); + this._minute = this.today.getMinutes(); + this._second = this.today.getSeconds(); this.selectedTime = o.selectedTime || { year: this._year, month: this._month, - day: this._day + day: this._day, + hour: this._hour, + minute: this._minute, + second: this._second }; this.datePicker = BI.createWidget({ type: "bi.date_picker", min: o.min, - max: o.max + max: o.max, + cls: "demo-clolor", }); this.calendar = BI.createWidget({ @@ -2494,21 +2637,42 @@ BI.DateTimePopup = BI.inherit(BI.Widget, { afterCardShow: function () { this.setValue(self.selectedTime); + self.calendar.setSelect(BI.Calendar.getPageByDateJSON(self.selectedTime)); } }); this.timeTunning = BI.createWidget({ - type: "bi.time_tunning" + type: "bi.time_tunning", + currentTime: { + hour: this._hour, + minute: this._minute, + second: this._second + } + }); + this.timeTunning.on(BI.TimeTuning.EVENT_CHANGE, function () { + self.selectedTime = self.timeTunning.getValue(); }); this.buttons = BI.createWidget({ type: "bi.button_group", items: [{ - type: "bi.text_button", - text: BI.i18nText('BI-Basic_Clears') + type: "bi.button", + textHeight: 30, + clear: true, + text: "取消", + handler: function () { + self.fireEvent(BI.DateTimePopup.EVENT_CLICK_CANCEL); + } + }, { + text: "|" }, { - type: "bi.text_button", - text: BI.i18nText("BI-Basic_Sure") + type: "bi.button", + textHeight: 30, + clear: true, + text: BI.i18nText("BI-Basic_Sure"), + handler: function () { + self.fireEvent(BI.DateTimePopup.EVENT_CLICK_CONFIRM); + } }], chooseType: 0, behaviors: {}, @@ -2531,23 +2695,28 @@ BI.DateTimePopup = BI.inherit(BI.Widget, { this.calendar.on(BI.Navigation.EVENT_CHANGE, function () { self.selectedTime = self.calendar.getValue(); - self.setValue(self.selectedTime); - self.fireEvent(BI.DateCalendarPopup.EVENT_CHANGE); + self.fireEvent(BI.DateTimePopup.EVENT_CHANGE); }); + + self.calendar.setSelect(BI.Calendar.getPageByDateJSON(self.selectedTime)); + this.calendar.setValue(this.selectedTime); }, setValue: function (timeOb) { this.datePicker.setValue(timeOb); this.calendar.setSelect(BI.Calendar.getPageByDateJSON(timeOb)); this.calendar.setValue(timeOb); + this.timeTunning.setValue(timeOb); this.selectedTime = timeOb; }, getValue: function () { - return this.selectedTime; + return $.extend({}, this.calendar.getValue(), this.timeTunning.getValue()); } }); BI.DateTimePopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.DateTimePopup.EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM"; +BI.DateTimePopup.EVENT_CLICK_CANCEL = "EVENT_CLICK_CANCEL"; BI.shortcut("bi.date_time_popup", BI.DateTimePopup);/** * Created by dailer on 2017/7/19. * 时间微调器练习 @@ -2599,7 +2768,9 @@ BI.TimeTuning = BI.inherit(BI.Widget, { width: 60, height: 30 }); - this.h.on(BI.FineTuningNumberEditor.EVENT_CONFIRM, function () {}); + this.h.on(BI.FineTuningNumberEditor.EVENT_CONFIRM, function () { + self.fireEvent(BI.TimeTuning.EVENT_CHANGE); + }); //分 this.m = BI.createWidget({ @@ -2612,6 +2783,7 @@ BI.TimeTuning = BI.inherit(BI.Widget, { }) this.m.on(BI.FineTuningNumberEditor.EVENT_CONFIRM, function () { self._reviseHour(); + self.fireEvent(BI.TimeTuning.EVENT_CHANGE); }); //秒 @@ -2625,6 +2797,7 @@ BI.TimeTuning = BI.inherit(BI.Widget, { }) this.s.on(BI.FineTuningNumberEditor.EVENT_CONFIRM, function () { self._reviseMinute(); + self.fireEvent(BI.TimeTuning.EVENT_CHANGE); }); @@ -2657,7 +2830,7 @@ BI.TimeTuning = BI.inherit(BI.Widget, { BI.createWidget({ type: "bi.htape", - cls: "bi-border demo-clolor", + cls: "demo-clolor", element: this, items: [this.editor], width: 270, @@ -2666,12 +2839,12 @@ BI.TimeTuning = BI.inherit(BI.Widget, { }, _reviseMinute: function () { - this.m._finetuning(this.s.isNeedRevise); + this.m._finetuning(this.s.getIsNeedRevise()); this._reviseHour(); }, _reviseHour: function () { - this.h._finetuning(this.m.isNeedRevise); + this.h._finetuning(this.m.getIsNeedRevise()); }, getCurrentTime: function () { @@ -2690,169 +2863,97 @@ BI.TimeTuning = BI.inherit(BI.Widget, { return this._format(this.h.getValue()) + ':' + this._format(this.m.getValue()) + ':' + this._format(this.s.getValue()) }, + getValue: function () { + return { + hour: this.h.getValue(), + minute: this.m.getValue(), + second: this.s.getValue() + } + }, + setStep: function (step) { this.step = step || this.step; }, - setValue: function (v) { - this.value = v; - this.editor.setValue(); + setValue: function (timeObj) { + this.h.setValue(timeObj.hour); + this.m.setValue(timeObj.minute); + this.s.setValue(timeObj.second); } }); -BI.TimeTuning.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.shortcut("bi.time_tunning", BI.TimeTuning);/** - * Created by dailer on 2017/7/18. - * 数值微调器练习 - */ -BI.FineTuningNumberEditor = BI.inherit(BI.Widget, { +BI.TimeTuning.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.time_tunning", BI.TimeTuning);BI.DateTimeTrigger = BI.inherit(BI.Trigger, { + _defaultConfig: function () { - return BI.extend(BI.FineTuningNumberEditor.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-fine-tuning-number-editor bi-border", - value: 0, - disabled: false, - min: 0, - max: 100000, - step: 1, - formatter: BI.emptyFn, - parser: BI.emptyFn - }) + return BI.extend(BI.DateTimeTrigger.superclass._defaultConfig.apply(this, arguments), { + extraCls: "bi-date-trigger", + min: '1900-01-01', //最小日期 + max: '2099-12-31', //最大日期 + height: 32 + }); }, - _init: function () { - BI.FineTuningNumberEditor.superclass._init.apply(this, arguments); + BI.DateTimeTrigger.superclass._init.apply(this, arguments); var self = this, o = this.options; - if (o.formatter == BI.emptyFn) { - this.formatter = function (v) { - return v; - } - } else { - this.formatter = o.formatter; - } - - this.parser = o.parser; - this.step = o.step; - this.min = o.min; - this.max = o.max; - this.value = o.value; - this.isNeedRevise = 0; - - this.editor = BI.createWidget({ - type: "bi.sign_editor", - value: o.value, - errorText: BI.i18nText("BI-Please_Input_Natural_Number") - }); - this.editor.on(BI.TextEditor.EVENT_CONFIRM, function () { - self.setValue(self.editor.getValue()); - self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM); - }); - - - this.topBtn = BI.createWidget({ - type: "bi.icon_button", - trigger: "lclick,", - cls: "column-pre-page-h-font top-button bi-border-left bi-border-bottom", - }); - this.topBtn.on(BI.IconButton.EVENT_CHANGE, function () { - self._isNeedRevise(); - - self._finetuning(1); - - self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM); - }); - - this.bottomBtn = BI.createWidget({ - type: "bi.icon_button", - trigger: "lclick,", - cls: "column-next-page-h-font bottom-button bi-border-left bi-border-top" - }); - this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function () { - self._finetuning(-1); - self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM); + this.label = BI.createWidget({ + type: "bi.label", + textAlign: "left", + text: "", + height: o.height }); - this._finetuning(0); - BI.createWidget({ type: "bi.htape", element: this, - items: [this.editor, { - el: { - type: "bi.grid", - columns: 1, - rows: 2, - items: [{ - column: 0, - row: 0, - el: this.topBtn - }, { - column: 0, - row: 1, - el: this.bottomBtn - }] - }, + items: [{ + el: BI.createWidget({ + type: "bi.icon_button", + cls: "search-font" + }), width: 30 + }, { + el: this.label }] - }); - }, - - //微调 - _finetuning: function (add) { - //窝是在不值该如何处理精度损失问题,所以迫不得已采取了这个方法 - var v = BI.parseFloat(this.editor.getValue()) * 1000000000000; - var addend = add * this.step * 1000000000000; - var result = (v + addend) / 1000000000000; - - if (result > this.max) { - this.editor.setValue(this.formatter(this.min)); - this.isNeedRevise = 1; - this.value = this.min; - return; - } - if (result < this.min) { - this.editor.setValue(this.formatter(this.max)); - this.isNeedRevise = -1; - this.value = this.max; - return; - } - this.value = result; - this.isNeedRevise = 0; - this.editor.setValue(this.formatter(result)); + }) + var today = new Date(), + timeObj = { + year: today.getFullYear(), + month: today.getMonth(), + day: today.getDate(), + hour: today.getHours(), + minute: today.getMinutes(), + second: today.getSeconds() + }; + this.setValue(timeObj); }, - _isNeedRevise: function () { - // console.log(this.editor.getValue() - this.value); - }, - getMinAndMax: function () { - return { - min: this.min, - max: this.max + + _parseTimeObjToStr: function (timeObj) { + var _format = function (p) { + return p < 10 ? ('0' + p) : p }; + BI.each(timeObj, function (key, val) { + timeObj[key] = _format(timeObj[key]); + }); + return timeObj.year + "-" + (1 + BI.parseInt(timeObj.month)) + "-" + timeObj.day + " " + timeObj.hour + ":" + timeObj.minute + ":" + timeObj.second; }, - getStep: function () { - return this.step; - }, + setValue: function (v) { + this.label.setValue(this._parseTimeObjToStr(v)); - getValue: function () { - return this.value; }, - setStep: function (step) { - this.step = step || this.step; - }, + getValue: function () { - setValue: function (v) { - this.value = v; - this.editor.setValue(this.formatter(v)); } }); -BI.FineTuningNumberEditor.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.shortcut("bi.test_editor", BI.FineTuningNumberEditor);/** + +BI.shortcut("bi.date_time_trigger1", BI.DateTimeTrigger);/** * 日期控件中的月份下拉框 * * Created by GUY on 2015/9/7. diff --git a/demo/js/config/component.js b/demo/js/config/component.js index 755a60f95..41e76b6fe 100644 --- a/demo/js/config/component.js +++ b/demo/js/config/component.js @@ -3,7 +3,7 @@ */ Demo.COMPONENT_CONFIG = [{ id: 5, - text: "部件" + text: "部件+服务" }, { pId: 5, text: "bi.value_chooser_combo", diff --git a/demo/js/widget/date/demo.date.js b/demo/js/widget/date/demo.date.js index 8b5665ce6..72d2ea823 100644 --- a/demo/js/widget/date/demo.date.js +++ b/demo/js/widget/date/demo.date.js @@ -11,18 +11,34 @@ Demo.Date = BI.inherit(BI.Widget, { }, render: function () { - + var self = this; return { type: "bi.horizontal_auto", vgap: 10, items: [{ type: "bi.date_combo", + ref: function () { + self.datecombo = this; + }, width: 300 }, { type: "bi.button", text: "getVlaue", - height: 50, - width: 300 + width: 300, + handler: function () { + BI.Msg.alert("date", JSON.stringify(self.datecombo.getValue())); + } + }, { + type: "bi.button", + text: "setVlaue '2017-12-31'", + width: 300, + handler: function () { + self.datecombo.setValue({ + year: 2017, + month: 11, + day: 31 + }) + } }] } } diff --git a/demo/js/widget/date/demo.datepane.js b/demo/js/widget/date/demo.datepane.js index c3ba442fd..f95b6c107 100644 --- a/demo/js/widget/date/demo.datepane.js +++ b/demo/js/widget/date/demo.datepane.js @@ -3,7 +3,7 @@ Demo.DatePane = BI.inherit(BI.Widget, { baseCls: "demo-datepane" }, render: function () { - + var self = this; return { type: "bi.horizontal_auto", items: [{ @@ -20,13 +20,26 @@ Demo.DatePane = BI.inherit(BI.Widget, { month: 12, day: 11 }, - height:300 + ref: function (_ref) { + self.datepane = _ref; + }, + height: 300 }, { type: "bi.button", text: "getValue", handler: function () { - BI.Msg.toast("date" + JSON.stringify(datepane.getValue())); + BI.Msg.toast("date" + JSON.stringify(self.datepane.getValue())); + } + }, { + type: "bi.button", + text: "setVlaue '2017-12-31'", + handler: function () { + self.datepane.setValue({ + year: 2017, + month: 11, + day: 31 + }) } } ], diff --git a/demo/js/widget/filemanager/demo.file.manager.js b/demo/js/widget/filemanager/demo.file.manager.js index d26628f1f..7b45abf59 100644 --- a/demo/js/widget/filemanager/demo.file.manager.js +++ b/demo/js/widget/filemanager/demo.file.manager.js @@ -34,20 +34,34 @@ Demo.FileManager = BI.inherit(BI.Widget, { id: "121", pId: "111", buildUrl: "www.baidu.com", - value: "111", - text: "文件2", + value: "121", + text: "文件1", lastModify: 1454316355142 }, { id: "122", pId: "111", buildUrl: "www.baidu.com", - value: "112", - text: "文件3", + value: "122", + text: "文件2", lastModify: 1454316355142 }]; - return { + var filemanager = BI.createWidget({ type: "bi.file_manager", items: items + }); + return { + type: "bi.vtape", + items: [{ + el: filemanager, + height: "fill" + }, { + type: "bi.button", + text: "getValue", + handler: function () { + BI.Msg.alert("", JSON.stringify(filemanager.getValue())); + }, + height: 25 + }] } } }); diff --git a/demo/js/widget/month/demo.month.js b/demo/js/widget/month/demo.month.js index c40ccdad9..7dd060d2f 100644 --- a/demo/js/widget/month/demo.month.js +++ b/demo/js/widget/month/demo.month.js @@ -6,13 +6,35 @@ Demo.Month = BI.inherit(BI.Widget, { baseCls: "demo-exceltable" }, render: function () { + var self = this; return { - type: "bi.horizontal_adapt", + type: "bi.horizontal_auto", items: [{ type: "bi.month_combo", + width: 300, + ref: function () { + self.monthcombo = this; + } + }, { + type: "bi.button", + text: "getValue", + handler: function () { + BI.Msg.toast(JSON.stringify(self.monthcombo.getValue())); + }, width: 300 - }] - + }, { + type: "bi.button", + text: "setValue : 11", + handler: function () { + self.monthcombo.setValue(11); + }, + width: 300 + }, { + type: "bi.label", + text: "月份value 范围为0-11,显示范围为1-12", + width: 300 + }], + vgap: 10 } } }) diff --git a/demo/js/widget/quarter/demo.quarter.js b/demo/js/widget/quarter/demo.quarter.js index bad058e63..0cadac2fb 100644 --- a/demo/js/widget/quarter/demo.quarter.js +++ b/demo/js/widget/quarter/demo.quarter.js @@ -6,13 +6,31 @@ Demo.Quarter = BI.inherit(BI.Widget, { baseCls: "demo-exceltable" }, render: function () { + var self = this; return { - type: "bi.horizontal_adapt", + type: "bi.horizontal_auto", items: [{ type: "bi.quarter_combo", + width: 300, + ref: function () { + self.quartercombo = this; + } + }, { + type: "bi.button", + text: "getValue", + handler: function () { + BI.Msg.toast(JSON.stringify(self.quartercombo.getValue())); + }, width: 300 - }] - + }, { + type: "bi.button", + text: "setValue : 3", + handler: function () { + self.quartercombo.setValue(3); + }, + width: 300 + }], + vgap: 10 } } }) diff --git a/demo/js/widget/year/demo.year.js b/demo/js/widget/year/demo.year.js index 810b224b9..b67ec216f 100644 --- a/demo/js/widget/year/demo.year.js +++ b/demo/js/widget/year/demo.year.js @@ -6,12 +6,31 @@ Demo.Year = BI.inherit(BI.Widget, { baseCls: "demo-exceltable" }, render: function () { + var self = this; return { - type: "bi.horizontal_adapt", + type: "bi.horizontal_auto", items: [{ type: "bi.year_combo", + width: 300, + ref: function () { + self.yearcombo = this; + } + }, { + type: "bi.button", + text: "getValue", + handler: function () { + BI.Msg.toast(JSON.stringify(self.yearcombo.getValue())); + }, width: 300 - }] + }, { + type: "bi.button", + text: "setValue : 2018", + handler: function () { + self.yearcombo.setValue(2018); + }, + width: 300 + }], + vgap: 10 } } }) diff --git a/demo/js/widget/yearmonth/demo.year_month_combo.js b/demo/js/widget/yearmonth/demo.year_month_combo.js index 02ab8af65..2f864c74c 100644 --- a/demo/js/widget/yearmonth/demo.year_month_combo.js +++ b/demo/js/widget/yearmonth/demo.year_month_combo.js @@ -23,6 +23,16 @@ Demo.YearMonthCombo = BI.inherit(BI.Widget, { BI.Msg.toast(JSON.stringify(self.widget.getValue())) }, width: 300 + }, { + type: "bi.button", + text: "setVlaue '2017-12'", + width: 300, + handler: function () { + self.widget.setValue({ + year: 2017, + month: 11 + }) + } }], vgap: 20 } diff --git a/demo/js/widget/yearquarter/demo.year_quarter_combo.js b/demo/js/widget/yearquarter/demo.year_quarter_combo.js index ddd9cccf2..f57acce27 100644 --- a/demo/js/widget/yearquarter/demo.year_quarter_combo.js +++ b/demo/js/widget/yearquarter/demo.year_quarter_combo.js @@ -6,24 +6,34 @@ Demo.YearQuarterCombo = BI.inherit(BI.Widget, { baseCls: "" }, render: function () { - var self=this; + var self = this; return { type: "bi.horizontal_auto", items: [{ type: "bi.year_quarter_combo", width: 300, - ref:function(_ref){ - self.widget=_ref; + ref: function (_ref) { + self.widget = _ref; }, yearBehaviors: {}, quarterBehaviors: {}, }, { type: "bi.button", text: "getValue", - handler:function(){ + handler: function () { BI.Msg.toast(JSON.stringify(self.widget.getValue())) }, width: 300 + }, { + type: "bi.button", + text: "setVlaue '2017 季度3'", + width: 300, + handler: function () { + self.widget.setValue({ + year: 2017, + quarter: 3 + }) + } }], vgap: 20 } diff --git a/docs/demo.js b/docs/demo.js index c7fb87f11..6cc2630fe 100644 --- a/docs/demo.js +++ b/docs/demo.js @@ -3129,7 +3129,7 @@ BI.shortcut("demo.value_chooser_pane", Demo.ValueChooserPane);Demo.BASE_CONFIG = */ Demo.COMPONENT_CONFIG = [{ id: 5, - text: "部件" + text: "部件+服务" }, { pId: 5, text: "bi.value_chooser_combo", @@ -3589,14 +3589,14 @@ Demo.COMPONENT_CONFIG = [{ text: "bi.dialog", value: "demo.dialog" }, { - id: 7, - text: '数值微调器', - value: "demo.test_editor" + pId: 4, + id: 419, + text: '文件管理', }, { - id: 8, - text: '所有日期控件', - value: "demo.all_date_widget" - } + pId: 419, + text: "bi.file_manager", + value: "demo.file_manager" + }, ];Demo.Func = BI.inherit(BI.Widget, { props: { baseCls: "demo-func" @@ -6562,179 +6562,34 @@ Demo.Date = BI.inherit(BI.Widget, { }, render: function () { - + var self = this; return { type: "bi.horizontal_auto", vgap: 10, items: [{ type: "bi.date_combo", - width: 300 - }, { - type: "bi.date_picker", - width: 300 - }, { - type: "bi.date_trigger", - width: 300 - }, { - type: "bi.date_calendar_popup", - width: 300 - }, { - type: "bi.date_triangle_trigger", - width: 300 - }, { - type: "bi.calendar", - logic: { - dynamic: true - }, - width: 300 - }] - } - } -}) - -BI.shortcut("demo.all_date_widget", Demo.Date);/** - * Created by Dailer on 2017/7/18. - */ -Demo.TestEditor = BI.inherit(BI.Widget, { - props: { - baseCls: "" - }, - render: function () { - var editor = BI.createWidget({ - type: "bi.sign_editor", - cls: "bi-border", - width: 90, - height: 28, - }); - - var test = BI.createWidget({ - type: "bi.test_editor", - // formatter: function (v) { - // return v + "%"; - // }, - value: 12, - width: 90, - height: 28, - step: 1 - }); - - var timetunning = BI.createWidget({ - type: "bi.time_tunning", - currentTime: { - hour: 13, - minute: 45, - second: 50 - } - }); - - var dateTimeCombo = BI.createWidget({ - type: "bi.date_time_combo", - width: 300 - }); - - var enable = 1; - - return { - type: "bi.horizontal_auto", - items: [{ - el: test - }, - { - type: "bi.left", - items: [{ - el: editor - }, { - type: "bi.button", - text: "设置step", - width: 90, - height: 28, - handler: function () { - test.setStep(editor.getValue()); - BI.Msg.toast("设置成功") - }, - lgap: 5 - }, { - type: "bi.button", - text: "toggle disabled", - height: 28, - handler: function () { - enable *= -1; - test.setEnable(Boolean(1 + enable)); - BI.Msg.toast("设置成功") - }, - lgap: 20 - }] - }, - { - type: "bi.left", - items: [ - timetunning, - { - type: "bi.label", - text: "时间选择控件,自动进位与退位,返回数据自动对小于10的数补0", - whiteSpace: "normal", - cls: "layout-bg3", - height: 50, - width: 400, - lgap: 10 - } - ], - }, - { - type: "bi.left", - items: [{ - type: "bi.button", - text: "getCurrentTime", - cls: "layout-bg1", - handler: function () { - BI.Msg.alert("JSON 形式", JSON.stringify(timetunning.getCurrentTime())); - } - }, { - type: "bi.button", - text: "getCurrentTimeStr", - cls: "layout-bg1", - handler: function () { - BI.Msg.alert("字符串形式", timetunning.getCurrentTimeStr()); - } - }], - hgap: 10 + ref: function () { + self.datecombo = this; }, - { - type: "bi.left", - items: [dateTimeCombo] - } - ], - vgap: 20, - hgap: 10 - } - } -}); - -BI.shortcut("demo.test_editor", Demo.TestEditor);/** - * Created by Dailer on 2017/7/11. - */ -Demo.Date = BI.inherit(BI.Widget, { - props: { - baseCls: "demo-date" - }, - - _init: function () { - Demo.Date.superclass._init.apply(this, arguments); - }, - - render: function () { - - return { - type: "bi.horizontal_auto", - vgap: 10, - items: [{ - type: "bi.date_combo", width: 300 }, { type: "bi.button", text: "getVlaue", - height: 50, - width: 300 + width: 300, + handler: function () { + BI.Msg.alert("date", JSON.stringify(self.datecombo.getValue())); + } + }, { + type: "bi.button", + text: "setVlaue '2017-12-31'", + width: 300, + handler: function () { + self.datecombo.setValue({ + year: 2017, + month: 11, + day: 31 + }) + } }] } } @@ -6745,7 +6600,7 @@ BI.shortcut("demo.date", Demo.Date);Demo.DatePane = BI.inherit(BI.Widget, { baseCls: "demo-datepane" }, render: function () { - + var self = this; return { type: "bi.horizontal_auto", items: [{ @@ -6762,13 +6617,26 @@ BI.shortcut("demo.date", Demo.Date);Demo.DatePane = BI.inherit(BI.Widget, { month: 12, day: 11 }, - height:300 + ref: function (_ref) { + self.datepane = _ref; + }, + height: 300 }, { type: "bi.button", text: "getValue", handler: function () { - BI.Msg.toast("date" + JSON.stringify(datepane.getValue())); + BI.Msg.toast("date" + JSON.stringify(self.datepane.getValue())); + } + }, { + type: "bi.button", + text: "setVlaue '2017-12-31'", + handler: function () { + self.datepane.setValue({ + year: 2017, + month: 11, + day: 31 + }) } } ], @@ -7211,7 +7079,74 @@ Demo.TextEditor = BI.inherit(BI.Widget, { } }) -BI.shortcut("demo.text_editor", Demo.TextEditor);/** +BI.shortcut("demo.text_editor", Demo.TextEditor);/* 文件管理导航 + Created by dailer on 2017 / 7 / 21. + */ +Demo.FileManager = BI.inherit(BI.Widget, { + props: { + baseCls: "" + }, + + render: function () { + var items = [{ + id: "1", + value: "1", + text: "根目录", + lastModify: 1454316355142 + }, { + id: "11", + pId: "1", + value: "11", + text: "第一级子目录1", + lastModify: 1454316355142 + }, { + id: "12", + pId: "1", + value: "12", + text: "第一级子目录2", + lastModify: 1454316355142 + }, { + id: "111", + pId: "11", + value: "111", + text: "第二级子目录", + lastModify: 1454316355142 + }, { + id: "121", + pId: "111", + buildUrl: "www.baidu.com", + value: "121", + text: "文件1", + lastModify: 1454316355142 + }, { + id: "122", + pId: "111", + buildUrl: "www.baidu.com", + value: "122", + text: "文件2", + lastModify: 1454316355142 + }]; + var filemanager = BI.createWidget({ + type: "bi.file_manager", + items: items + }); + return { + type: "bi.vtape", + items: [{ + el: filemanager, + height: "fill" + }, { + type: "bi.button", + text: "getValue", + handler: function () { + BI.Msg.alert("", JSON.stringify(filemanager.getValue())); + }, + height: 25 + }] + } + } +}); +BI.shortcut("demo.file_manager", Demo.FileManager);/** * Created by Dailer on 2017/7/11. */ Demo.Month = BI.inherit(BI.Widget, { @@ -7219,13 +7154,35 @@ Demo.Month = BI.inherit(BI.Widget, { baseCls: "demo-exceltable" }, render: function () { + var self = this; return { - type: "bi.horizontal_adapt", + type: "bi.horizontal_auto", items: [{ type: "bi.month_combo", + width: 300, + ref: function () { + self.monthcombo = this; + } + }, { + type: "bi.button", + text: "getValue", + handler: function () { + BI.Msg.toast(JSON.stringify(self.monthcombo.getValue())); + }, width: 300 - }] - + }, { + type: "bi.button", + text: "setValue : 11", + handler: function () { + self.monthcombo.setValue(11); + }, + width: 300 + }, { + type: "bi.label", + text: "月份value 范围为0-11,显示范围为1-12", + width: 300 + }], + vgap: 10 } } }) @@ -8164,13 +8121,31 @@ Demo.Quarter = BI.inherit(BI.Widget, { baseCls: "demo-exceltable" }, render: function () { + var self = this; return { - type: "bi.horizontal_adapt", + type: "bi.horizontal_auto", items: [{ type: "bi.quarter_combo", + width: 300, + ref: function () { + self.quartercombo = this; + } + }, { + type: "bi.button", + text: "getValue", + handler: function () { + BI.Msg.toast(JSON.stringify(self.quartercombo.getValue())); + }, width: 300 - }] - + }, { + type: "bi.button", + text: "setValue : 3", + handler: function () { + self.quartercombo.setValue(3); + }, + width: 300 + }], + vgap: 10 } } }) @@ -9530,12 +9505,31 @@ Demo.Year = BI.inherit(BI.Widget, { baseCls: "demo-exceltable" }, render: function () { + var self = this; return { - type: "bi.horizontal_adapt", + type: "bi.horizontal_auto", items: [{ type: "bi.year_combo", + width: 300, + ref: function () { + self.yearcombo = this; + } + }, { + type: "bi.button", + text: "getValue", + handler: function () { + BI.Msg.toast(JSON.stringify(self.yearcombo.getValue())); + }, width: 300 - }] + }, { + type: "bi.button", + text: "setValue : 2018", + handler: function () { + self.yearcombo.setValue(2018); + }, + width: 300 + }], + vgap: 10 } } }) @@ -9565,6 +9559,16 @@ Demo.YearMonthCombo = BI.inherit(BI.Widget, { BI.Msg.toast(JSON.stringify(self.widget.getValue())) }, width: 300 + }, { + type: "bi.button", + text: "setVlaue '2017-12'", + width: 300, + handler: function () { + self.widget.setValue({ + year: 2017, + month: 11 + }) + } }], vgap: 20 } @@ -9579,24 +9583,34 @@ Demo.YearQuarterCombo = BI.inherit(BI.Widget, { baseCls: "" }, render: function () { - var self=this; + var self = this; return { type: "bi.horizontal_auto", items: [{ type: "bi.year_quarter_combo", width: 300, - ref:function(_ref){ - self.widget=_ref; + ref: function (_ref) { + self.widget = _ref; }, yearBehaviors: {}, quarterBehaviors: {}, }, { type: "bi.button", text: "getValue", - handler:function(){ + handler: function () { BI.Msg.toast(JSON.stringify(self.widget.getValue())) }, width: 300 + }, { + type: "bi.button", + text: "setVlaue '2017 季度3'", + width: 300, + handler: function () { + self.widget.setValue({ + year: 2017, + quarter: 3 + }) + } }], vgap: 20 } diff --git a/docs/widget.js b/docs/widget.js index e418ac9f0..5580c64d8 100644 --- a/docs/widget.js +++ b/docs/widget.js @@ -2360,7 +2360,7 @@ BI.DateTimeCombo = BI.inherit(BI.Widget, { o = this.options; this.trigger = BI.createWidget({ - type: "bi.date_trigger" + type: "bi.date_time_trigger1" }); this.trigger.on(BI.DateTrigger.EVENT_TRIGGER_CLICK, function () { @@ -2371,13 +2371,21 @@ BI.DateTimeCombo = BI.inherit(BI.Widget, { type: "bi.date_time_popup" }); - this.popup.on(BI.DateCalendarPopup.EVENT_CHANGE, function () { - self.setValue(self.popup.getValue()); + this.popup.on(BI.DateTimePopup.EVENT_CHANGE, function () { + //self.setValue(self.popup.getValue()); + }); + this.popup.on(BI.DateTimePopup.EVENT_CLICK_CONFIRM, function () { + //do something here + self.setValue(); + self.combo.hideView(); + }); + this.popup.on(BI.DateTimePopup.EVENT_CLICK_CANCEL, function () { + self.combo.hideView(); }); this.combo = BI.createWidget({ type: "bi.combo", - toggle: false, + toggle: true, element: this, isNeedAdjustHeight: false, isNeedAdjustWidth: false, @@ -2391,29 +2399,156 @@ BI.DateTimeCombo = BI.inherit(BI.Widget, { }, - _reviseMinute: function () { - this.m._finetuning(this.s.isNeedRevise); - this._reviseHour(); + getValue: function () { + return this.popup.getValue(); }, - _reviseHour: function () { - this.h._finetuning(this.m.isNeedRevise); + setStep: function (step) { + this.step = step || this.step; }, - getCurrentTime: function () { + setValue: function (v) { + this.trigger.setValue(this.popup.getValue()); + } + +}); +BI.DateTimeCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.shortcut("bi.date_time_combo", BI.DateTimeCombo);/** + * Created by dailer on 2017/7/18. + * 数值微调器练习 + */ +BI.NumberSpinner = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.NumberSpinner.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-fine-tuning-number-editor bi-border", + value: 0, + min: 0, + max: 100000, + step: 1, + formatter: BI.emptyFn, + parser: BI.emptyFn + }) + }, + + _init: function () { + BI.NumberSpinner.superclass._init.apply(this, arguments); + var self = this, + o = this.options; + if (o.formatter == BI.emptyFn) { + this.formatter = function (v) { + return v; + } + } else { + this.formatter = o.formatter; + } + + this.parser = o.parser; + this.step = o.step; + this.min = o.min; + this.max = o.max; + this.value = o.value; + this.isNeedRevise = 0; + + this.editor = BI.createWidget({ + type: "bi.sign_editor", + value: o.value, + errorText: BI.i18nText("BI-Please_Input_Natural_Number") + }); + this.editor.on(BI.TextEditor.EVENT_CONFIRM, function () { + self.setValue(self.editor.getValue()); + self.fireEvent(BI.NumberSpinner.EVENT_CONFIRM); + }); + + + this.topBtn = BI.createWidget({ + type: "bi.icon_button", + trigger: "lclick,", + cls: "column-pre-page-h-font top-button bi-border-left bi-border-bottom", + }); + this.topBtn.on(BI.IconButton.EVENT_CHANGE, function () { + + self._finetuning(1); + + self.fireEvent(BI.NumberSpinner.EVENT_CONFIRM); + }); + + this.bottomBtn = BI.createWidget({ + type: "bi.icon_button", + trigger: "lclick,", + cls: "column-next-page-h-font bottom-button bi-border-left bi-border-top" + }); + this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function () { + self._finetuning(-1); + self.fireEvent(BI.NumberSpinner.EVENT_CONFIRM); + }); + + this._finetuning(0); + + BI.createWidget({ + type: "bi.htape", + element: this, + items: [this.editor, { + el: { + type: "bi.grid", + columns: 1, + rows: 2, + items: [{ + column: 0, + row: 0, + el: this.topBtn + }, { + column: 0, + row: 1, + el: this.bottomBtn + }] + }, + width: 30 + }] + }); + }, + + //微调 + _finetuning: function (add) { + //窝是在不值该如何处理精度损失问题,所以迫不得已采取了这个方法 + var v = BI.parseFloat(this.editor.getValue()) * 1000000000000; + var addend = add * this.step * 1000000000000; + var result = (v + addend) / 1000000000000; + + if (result > this.max) { + this.editor.setValue(this.formatter(this.min)); + this.isNeedRevise = 1; + this.value = this.min; + return; + } + if (result < this.min) { + this.editor.setValue(this.formatter(this.max)); + this.isNeedRevise = -1; + this.value = this.max; + return; + } + this.value = result; + this.isNeedRevise = 0; + this.editor.setValue(this.formatter(result)); + + }, + + getIsNeedRevise: function () { + return this.isNeedRevise; + }, + + getMinAndMax: function () { return { - hour: this.h.getValue(), - minute: this.m.getValue(), - second: this.s.getValue() + min: this.min, + max: this.max }; }, - _format: function (p) { - return p < 10 ? ('0' + p) : p + getStep: function () { + return this.step; }, - getCurrentTimeStr: function () { - return this._format(this.h.getValue()) + ':' + this._format(this.m.getValue()) + ':' + this._format(this.s.getValue()) + getValue: function () { + return this.value; }, setStep: function (step) { @@ -2421,12 +2556,13 @@ BI.DateTimeCombo = BI.inherit(BI.Widget, { }, setValue: function (v) { - + this.value = v; + this.editor.setValue(this.formatter(v)); } }); -BI.DateTimeCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.shortcut("bi.date_time_combo", BI.DateTimeCombo);/** +BI.NumberSpinner.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.shortcut("bi.test_editor", BI.NumberSpinner);/** * Created by GUY on 2015/9/7. * @class BI.DateCalendarPopup * @extends BI.Widget @@ -2435,7 +2571,7 @@ BI.DateTimePopup = BI.inherit(BI.Widget, { _defaultConfig: function () { var conf = BI.DateTimePopup.superclass._defaultConfig.apply(this, arguments); return BI.extend(conf, { - baseCls: "bi-date-calendar-popup", + baseCls: "bi-date-calendar-popup demo-clolor", min: '1900-01-01', //最小日期 max: '2099-12-31', //最大日期 selectedTime: null @@ -2466,16 +2602,23 @@ BI.DateTimePopup = BI.inherit(BI.Widget, { this._year = this.today.getFullYear(); this._month = this.today.getMonth(); this._day = this.today.getDate(); + this._hour = this.today.getHours(); + this._minute = this.today.getMinutes(); + this._second = this.today.getSeconds(); this.selectedTime = o.selectedTime || { year: this._year, month: this._month, - day: this._day + day: this._day, + hour: this._hour, + minute: this._minute, + second: this._second }; this.datePicker = BI.createWidget({ type: "bi.date_picker", min: o.min, - max: o.max + max: o.max, + cls: "demo-clolor", }); this.calendar = BI.createWidget({ @@ -2494,21 +2637,42 @@ BI.DateTimePopup = BI.inherit(BI.Widget, { afterCardShow: function () { this.setValue(self.selectedTime); + self.calendar.setSelect(BI.Calendar.getPageByDateJSON(self.selectedTime)); } }); this.timeTunning = BI.createWidget({ - type: "bi.time_tunning" + type: "bi.time_tunning", + currentTime: { + hour: this._hour, + minute: this._minute, + second: this._second + } + }); + this.timeTunning.on(BI.TimeTuning.EVENT_CHANGE, function () { + self.selectedTime = self.timeTunning.getValue(); }); this.buttons = BI.createWidget({ type: "bi.button_group", items: [{ - type: "bi.text_button", - text: BI.i18nText('BI-Basic_Clears') + type: "bi.button", + textHeight: 30, + clear: true, + text: "取消", + handler: function () { + self.fireEvent(BI.DateTimePopup.EVENT_CLICK_CANCEL); + } + }, { + text: "|" }, { - type: "bi.text_button", - text: BI.i18nText("BI-Basic_Sure") + type: "bi.button", + textHeight: 30, + clear: true, + text: BI.i18nText("BI-Basic_Sure"), + handler: function () { + self.fireEvent(BI.DateTimePopup.EVENT_CLICK_CONFIRM); + } }], chooseType: 0, behaviors: {}, @@ -2531,23 +2695,28 @@ BI.DateTimePopup = BI.inherit(BI.Widget, { this.calendar.on(BI.Navigation.EVENT_CHANGE, function () { self.selectedTime = self.calendar.getValue(); - self.setValue(self.selectedTime); - self.fireEvent(BI.DateCalendarPopup.EVENT_CHANGE); + self.fireEvent(BI.DateTimePopup.EVENT_CHANGE); }); + + self.calendar.setSelect(BI.Calendar.getPageByDateJSON(self.selectedTime)); + this.calendar.setValue(this.selectedTime); }, setValue: function (timeOb) { this.datePicker.setValue(timeOb); this.calendar.setSelect(BI.Calendar.getPageByDateJSON(timeOb)); this.calendar.setValue(timeOb); + this.timeTunning.setValue(timeOb); this.selectedTime = timeOb; }, getValue: function () { - return this.selectedTime; + return $.extend({}, this.calendar.getValue(), this.timeTunning.getValue()); } }); BI.DateTimePopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.DateTimePopup.EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM"; +BI.DateTimePopup.EVENT_CLICK_CANCEL = "EVENT_CLICK_CANCEL"; BI.shortcut("bi.date_time_popup", BI.DateTimePopup);/** * Created by dailer on 2017/7/19. * 时间微调器练习 @@ -2599,7 +2768,9 @@ BI.TimeTuning = BI.inherit(BI.Widget, { width: 60, height: 30 }); - this.h.on(BI.FineTuningNumberEditor.EVENT_CONFIRM, function () {}); + this.h.on(BI.FineTuningNumberEditor.EVENT_CONFIRM, function () { + self.fireEvent(BI.TimeTuning.EVENT_CHANGE); + }); //分 this.m = BI.createWidget({ @@ -2612,6 +2783,7 @@ BI.TimeTuning = BI.inherit(BI.Widget, { }) this.m.on(BI.FineTuningNumberEditor.EVENT_CONFIRM, function () { self._reviseHour(); + self.fireEvent(BI.TimeTuning.EVENT_CHANGE); }); //秒 @@ -2625,6 +2797,7 @@ BI.TimeTuning = BI.inherit(BI.Widget, { }) this.s.on(BI.FineTuningNumberEditor.EVENT_CONFIRM, function () { self._reviseMinute(); + self.fireEvent(BI.TimeTuning.EVENT_CHANGE); }); @@ -2657,7 +2830,7 @@ BI.TimeTuning = BI.inherit(BI.Widget, { BI.createWidget({ type: "bi.htape", - cls: "bi-border demo-clolor", + cls: "demo-clolor", element: this, items: [this.editor], width: 270, @@ -2666,12 +2839,12 @@ BI.TimeTuning = BI.inherit(BI.Widget, { }, _reviseMinute: function () { - this.m._finetuning(this.s.isNeedRevise); + this.m._finetuning(this.s.getIsNeedRevise()); this._reviseHour(); }, _reviseHour: function () { - this.h._finetuning(this.m.isNeedRevise); + this.h._finetuning(this.m.getIsNeedRevise()); }, getCurrentTime: function () { @@ -2690,169 +2863,97 @@ BI.TimeTuning = BI.inherit(BI.Widget, { return this._format(this.h.getValue()) + ':' + this._format(this.m.getValue()) + ':' + this._format(this.s.getValue()) }, + getValue: function () { + return { + hour: this.h.getValue(), + minute: this.m.getValue(), + second: this.s.getValue() + } + }, + setStep: function (step) { this.step = step || this.step; }, - setValue: function (v) { - this.value = v; - this.editor.setValue(); + setValue: function (timeObj) { + this.h.setValue(timeObj.hour); + this.m.setValue(timeObj.minute); + this.s.setValue(timeObj.second); } }); -BI.TimeTuning.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.shortcut("bi.time_tunning", BI.TimeTuning);/** - * Created by dailer on 2017/7/18. - * 数值微调器练习 - */ -BI.FineTuningNumberEditor = BI.inherit(BI.Widget, { +BI.TimeTuning.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.time_tunning", BI.TimeTuning);BI.DateTimeTrigger = BI.inherit(BI.Trigger, { + _defaultConfig: function () { - return BI.extend(BI.FineTuningNumberEditor.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-fine-tuning-number-editor bi-border", - value: 0, - disabled: false, - min: 0, - max: 100000, - step: 1, - formatter: BI.emptyFn, - parser: BI.emptyFn - }) + return BI.extend(BI.DateTimeTrigger.superclass._defaultConfig.apply(this, arguments), { + extraCls: "bi-date-trigger", + min: '1900-01-01', //最小日期 + max: '2099-12-31', //最大日期 + height: 32 + }); }, - _init: function () { - BI.FineTuningNumberEditor.superclass._init.apply(this, arguments); + BI.DateTimeTrigger.superclass._init.apply(this, arguments); var self = this, o = this.options; - if (o.formatter == BI.emptyFn) { - this.formatter = function (v) { - return v; - } - } else { - this.formatter = o.formatter; - } - - this.parser = o.parser; - this.step = o.step; - this.min = o.min; - this.max = o.max; - this.value = o.value; - this.isNeedRevise = 0; - - this.editor = BI.createWidget({ - type: "bi.sign_editor", - value: o.value, - errorText: BI.i18nText("BI-Please_Input_Natural_Number") - }); - this.editor.on(BI.TextEditor.EVENT_CONFIRM, function () { - self.setValue(self.editor.getValue()); - self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM); - }); - - - this.topBtn = BI.createWidget({ - type: "bi.icon_button", - trigger: "lclick,", - cls: "column-pre-page-h-font top-button bi-border-left bi-border-bottom", - }); - this.topBtn.on(BI.IconButton.EVENT_CHANGE, function () { - self._isNeedRevise(); - - self._finetuning(1); - - self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM); - }); - - this.bottomBtn = BI.createWidget({ - type: "bi.icon_button", - trigger: "lclick,", - cls: "column-next-page-h-font bottom-button bi-border-left bi-border-top" - }); - this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function () { - self._finetuning(-1); - self.fireEvent(BI.FineTuningNumberEditor.EVENT_CONFIRM); + this.label = BI.createWidget({ + type: "bi.label", + textAlign: "left", + text: "", + height: o.height }); - this._finetuning(0); - BI.createWidget({ type: "bi.htape", element: this, - items: [this.editor, { - el: { - type: "bi.grid", - columns: 1, - rows: 2, - items: [{ - column: 0, - row: 0, - el: this.topBtn - }, { - column: 0, - row: 1, - el: this.bottomBtn - }] - }, + items: [{ + el: BI.createWidget({ + type: "bi.icon_button", + cls: "search-font" + }), width: 30 + }, { + el: this.label }] - }); - }, - - //微调 - _finetuning: function (add) { - //窝是在不值该如何处理精度损失问题,所以迫不得已采取了这个方法 - var v = BI.parseFloat(this.editor.getValue()) * 1000000000000; - var addend = add * this.step * 1000000000000; - var result = (v + addend) / 1000000000000; - - if (result > this.max) { - this.editor.setValue(this.formatter(this.min)); - this.isNeedRevise = 1; - this.value = this.min; - return; - } - if (result < this.min) { - this.editor.setValue(this.formatter(this.max)); - this.isNeedRevise = -1; - this.value = this.max; - return; - } - this.value = result; - this.isNeedRevise = 0; - this.editor.setValue(this.formatter(result)); + }) + var today = new Date(), + timeObj = { + year: today.getFullYear(), + month: today.getMonth(), + day: today.getDate(), + hour: today.getHours(), + minute: today.getMinutes(), + second: today.getSeconds() + }; + this.setValue(timeObj); }, - _isNeedRevise: function () { - // console.log(this.editor.getValue() - this.value); - }, - getMinAndMax: function () { - return { - min: this.min, - max: this.max + + _parseTimeObjToStr: function (timeObj) { + var _format = function (p) { + return p < 10 ? ('0' + p) : p }; + BI.each(timeObj, function (key, val) { + timeObj[key] = _format(timeObj[key]); + }); + return timeObj.year + "-" + (1 + BI.parseInt(timeObj.month)) + "-" + timeObj.day + " " + timeObj.hour + ":" + timeObj.minute + ":" + timeObj.second; }, - getStep: function () { - return this.step; - }, + setValue: function (v) { + this.label.setValue(this._parseTimeObjToStr(v)); - getValue: function () { - return this.value; }, - setStep: function (step) { - this.step = step || this.step; - }, + getValue: function () { - setValue: function (v) { - this.value = v; - this.editor.setValue(this.formatter(v)); } }); -BI.FineTuningNumberEditor.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.shortcut("bi.test_editor", BI.FineTuningNumberEditor);/** + +BI.shortcut("bi.date_time_trigger1", BI.DateTimeTrigger);/** * 日期控件中的月份下拉框 * * Created by GUY on 2015/9/7.