|
|
|
@ -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. |
|
|
|
|