Browse Source

BI-6615 need fix

es6
刘荣歆 8 years ago
parent
commit
622fd07c9e
  1. 620
      bi/widget.js
  2. 6
      demo/js/config/widget.js
  3. 5
      demo/js/widget/demo.datetime.js
  4. 125
      demo/js/widget/multidatetime/multi.datetime.combo.js
  5. 38
      demo/js/widget/multidatetime/multi.datetime.js
  6. 177
      demo/js/widget/multidatetime/multi.datetime.popup.js
  7. 106
      demo/js/widget/multidatetime/multi.datetime.select.js
  8. 63
      demo/js/widget/multidatetime/multi.datetime.trigger.js
  9. 523
      docs/demo.js
  10. 620
      docs/widget.js
  11. 81
      src/widget/dailertest/combo.date.time.js
  12. 150
      src/widget/dailertest/number.spinner.js
  13. 156
      src/widget/dailertest/popup.date.time.js
  14. 167
      src/widget/dailertest/time.spinner.js
  15. 71
      src/widget/dailertest/trigger.date.time.js

620
bi/widget.js

@ -2334,626 +2334,6 @@ BI.BranchRelation = BI.inherit(BI.Widget, {
}); });
BI.BranchRelation.EVENT_CHANGE = "BranchRelation.EVENT_CHANGE"; BI.BranchRelation.EVENT_CHANGE = "BranchRelation.EVENT_CHANGE";
BI.shortcut("bi.branch_relation", BI.BranchRelation);/** BI.shortcut("bi.branch_relation", BI.BranchRelation);/**
* Created by dailer on 2017/7/19.
* 日期时间练习
*/
BI.DateTimeCombo = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.TimeTuning.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-fine-tuning-number-editor bi-border",
selectedTime: {
year: 2017,
month: 0,
day: 1,
hour: 0,
minute: 0,
second: 0
},
height: 30
})
},
_init: function () {
BI.DateCombo.superclass._init.apply(this, arguments);
var self = this,
o = this.options;
this.trigger = BI.createWidget({
type: "bi.date_time_trigger1"
});
this.trigger.on(BI.DateTrigger.EVENT_TRIGGER_CLICK, function () {
self.combo.toggle();
});
this.popup = BI.createWidget({
type: "bi.date_time_popup"
});
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: true,
element: this,
isNeedAdjustHeight: false,
isNeedAdjustWidth: false,
el: this.trigger,
popup: {
width: 270,
el: this.popup,
stopPropagation: false
}
})
},
getValue: function () {
return this.popup.getValue();
},
setStep: function (step) {
this.step = step || this.step;
},
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 {
min: this.min,
max: this.max
};
},
getStep: function () {
return this.step;
},
getValue: function () {
return this.value;
},
setStep: function (step) {
this.step = step || this.step;
},
setValue: function (v) {
this.value = v;
this.editor.setValue(this.formatter(v));
}
});
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
*/
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 demo-clolor",
min: '1900-01-01', //最小日期
max: '2099-12-31', //最大日期
selectedTime: null
})
},
_createNav: function (v) {
var date = BI.Calendar.getDateJSONByPage(v);
var calendar = BI.createWidget({
type: "bi.calendar",
logic: {
dynamic: true
},
min: this.options.min,
max: this.options.max,
year: date.year,
month: date.month,
day: this.selectedTime.day
});
return calendar
},
_init: function () {
BI.DateTimePopup.superclass._init.apply(this, arguments);
var self = this,
o = this.options;
this.today = new Date();
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,
hour: this._hour,
minute: this._minute,
second: this._second
};
this.datePicker = BI.createWidget({
type: "bi.date_picker",
min: o.min,
max: o.max,
cls: "demo-clolor",
});
this.calendar = BI.createWidget({
direction: "top",
// element: this,
logic: {
dynamic: true
},
type: "bi.navigation",
tab: this.datePicker,
cardCreator: BI.bind(this._createNav, this),
afterCardCreated: function () {
},
afterCardShow: function () {
this.setValue(self.selectedTime);
self.calendar.setSelect(BI.Calendar.getPageByDateJSON(self.selectedTime));
}
});
this.timeTunning = BI.createWidget({
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.button",
textHeight: 30,
clear: true,
text: "取消",
handler: function () {
self.fireEvent(BI.DateTimePopup.EVENT_CLICK_CANCEL);
}
}, {
text: "|"
}, {
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: {},
layouts: [{
type: "bi.center_adapt"
}]
});
this.dateTime = BI.createWidget({
type: "bi.vertical",
element: this,
items: [this.calendar, this.timeTunning, this.buttons]
});
this.datePicker.on(BI.DatePicker.EVENT_CHANGE, function () {
self.selectedTime = self.datePicker.getValue();
self.selectedTime.day = 1;
self.calendar.setSelect(BI.Calendar.getPageByDateJSON(self.selectedTime));
});
this.calendar.on(BI.Navigation.EVENT_CHANGE, function () {
self.selectedTime = self.calendar.getValue();
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 $.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.
* 时间微调器练习
*/
BI.TimeTuning = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.TimeTuning.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-fine-tuning-number-editor bi-border",
disabled: false,
currentTime: {
hour: 0,
minute: 0,
second: 0
}
})
},
_init: function () {
BI.TimeTuning.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.currentTime = BI.deepClone(o.currentTime);
this.last = {
lastH: o.currentTime.hour,
lastM: o.currentTime.minute,
lastS: o.currentTime.second
}
//时
this.h = BI.createWidget({
type: "bi.test_editor",
value: this.currentTime.hour,
min: 0,
max: 23,
width: 60,
height: 30
});
this.h.on(BI.FineTuningNumberEditor.EVENT_CONFIRM, function () {
self.fireEvent(BI.TimeTuning.EVENT_CHANGE);
});
//分
this.m = BI.createWidget({
type: "bi.test_editor",
value: this.currentTime.minute,
min: 0,
max: 59,
width: 60,
height: 30
})
this.m.on(BI.FineTuningNumberEditor.EVENT_CONFIRM, function () {
self._reviseHour();
self.fireEvent(BI.TimeTuning.EVENT_CHANGE);
});
//秒
this.s = BI.createWidget({
type: "bi.test_editor",
value: this.currentTime.second,
min: 0,
max: 59,
width: 60,
height: 30
})
this.s.on(BI.FineTuningNumberEditor.EVENT_CONFIRM, function () {
self._reviseMinute();
self.fireEvent(BI.TimeTuning.EVENT_CHANGE);
});
this.editor = BI.createWidget({
type: "bi.horizontal",
items: [{
type: "bi.label",
text: "时间",
width: 45,
height: 30
},
this.h,
{
type: "bi.text",
text: ":",
textAlign: "center",
width: 15
},
this.m,
{
type: "bi.text",
text: ":",
textAlign: "center",
width: 15
},
this.s
]
});
BI.createWidget({
type: "bi.htape",
cls: "demo-clolor",
element: this,
items: [this.editor],
width: 270,
height: 50
});
},
_reviseMinute: function () {
this.m._finetuning(this.s.getIsNeedRevise());
this._reviseHour();
},
_reviseHour: function () {
this.h._finetuning(this.m.getIsNeedRevise());
},
getCurrentTime: function () {
return {
hour: this.h.getValue(),
minute: this.m.getValue(),
second: this.s.getValue()
};
},
_format: function (p) {
return p < 10 ? ('0' + p) : p
},
getCurrentTimeStr: function () {
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 (timeObj) {
this.h.setValue(timeObj.hour);
this.m.setValue(timeObj.minute);
this.s.setValue(timeObj.second);
}
});
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.DateTimeTrigger.superclass._defaultConfig.apply(this, arguments), {
extraCls: "bi-date-trigger",
min: '1900-01-01', //最小日期
max: '2099-12-31', //最大日期
height: 32
});
},
_init: function () {
BI.DateTimeTrigger.superclass._init.apply(this, arguments);
var self = this,
o = this.options;
this.label = BI.createWidget({
type: "bi.label",
textAlign: "left",
text: "",
height: o.height
});
BI.createWidget({
type: "bi.htape",
element: this,
items: [{
el: BI.createWidget({
type: "bi.icon_button",
cls: "search-font"
}),
width: 30
}, {
el: this.label
}]
})
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);
},
_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;
},
setValue: function (v) {
this.label.setValue(this._parseTimeObjToStr(v));
},
getValue: function () {
}
});
BI.shortcut("bi.date_time_trigger1", BI.DateTimeTrigger);/**
* 日期控件中的月份下拉框 * 日期控件中的月份下拉框
* *
* Created by GUY on 2015/9/7. * Created by GUY on 2015/9/7.

6
demo/js/config/widget.js

@ -181,15 +181,15 @@ Demo.WIDGET_CONFIG = [{
pId: 412, pId: 412,
text: "bi.year_month_combo", text: "bi.year_month_combo",
value: "demo.year_month_combo" value: "demo.year_month_combo"
},{ }, {
pId: 412, pId: 412,
text: "bi.year_quarter_combo", text: "bi.year_quarter_combo",
value: "demo.year_quarter_combo" value: "demo.year_quarter_combo"
},{ }, {
pId: 412, pId: 412,
text: "bi.custom_date_time", text: "bi.custom_date_time",
value: "demo.custom_date_time" value: "demo.custom_date_time"
},{ }, {
pId: 4, pId: 4,
id: 413, id: 413,
text: "简单下拉树" text: "简单下拉树"

5
demo/js/widget/demo.datetime.js

@ -2,8 +2,7 @@
* Created by Urthur on 2017/7/18. * Created by Urthur on 2017/7/18.
*/ */
Demo.CustomDateTime = BI.inherit(BI.Widget, { Demo.CustomDateTime = BI.inherit(BI.Widget, {
props: { props: {},
},
render: function () { render: function () {
var self = this; var self = this;
return { return {
@ -12,7 +11,7 @@ Demo.CustomDateTime = BI.inherit(BI.Widget, {
el: { el: {
type: "bi.custom_date_time_combo", type: "bi.custom_date_time_combo",
ref: function (_ref) { ref: function (_ref) {
self.customDateTime = _ref; self.customDateTime = _ref;
self.customDateTime.on(BI.CustomDateTimeCombo.EVENT_CONFIRM, function () { self.customDateTime.on(BI.CustomDateTimeCombo.EVENT_CONFIRM, function () {
BI.Msg.alert("日期", this.getValue().text); BI.Msg.alert("日期", this.getValue().text);
}); });

125
demo/js/widget/multidatetime/multi.datetime.combo.js

@ -1,125 +0,0 @@
/**
* Created by Urthur on 2017/7/14.
*/
BI.MultiDateTimeCombo = BI.inherit(BI.Single, {
constants: {
popupHeight: 290,
popupWidth: 270,
comboAdjustHeight: 1,
border: 1,
DATE_MIN_VALUE: "1900-01-01",
DATE_MAX_VALUE: "2099-12-31"
},
_defaultConfig: function () {
return BI.extend(BI.MultiDateTimeCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: 'bi-multi-date-time-combo bi-border',
height: 24
});
},
_init: function () {
BI.MultiDateTimeCombo.superclass._init.apply(this, arguments);
var self = this, opts = this.options;
var date = new Date();
this.storeValue = {
value: {
year: date.getFullYear(),
month: date.getMonth(),
day: date.getDate(),
hour: date.getHours(),
minute: date.getMinutes(),
second: date.getSeconds()
}
};
this.trigger = BI.createWidget({
type: 'bi.date_time_trigger',
min: this.constants.DATE_MIN_VALUE,
max: this.constants.DATE_MAX_VALUE
});
this.popup = BI.createWidget({
type: "bi.multi_date_time_popup",
min: this.constants.DATE_MIN_VALUE,
max: this.constants.DATE_MAX_VALUE
});
self.setValue(this.storeValue);
this.popup.on(BI.MultiDateTimePopup.BUTTON_CANCEL_EVENT_CHANGE, function () {
self.combo.hideView();
self.fireEvent(BI.MultiDateTimeCombo.EVENT_CANCEL);
});
this.popup.on(BI.MultiDateTimePopup.BUTTON_OK_EVENT_CHANGE, function () {
self.setValue(self.popup.getValue());
self.combo.hideView();
self.fireEvent(BI.MultiDateTimeCombo.EVENT_CONFIRM);
});
this.popup.on(BI.MultiDateTimePopup.CALENDAR_EVENT_CHANGE, function () {
self.setValue(self.popup.getValue());
});
this.combo = BI.createWidget({
type: 'bi.combo',
toggle: false,
isNeedAdjustHeight: false,
isNeedAdjustWidth: false,
el: this.trigger,
adjustLength: this.constants.comboAdjustHeight,
popup: {
el: this.popup,
maxHeight: this.constants.popupHeight,
width: this.constants.popupWidth,
stopPropagation: false
}
});
this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
self.popup.setValue(self.storeValue);
self.fireEvent(BI.MultiDateTimeCombo.EVENT_BEFORE_POPUPVIEW);
});
var triggerBtn = BI.createWidget({
type: "bi.trigger_icon_button",
cls: "bi-trigger-date-button chart-date-normal-font bi-border-right",
width: 30,
height: 24
});
triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () {
if (self.combo.isViewVisible()) {
self.combo.hideView();
} else {
self.combo.showView();
}
});
BI.createWidget({
type: "bi.htape",
element: this,
items: [{
type: "bi.absolute",
items: [{
el: this.combo,
top: 0,
left: 0,
right: 0,
bottom: 0
}, {
el: triggerBtn,
top: 0,
left: 0
}]
}]
})
},
setValue: function (v) {
this.storeValue = v;
this.popup.setValue(v);
this.trigger.setValue(v);
},
getValue: function () {
return this.storeValue;
}
});
BI.MultiDateTimeCombo.EVENT_CANCEL = "EVENT_CANCEL";
BI.MultiDateTimeCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.MultiDateTimeCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.MultiDateTimeCombo.EVENT_BEFORE_POPUPVIEW = "BI.MultiDateTimeCombo.EVENT_BEFORE_POPUPVIEW";
BI.shortcut('bi.multi_date_time_combo', BI.MultiDateTimeCombo);

38
demo/js/widget/multidatetime/multi.datetime.js

@ -1,38 +0,0 @@
/**
* Created by Urthur on 2017/7/14.
*/
BI.CustomMultiDateTimeCombo = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.CustomMultiDateTimeCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-custom-multi-date-time-combo"
})
},
_init: function () {
BI.CustomMultiDateTimeCombo.superclass._init.apply(this, arguments);
var self = this;
this.multiDateTime = BI.createWidget({
type: "bi.multi_date_time_combo",
element: this
});
this.multiDateTime.on(BI.MultiDateTimeCombo.EVENT_CANCEL, function () {
self.fireEvent(BI.CustomMultiDateTimeCombo.EVENT_CANCEL);
});
this.multiDateTime.on(BI.MultiDateTimeCombo.EVENT_CONFIRM, function () {
self.fireEvent(BI.CustomMultiDateTimeCombo.EVENT_CONFIRM);
});
},
getValue: function () {
return this.multiDateTime.getValue();
},
setValue: function (v) {
this.multiDateTime.setValue(v);
}
});
BI.CustomMultiDateTimeCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.CustomMultiDateTimeCombo.EVENT_CANCEL = "EVENT_CANCEL";
BI.CustomMultiDateTimeCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.custom_multi_date_time_combo", BI.CustomMultiDateTimeCombo);

177
demo/js/widget/multidatetime/multi.datetime.popup.js

@ -1,177 +0,0 @@
/**
* Created by Urthur on 2017/7/14.
*/
BI.MultiDateTimePopup = BI.inherit(BI.Widget, {
constants: {
tabHeight: 30,
tabWidth: 42,
titleHeight: 27,
itemHeight: 30,
triggerHeight: 24,
buttonWidth: 90,
buttonHeight: 25,
popupHeight: 290,
popupWidth: 270,
comboAdjustHeight: 1,
lgap: 2,
border: 1
},
_defaultConfig: function () {
return BI.extend(BI.MultiDateTimePopup.superclass._defaultConfig.apply(this, arguments), {
baseCls: 'bi-multi-date-time-popup',
width: 268,
height: 290
});
},
_init: function () {
BI.MultiDateTimePopup.superclass._init.apply(this, arguments);
var self = this, opts = this.options;
this.cancelButton = BI.createWidget({
type: 'bi.text_button',
forceCenter: true,
cls: 'bi-multidate-popup-button bi-border-top bi-border-right',
shadow: true,
text: BI.i18nText("BI-Basic_Cancel")
});
this.cancelButton.on(BI.TextButton.EVENT_CHANGE, function () {
self.fireEvent(BI.MultiDateTimePopup.BUTTON_CANCEL_EVENT_CHANGE);
});
this.okButton = BI.createWidget({
type: "bi.text_button",
forceCenter: true,
cls: 'bi-multidate-popup-button bi-border-top',
shadow: true,
text: BI.i18nText("BI-Basic_OK")
});
this.okButton.on(BI.TextButton.EVENT_CHANGE, function () {
self.fireEvent(BI.MultiDateTimePopup.BUTTON_OK_EVENT_CHANGE);
});
this.dateCombo = BI.createWidget({
type: "bi.date_calendar_popup",
min: self.options.min,
max: self.options.max
});
self.dateCombo.on(BI.DateCalendarPopup.EVENT_CHANGE, function () {
self.fireEvent(BI.MultiDateTimePopup.CALENDAR_EVENT_CHANGE);
});
this.dateSelect = BI.createWidget({
type: "bi.horizontal",
cls: "bi-border-top",
items: [{
type: "bi.label",
text: BI.i18nText("BI-Basic_Time"),
width: 45
},{
type: "bi.multi_date_time_select",
max: 23,
min: 0,
width: 60,
height: 30,
ref: function (_ref) {
self.hour = _ref;
self.hour.on(BI.MultiDateTimeSelect.EVENT_CONFIRM, function () {
self.fireEvent(BI.MultiDateTimePopup.CALENDAR_EVENT_CHANGE);
});
}
},{
type: "bi.label",
text: ":",
width: 15
},{
type: "bi.multi_date_time_select",
max: 59,
min: 0,
width: 60,
height: 30,
ref: function (_ref) {
self.minute = _ref;
self.minute.on(BI.MultiDateTimeSelect.EVENT_CONFIRM, function () {
self.fireEvent(BI.MultiDateTimePopup.CALENDAR_EVENT_CHANGE);
});
}
},{
type: "bi.label",
text: ":",
width: 15
},{
type: "bi.multi_date_time_select",
max: 59,
min: 0,
width: 60,
height: 30,
ref: function (_ref) {
self.second = _ref;
self.second.on(BI.MultiDateTimeSelect.EVENT_CONFIRM, function () {
self.fireEvent(BI.MultiDateTimePopup.CALENDAR_EVENT_CHANGE);
});
}
}]
});
this.dateButton = BI.createWidget({
type: "bi.grid",
items: [[this.cancelButton, this.okButton]]
});
BI.createWidget({
element: this,
type: "bi.vtape",
items: [{
el: this.dateCombo
}, {
el: this.dateSelect,
height: 50
},{
el: this.dateButton,
height: 30
}]
});
},
setValue: function (v) {
var value, date;
if (BI.isNotNull(v)) {
value = v.value;
if(BI.isNull(value)){
date = new Date();
this.dateCombo.setValue({
year: date.getFullYear(),
month: date.getMonth(),
day: date.getDate()
});
this.hour.setValue(date.getHours());
this.minute.setValue(date.getMinutes());
this.second.setValue(date.getSeconds());
} else {
this.dateCombo.setValue({
year: value.year,
month: value.month,
day: value.day
});
this.hour.setValue(value.hour);
this.minute.setValue(value.minute);
this.second.setValue(value.second);
}
}
},
getValue: function () {
return {
value: {
year: this.dateCombo.getValue().year,
month: this.dateCombo.getValue().month,
day: this.dateCombo.getValue().day,
hour: this.hour.getValue(),
minute: this.minute.getValue(),
second: this.second.getValue()
}
}
}
});
BI.MultiDateTimePopup.BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE";
BI.MultiDateTimePopup.BUTTON_CANCEL_EVENT_CHANGE = "BUTTON_CANCEL_EVENT_CHANGE";
BI.MultiDateTimePopup.CALENDAR_EVENT_CHANGE = "CALENDAR_EVENT_CHANGE";
BI.shortcut('bi.multi_date_time_popup', BI.MultiDateTimePopup);

106
demo/js/widget/multidatetime/multi.datetime.select.js

@ -1,106 +0,0 @@
/**
* Created by Urthur on 2017/7/14.
*/
BI.MultiDateTimeSelect = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.MultiDateTimeSelect.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-multi-date-time-select bi-border",
max: 23,
min: 0
})
},
_init: function () {
BI.MultiDateTimeSelect.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.editor = BI.createWidget({
type: "bi.sign_editor",
value: this._alertInEditorValue(o.min),
errorText: BI.i18nText("BI-Please_Input_Natural_Number"),
validationChecker: function(v){
return BI.isNaturalNumber(v);
}
});
this.editor.on(BI.TextEditor.EVENT_CONFIRM, function(){
self._finetuning(0);
self.fireEvent(BI.MultiDateTimeSelect.EVENT_CONFIRM);
});
this.topBtn = BI.createWidget({
type: "bi.icon_button",
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.MultiDateTimeSelect.EVENT_CONFIRM);
});
this.bottomBtn = BI.createWidget({
type: "bi.icon_button",
cls: "column-next-page-h-font bottom-button bi-border-left"
});
this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function(){
self._finetuning(-1);
self.fireEvent(BI.MultiDateTimeSelect.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
}]
});
},
_alertOutEditorValue: function(v){
if (v > this.options.max){
v = this.options.min;
}
if (v < this.options.min){
v = this.options.max
}
return BI.parseInt(v);
},
_alertInEditorValue: function(v){
if (v > this.options.max){
v = this.options.min;
}
if (v < this.options.min){
v = this.options.max;
}
v = v < 10 ? "0" + v : v;
return v;
},
_finetuning: function(add){
var v = BI.parseInt(this._alertOutEditorValue(this.editor.getValue()));
this.editor.setValue(this._alertInEditorValue(v + add));
},
getValue: function () {
var v = this.editor.getValue();
return this._alertOutEditorValue(v);
},
setValue: function (v) {
this.editor.setValue(this._alertInEditorValue(v));
this._finetuning(0);
}
});
BI.MultiDateTimeSelect.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.multi_date_time_select", BI.MultiDateTimeSelect);

63
demo/js/widget/multidatetime/multi.datetime.trigger.js

@ -1,63 +0,0 @@
/**
* Created by Urthur on 2017/7/14.
*/
BI.DateTimeTrigger = BI.inherit(BI.Trigger, {
_const: {
hgap: 4,
vgap: 2,
triggerWidth: 30
},
_defaultConfig: function () {
return BI.extend(BI.DateTimeTrigger.superclass._defaultConfig.apply(this, arguments), {
extraCls: "bi-date-time-trigger",
min: '1900-01-01', //最小日期
max: '2099-12-31', //最大日期
height: 25
});
},
_init: function () {
BI.DateTimeTrigger.superclass._init.apply(this, arguments);
var self = this, o = this.options, c = this._const;
this.editor = BI.createWidget({
type: "bi.sign_editor",
height: o.height,
hgap: c.hgap,
vgap: c.vgap,
disabled: true
});
BI.createWidget({
type: "bi.htape",
element: this,
items: [{
el: BI.createWidget(),
width: 30
}, {
el: this.editor
}]
})
},
_printTime: function (v) {
return v < 10 ? "0" + v : v;
},
setValue: function (v) {
var self = this;
if (BI.isNotNull(v)) {
var value = v.value, dateStr;
if(BI.isNull(value)){
value = new Date();
dateStr = value.getFullYear() + "-" + self._printTime(value.getMonth() + 1) + "-" + self._printTime(value.getDate())
+ " " + self._printTime(value.getHours()) + ":" + self._printTime(value.getMinutes()) + ":" + self._printTime(value.getSeconds());
} else {
dateStr = value.year + "-" + self._printTime(value.month + 1) + "-" + self._printTime(value.day)
+ " " + self._printTime(value.hour) + ":" + self._printTime(value.minute) + ":" + self._printTime(value.second);
}
this.editor.setValue(dateStr);
}
}
});
BI.shortcut("bi.date_time_trigger", BI.DateTimeTrigger);

523
docs/demo.js

@ -3529,15 +3529,15 @@ Demo.COMPONENT_CONFIG = [{
pId: 412, pId: 412,
text: "bi.year_month_combo", text: "bi.year_month_combo",
value: "demo.year_month_combo" value: "demo.year_month_combo"
},{ }, {
pId: 412, pId: 412,
text: "bi.year_quarter_combo", text: "bi.year_quarter_combo",
value: "demo.year_quarter_combo" value: "demo.year_quarter_combo"
},{ }, {
pId: 412, pId: 412,
text: "bi.custom_date_time", text: "bi.custom_date_time",
value: "demo.custom_date_time" value: "demo.custom_date_time"
},{ }, {
pId: 4, pId: 4,
id: 413, id: 413,
text: "简单下拉树" text: "简单下拉树"
@ -3602,8 +3602,7 @@ Demo.COMPONENT_CONFIG = [{
text: "bi.dialog", text: "bi.dialog",
value: "demo.dialog" value: "demo.dialog"
} }
]; ];Demo.Func = BI.inherit(BI.Widget, {
Demo.Func = BI.inherit(BI.Widget, {
props: { props: {
baseCls: "demo-func" baseCls: "demo-func"
}, },
@ -7159,8 +7158,7 @@ BI.shortcut("demo.date_pane_widget", Demo.DatePane);/**
* Created by Urthur on 2017/7/18. * Created by Urthur on 2017/7/18.
*/ */
Demo.CustomDateTime = BI.inherit(BI.Widget, { Demo.CustomDateTime = BI.inherit(BI.Widget, {
props: { props: {},
},
render: function () { render: function () {
var self = this; var self = this;
return { return {
@ -7169,7 +7167,7 @@ Demo.CustomDateTime = BI.inherit(BI.Widget, {
el: { el: {
type: "bi.custom_date_time_combo", type: "bi.custom_date_time_combo",
ref: function (_ref) { ref: function (_ref) {
self.customDateTime = _ref; self.customDateTime = _ref;
self.customDateTime.on(BI.CustomDateTimeCombo.EVENT_CONFIRM, function () { self.customDateTime.on(BI.CustomDateTimeCombo.EVENT_CONFIRM, function () {
BI.Msg.alert("日期", this.getValue().text); BI.Msg.alert("日期", this.getValue().text);
}); });
@ -7726,515 +7724,6 @@ Demo.Month = BI.inherit(BI.Widget, {
}) })
BI.shortcut("demo.month", Demo.Month);/** BI.shortcut("demo.month", Demo.Month);/**
* Created by Urthur on 2017/7/14.
*/
BI.MultiDateTimeCombo = BI.inherit(BI.Single, {
constants: {
popupHeight: 290,
popupWidth: 270,
comboAdjustHeight: 1,
border: 1,
DATE_MIN_VALUE: "1900-01-01",
DATE_MAX_VALUE: "2099-12-31"
},
_defaultConfig: function () {
return BI.extend(BI.MultiDateTimeCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: 'bi-multi-date-time-combo bi-border',
height: 24
});
},
_init: function () {
BI.MultiDateTimeCombo.superclass._init.apply(this, arguments);
var self = this, opts = this.options;
var date = new Date();
this.storeValue = {
value: {
year: date.getFullYear(),
month: date.getMonth(),
day: date.getDate(),
hour: date.getHours(),
minute: date.getMinutes(),
second: date.getSeconds()
}
};
this.trigger = BI.createWidget({
type: 'bi.date_time_trigger',
min: this.constants.DATE_MIN_VALUE,
max: this.constants.DATE_MAX_VALUE
});
this.popup = BI.createWidget({
type: "bi.multi_date_time_popup",
min: this.constants.DATE_MIN_VALUE,
max: this.constants.DATE_MAX_VALUE
});
self.setValue(this.storeValue);
this.popup.on(BI.MultiDateTimePopup.BUTTON_CANCEL_EVENT_CHANGE, function () {
self.combo.hideView();
self.fireEvent(BI.MultiDateTimeCombo.EVENT_CANCEL);
});
this.popup.on(BI.MultiDateTimePopup.BUTTON_OK_EVENT_CHANGE, function () {
self.setValue(self.popup.getValue());
self.combo.hideView();
self.fireEvent(BI.MultiDateTimeCombo.EVENT_CONFIRM);
});
this.popup.on(BI.MultiDateTimePopup.CALENDAR_EVENT_CHANGE, function () {
self.setValue(self.popup.getValue());
});
this.combo = BI.createWidget({
type: 'bi.combo',
toggle: false,
isNeedAdjustHeight: false,
isNeedAdjustWidth: false,
el: this.trigger,
adjustLength: this.constants.comboAdjustHeight,
popup: {
el: this.popup,
maxHeight: this.constants.popupHeight,
width: this.constants.popupWidth,
stopPropagation: false
}
});
this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () {
self.popup.setValue(self.storeValue);
self.fireEvent(BI.MultiDateTimeCombo.EVENT_BEFORE_POPUPVIEW);
});
var triggerBtn = BI.createWidget({
type: "bi.trigger_icon_button",
cls: "bi-trigger-date-button chart-date-normal-font bi-border-right",
width: 30,
height: 24
});
triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () {
if (self.combo.isViewVisible()) {
self.combo.hideView();
} else {
self.combo.showView();
}
});
BI.createWidget({
type: "bi.htape",
element: this,
items: [{
type: "bi.absolute",
items: [{
el: this.combo,
top: 0,
left: 0,
right: 0,
bottom: 0
}, {
el: triggerBtn,
top: 0,
left: 0
}]
}]
})
},
setValue: function (v) {
this.storeValue = v;
this.popup.setValue(v);
this.trigger.setValue(v);
},
getValue: function () {
return this.storeValue;
}
});
BI.MultiDateTimeCombo.EVENT_CANCEL = "EVENT_CANCEL";
BI.MultiDateTimeCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.MultiDateTimeCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.MultiDateTimeCombo.EVENT_BEFORE_POPUPVIEW = "BI.MultiDateTimeCombo.EVENT_BEFORE_POPUPVIEW";
BI.shortcut('bi.multi_date_time_combo', BI.MultiDateTimeCombo);
/**
* Created by Urthur on 2017/7/14.
*/
BI.CustomMultiDateTimeCombo = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.CustomMultiDateTimeCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-custom-multi-date-time-combo"
})
},
_init: function () {
BI.CustomMultiDateTimeCombo.superclass._init.apply(this, arguments);
var self = this;
this.multiDateTime = BI.createWidget({
type: "bi.multi_date_time_combo",
element: this
});
this.multiDateTime.on(BI.MultiDateTimeCombo.EVENT_CANCEL, function () {
self.fireEvent(BI.CustomMultiDateTimeCombo.EVENT_CANCEL);
});
this.multiDateTime.on(BI.MultiDateTimeCombo.EVENT_CONFIRM, function () {
self.fireEvent(BI.CustomMultiDateTimeCombo.EVENT_CONFIRM);
});
},
getValue: function () {
return this.multiDateTime.getValue();
},
setValue: function (v) {
this.multiDateTime.setValue(v);
}
});
BI.CustomMultiDateTimeCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.CustomMultiDateTimeCombo.EVENT_CANCEL = "EVENT_CANCEL";
BI.CustomMultiDateTimeCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.custom_multi_date_time_combo", BI.CustomMultiDateTimeCombo);
/**
* Created by Urthur on 2017/7/14.
*/
BI.MultiDateTimePopup = BI.inherit(BI.Widget, {
constants: {
tabHeight: 30,
tabWidth: 42,
titleHeight: 27,
itemHeight: 30,
triggerHeight: 24,
buttonWidth: 90,
buttonHeight: 25,
popupHeight: 290,
popupWidth: 270,
comboAdjustHeight: 1,
lgap: 2,
border: 1
},
_defaultConfig: function () {
return BI.extend(BI.MultiDateTimePopup.superclass._defaultConfig.apply(this, arguments), {
baseCls: 'bi-multi-date-time-popup',
width: 268,
height: 290
});
},
_init: function () {
BI.MultiDateTimePopup.superclass._init.apply(this, arguments);
var self = this, opts = this.options;
this.cancelButton = BI.createWidget({
type: 'bi.text_button',
forceCenter: true,
cls: 'bi-multidate-popup-button bi-border-top bi-border-right',
shadow: true,
text: BI.i18nText("BI-Basic_Cancel")
});
this.cancelButton.on(BI.TextButton.EVENT_CHANGE, function () {
self.fireEvent(BI.MultiDateTimePopup.BUTTON_CANCEL_EVENT_CHANGE);
});
this.okButton = BI.createWidget({
type: "bi.text_button",
forceCenter: true,
cls: 'bi-multidate-popup-button bi-border-top',
shadow: true,
text: BI.i18nText("BI-Basic_OK")
});
this.okButton.on(BI.TextButton.EVENT_CHANGE, function () {
self.fireEvent(BI.MultiDateTimePopup.BUTTON_OK_EVENT_CHANGE);
});
this.dateCombo = BI.createWidget({
type: "bi.date_calendar_popup",
min: self.options.min,
max: self.options.max
});
self.dateCombo.on(BI.DateCalendarPopup.EVENT_CHANGE, function () {
self.fireEvent(BI.MultiDateTimePopup.CALENDAR_EVENT_CHANGE);
});
this.dateSelect = BI.createWidget({
type: "bi.horizontal",
cls: "bi-border-top",
items: [{
type: "bi.label",
text: BI.i18nText("BI-Basic_Time"),
width: 45
},{
type: "bi.multi_date_time_select",
max: 23,
min: 0,
width: 60,
height: 30,
ref: function (_ref) {
self.hour = _ref;
self.hour.on(BI.MultiDateTimeSelect.EVENT_CONFIRM, function () {
self.fireEvent(BI.MultiDateTimePopup.CALENDAR_EVENT_CHANGE);
});
}
},{
type: "bi.label",
text: ":",
width: 15
},{
type: "bi.multi_date_time_select",
max: 59,
min: 0,
width: 60,
height: 30,
ref: function (_ref) {
self.minute = _ref;
self.minute.on(BI.MultiDateTimeSelect.EVENT_CONFIRM, function () {
self.fireEvent(BI.MultiDateTimePopup.CALENDAR_EVENT_CHANGE);
});
}
},{
type: "bi.label",
text: ":",
width: 15
},{
type: "bi.multi_date_time_select",
max: 59,
min: 0,
width: 60,
height: 30,
ref: function (_ref) {
self.second = _ref;
self.second.on(BI.MultiDateTimeSelect.EVENT_CONFIRM, function () {
self.fireEvent(BI.MultiDateTimePopup.CALENDAR_EVENT_CHANGE);
});
}
}]
});
this.dateButton = BI.createWidget({
type: "bi.grid",
items: [[this.cancelButton, this.okButton]]
});
BI.createWidget({
element: this,
type: "bi.vtape",
items: [{
el: this.dateCombo
}, {
el: this.dateSelect,
height: 50
},{
el: this.dateButton,
height: 30
}]
});
},
setValue: function (v) {
var value, date;
if (BI.isNotNull(v)) {
value = v.value;
if(BI.isNull(value)){
date = new Date();
this.dateCombo.setValue({
year: date.getFullYear(),
month: date.getMonth(),
day: date.getDate()
});
this.hour.setValue(date.getHours());
this.minute.setValue(date.getMinutes());
this.second.setValue(date.getSeconds());
} else {
this.dateCombo.setValue({
year: value.year,
month: value.month,
day: value.day
});
this.hour.setValue(value.hour);
this.minute.setValue(value.minute);
this.second.setValue(value.second);
}
}
},
getValue: function () {
return {
value: {
year: this.dateCombo.getValue().year,
month: this.dateCombo.getValue().month,
day: this.dateCombo.getValue().day,
hour: this.hour.getValue(),
minute: this.minute.getValue(),
second: this.second.getValue()
}
}
}
});
BI.MultiDateTimePopup.BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE";
BI.MultiDateTimePopup.BUTTON_CANCEL_EVENT_CHANGE = "BUTTON_CANCEL_EVENT_CHANGE";
BI.MultiDateTimePopup.CALENDAR_EVENT_CHANGE = "CALENDAR_EVENT_CHANGE";
BI.shortcut('bi.multi_date_time_popup', BI.MultiDateTimePopup);
/**
* Created by Urthur on 2017/7/14.
*/
BI.MultiDateTimeSelect = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.MultiDateTimeSelect.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-multi-date-time-select bi-border",
max: 23,
min: 0
})
},
_init: function () {
BI.MultiDateTimeSelect.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.editor = BI.createWidget({
type: "bi.sign_editor",
value: this._alertInEditorValue(o.min),
errorText: BI.i18nText("BI-Please_Input_Natural_Number"),
validationChecker: function(v){
return BI.isNaturalNumber(v);
}
});
this.editor.on(BI.TextEditor.EVENT_CONFIRM, function(){
self._finetuning(0);
self.fireEvent(BI.MultiDateTimeSelect.EVENT_CONFIRM);
});
this.topBtn = BI.createWidget({
type: "bi.icon_button",
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.MultiDateTimeSelect.EVENT_CONFIRM);
});
this.bottomBtn = BI.createWidget({
type: "bi.icon_button",
cls: "column-next-page-h-font bottom-button bi-border-left"
});
this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function(){
self._finetuning(-1);
self.fireEvent(BI.MultiDateTimeSelect.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
}]
});
},
_alertOutEditorValue: function(v){
if (v > this.options.max){
v = this.options.min;
}
if (v < this.options.min){
v = this.options.max
}
return BI.parseInt(v);
},
_alertInEditorValue: function(v){
if (v > this.options.max){
v = this.options.min;
}
if (v < this.options.min){
v = this.options.max;
}
v = v < 10 ? "0" + v : v;
return v;
},
_finetuning: function(add){
var v = BI.parseInt(this._alertOutEditorValue(this.editor.getValue()));
this.editor.setValue(this._alertInEditorValue(v + add));
},
getValue: function () {
var v = this.editor.getValue();
return this._alertOutEditorValue(v);
},
setValue: function (v) {
this.editor.setValue(this._alertInEditorValue(v));
this._finetuning(0);
}
});
BI.MultiDateTimeSelect.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.multi_date_time_select", BI.MultiDateTimeSelect);
/**
* Created by Urthur on 2017/7/14.
*/
BI.DateTimeTrigger = BI.inherit(BI.Trigger, {
_const: {
hgap: 4,
vgap: 2,
triggerWidth: 30
},
_defaultConfig: function () {
return BI.extend(BI.DateTimeTrigger.superclass._defaultConfig.apply(this, arguments), {
extraCls: "bi-date-time-trigger",
min: '1900-01-01', //最小日期
max: '2099-12-31', //最大日期
height: 25
});
},
_init: function () {
BI.DateTimeTrigger.superclass._init.apply(this, arguments);
var self = this, o = this.options, c = this._const;
this.editor = BI.createWidget({
type: "bi.sign_editor",
height: o.height,
hgap: c.hgap,
vgap: c.vgap,
disabled: true
});
BI.createWidget({
type: "bi.htape",
element: this,
items: [{
el: BI.createWidget(),
width: 30
}, {
el: this.editor
}]
})
},
_printTime: function (v) {
return v < 10 ? "0" + v : v;
},
setValue: function (v) {
var self = this;
if (BI.isNotNull(v)) {
var value = v.value, dateStr;
if(BI.isNull(value)){
value = new Date();
dateStr = value.getFullYear() + "-" + self._printTime(value.getMonth() + 1) + "-" + self._printTime(value.getDate())
+ " " + self._printTime(value.getHours()) + ":" + self._printTime(value.getMinutes()) + ":" + self._printTime(value.getSeconds());
} else {
dateStr = value.year + "-" + self._printTime(value.month + 1) + "-" + self._printTime(value.day)
+ " " + self._printTime(value.hour) + ":" + self._printTime(value.minute) + ":" + self._printTime(value.second);
}
this.editor.setValue(dateStr);
}
}
});
BI.shortcut("bi.date_time_trigger", BI.DateTimeTrigger);
/**
* Created by User on 2017/3/22. * Created by User on 2017/3/22.
*/ */
Demo.MultiSelectCombo = BI.inherit(BI.Widget, { Demo.MultiSelectCombo = BI.inherit(BI.Widget, {

620
docs/widget.js

@ -2334,626 +2334,6 @@ BI.BranchRelation = BI.inherit(BI.Widget, {
}); });
BI.BranchRelation.EVENT_CHANGE = "BranchRelation.EVENT_CHANGE"; BI.BranchRelation.EVENT_CHANGE = "BranchRelation.EVENT_CHANGE";
BI.shortcut("bi.branch_relation", BI.BranchRelation);/** BI.shortcut("bi.branch_relation", BI.BranchRelation);/**
* Created by dailer on 2017/7/19.
* 日期时间练习
*/
BI.DateTimeCombo = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.TimeTuning.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-fine-tuning-number-editor bi-border",
selectedTime: {
year: 2017,
month: 0,
day: 1,
hour: 0,
minute: 0,
second: 0
},
height: 30
})
},
_init: function () {
BI.DateCombo.superclass._init.apply(this, arguments);
var self = this,
o = this.options;
this.trigger = BI.createWidget({
type: "bi.date_time_trigger1"
});
this.trigger.on(BI.DateTrigger.EVENT_TRIGGER_CLICK, function () {
self.combo.toggle();
});
this.popup = BI.createWidget({
type: "bi.date_time_popup"
});
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: true,
element: this,
isNeedAdjustHeight: false,
isNeedAdjustWidth: false,
el: this.trigger,
popup: {
width: 270,
el: this.popup,
stopPropagation: false
}
})
},
getValue: function () {
return this.popup.getValue();
},
setStep: function (step) {
this.step = step || this.step;
},
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 {
min: this.min,
max: this.max
};
},
getStep: function () {
return this.step;
},
getValue: function () {
return this.value;
},
setStep: function (step) {
this.step = step || this.step;
},
setValue: function (v) {
this.value = v;
this.editor.setValue(this.formatter(v));
}
});
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
*/
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 demo-clolor",
min: '1900-01-01', //最小日期
max: '2099-12-31', //最大日期
selectedTime: null
})
},
_createNav: function (v) {
var date = BI.Calendar.getDateJSONByPage(v);
var calendar = BI.createWidget({
type: "bi.calendar",
logic: {
dynamic: true
},
min: this.options.min,
max: this.options.max,
year: date.year,
month: date.month,
day: this.selectedTime.day
});
return calendar
},
_init: function () {
BI.DateTimePopup.superclass._init.apply(this, arguments);
var self = this,
o = this.options;
this.today = new Date();
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,
hour: this._hour,
minute: this._minute,
second: this._second
};
this.datePicker = BI.createWidget({
type: "bi.date_picker",
min: o.min,
max: o.max,
cls: "demo-clolor",
});
this.calendar = BI.createWidget({
direction: "top",
// element: this,
logic: {
dynamic: true
},
type: "bi.navigation",
tab: this.datePicker,
cardCreator: BI.bind(this._createNav, this),
afterCardCreated: function () {
},
afterCardShow: function () {
this.setValue(self.selectedTime);
self.calendar.setSelect(BI.Calendar.getPageByDateJSON(self.selectedTime));
}
});
this.timeTunning = BI.createWidget({
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.button",
textHeight: 30,
clear: true,
text: "取消",
handler: function () {
self.fireEvent(BI.DateTimePopup.EVENT_CLICK_CANCEL);
}
}, {
text: "|"
}, {
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: {},
layouts: [{
type: "bi.center_adapt"
}]
});
this.dateTime = BI.createWidget({
type: "bi.vertical",
element: this,
items: [this.calendar, this.timeTunning, this.buttons]
});
this.datePicker.on(BI.DatePicker.EVENT_CHANGE, function () {
self.selectedTime = self.datePicker.getValue();
self.selectedTime.day = 1;
self.calendar.setSelect(BI.Calendar.getPageByDateJSON(self.selectedTime));
});
this.calendar.on(BI.Navigation.EVENT_CHANGE, function () {
self.selectedTime = self.calendar.getValue();
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 $.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.
* 时间微调器练习
*/
BI.TimeTuning = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.TimeTuning.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-fine-tuning-number-editor bi-border",
disabled: false,
currentTime: {
hour: 0,
minute: 0,
second: 0
}
})
},
_init: function () {
BI.TimeTuning.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.currentTime = BI.deepClone(o.currentTime);
this.last = {
lastH: o.currentTime.hour,
lastM: o.currentTime.minute,
lastS: o.currentTime.second
}
//时
this.h = BI.createWidget({
type: "bi.test_editor",
value: this.currentTime.hour,
min: 0,
max: 23,
width: 60,
height: 30
});
this.h.on(BI.FineTuningNumberEditor.EVENT_CONFIRM, function () {
self.fireEvent(BI.TimeTuning.EVENT_CHANGE);
});
//分
this.m = BI.createWidget({
type: "bi.test_editor",
value: this.currentTime.minute,
min: 0,
max: 59,
width: 60,
height: 30
})
this.m.on(BI.FineTuningNumberEditor.EVENT_CONFIRM, function () {
self._reviseHour();
self.fireEvent(BI.TimeTuning.EVENT_CHANGE);
});
//秒
this.s = BI.createWidget({
type: "bi.test_editor",
value: this.currentTime.second,
min: 0,
max: 59,
width: 60,
height: 30
})
this.s.on(BI.FineTuningNumberEditor.EVENT_CONFIRM, function () {
self._reviseMinute();
self.fireEvent(BI.TimeTuning.EVENT_CHANGE);
});
this.editor = BI.createWidget({
type: "bi.horizontal",
items: [{
type: "bi.label",
text: "时间",
width: 45,
height: 30
},
this.h,
{
type: "bi.text",
text: ":",
textAlign: "center",
width: 15
},
this.m,
{
type: "bi.text",
text: ":",
textAlign: "center",
width: 15
},
this.s
]
});
BI.createWidget({
type: "bi.htape",
cls: "demo-clolor",
element: this,
items: [this.editor],
width: 270,
height: 50
});
},
_reviseMinute: function () {
this.m._finetuning(this.s.getIsNeedRevise());
this._reviseHour();
},
_reviseHour: function () {
this.h._finetuning(this.m.getIsNeedRevise());
},
getCurrentTime: function () {
return {
hour: this.h.getValue(),
minute: this.m.getValue(),
second: this.s.getValue()
};
},
_format: function (p) {
return p < 10 ? ('0' + p) : p
},
getCurrentTimeStr: function () {
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 (timeObj) {
this.h.setValue(timeObj.hour);
this.m.setValue(timeObj.minute);
this.s.setValue(timeObj.second);
}
});
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.DateTimeTrigger.superclass._defaultConfig.apply(this, arguments), {
extraCls: "bi-date-trigger",
min: '1900-01-01', //最小日期
max: '2099-12-31', //最大日期
height: 32
});
},
_init: function () {
BI.DateTimeTrigger.superclass._init.apply(this, arguments);
var self = this,
o = this.options;
this.label = BI.createWidget({
type: "bi.label",
textAlign: "left",
text: "",
height: o.height
});
BI.createWidget({
type: "bi.htape",
element: this,
items: [{
el: BI.createWidget({
type: "bi.icon_button",
cls: "search-font"
}),
width: 30
}, {
el: this.label
}]
})
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);
},
_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;
},
setValue: function (v) {
this.label.setValue(this._parseTimeObjToStr(v));
},
getValue: function () {
}
});
BI.shortcut("bi.date_time_trigger1", BI.DateTimeTrigger);/**
* 日期控件中的月份下拉框 * 日期控件中的月份下拉框
* *
* Created by GUY on 2015/9/7. * Created by GUY on 2015/9/7.

81
src/widget/dailertest/combo.date.time.js

@ -1,81 +0,0 @@
/**
* Created by dailer on 2017/7/19.
* 日期时间练习
*/
BI.DateTimeCombo = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.TimeTuning.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-fine-tuning-number-editor bi-border",
selectedTime: {
year: 2017,
month: 0,
day: 1,
hour: 0,
minute: 0,
second: 0
},
height: 30
})
},
_init: function () {
BI.DateCombo.superclass._init.apply(this, arguments);
var self = this,
o = this.options;
this.trigger = BI.createWidget({
type: "bi.date_time_trigger1"
});
this.trigger.on(BI.DateTrigger.EVENT_TRIGGER_CLICK, function () {
self.combo.toggle();
});
this.popup = BI.createWidget({
type: "bi.date_time_popup"
});
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: true,
element: this,
isNeedAdjustHeight: false,
isNeedAdjustWidth: false,
el: this.trigger,
popup: {
width: 270,
el: this.popup,
stopPropagation: false
}
})
},
getValue: function () {
return this.popup.getValue();
},
setStep: function (step) {
this.step = step || this.step;
},
setValue: function (v) {
this.trigger.setValue(this.popup.getValue());
}
});
BI.DateTimeCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.date_time_combo", BI.DateTimeCombo);

150
src/widget/dailertest/number.spinner.js

@ -1,150 +0,0 @@
/**
* 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 {
min: this.min,
max: this.max
};
},
getStep: function () {
return this.step;
},
getValue: function () {
return this.value;
},
setStep: function (step) {
this.step = step || this.step;
},
setValue: function (v) {
this.value = v;
this.editor.setValue(this.formatter(v));
}
});
BI.NumberSpinner.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.test_editor", BI.NumberSpinner);

156
src/widget/dailertest/popup.date.time.js

@ -1,156 +0,0 @@
/**
* Created by GUY on 2015/9/7.
* @class BI.DateCalendarPopup
* @extends BI.Widget
*/
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 demo-clolor",
min: '1900-01-01', //最小日期
max: '2099-12-31', //最大日期
selectedTime: null
})
},
_createNav: function (v) {
var date = BI.Calendar.getDateJSONByPage(v);
var calendar = BI.createWidget({
type: "bi.calendar",
logic: {
dynamic: true
},
min: this.options.min,
max: this.options.max,
year: date.year,
month: date.month,
day: this.selectedTime.day
});
return calendar
},
_init: function () {
BI.DateTimePopup.superclass._init.apply(this, arguments);
var self = this,
o = this.options;
this.today = new Date();
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,
hour: this._hour,
minute: this._minute,
second: this._second
};
this.datePicker = BI.createWidget({
type: "bi.date_picker",
min: o.min,
max: o.max,
cls: "demo-clolor",
});
this.calendar = BI.createWidget({
direction: "top",
// element: this,
logic: {
dynamic: true
},
type: "bi.navigation",
tab: this.datePicker,
cardCreator: BI.bind(this._createNav, this),
afterCardCreated: function () {
},
afterCardShow: function () {
this.setValue(self.selectedTime);
self.calendar.setSelect(BI.Calendar.getPageByDateJSON(self.selectedTime));
}
});
this.timeTunning = BI.createWidget({
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.button",
textHeight: 30,
clear: true,
text: "取消",
handler: function () {
self.fireEvent(BI.DateTimePopup.EVENT_CLICK_CANCEL);
}
}, {
text: "|"
}, {
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: {},
layouts: [{
type: "bi.center_adapt"
}]
});
this.dateTime = BI.createWidget({
type: "bi.vertical",
element: this,
items: [this.calendar, this.timeTunning, this.buttons]
});
this.datePicker.on(BI.DatePicker.EVENT_CHANGE, function () {
self.selectedTime = self.datePicker.getValue();
self.selectedTime.day = 1;
self.calendar.setSelect(BI.Calendar.getPageByDateJSON(self.selectedTime));
});
this.calendar.on(BI.Navigation.EVENT_CHANGE, function () {
self.selectedTime = self.calendar.getValue();
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 $.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);

167
src/widget/dailertest/time.spinner.js

@ -1,167 +0,0 @@
/**
* Created by dailer on 2017/7/19.
* 时间微调器练习
*/
BI.TimeTuning = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.TimeTuning.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-fine-tuning-number-editor bi-border",
disabled: false,
currentTime: {
hour: 0,
minute: 0,
second: 0
}
})
},
_init: function () {
BI.TimeTuning.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.currentTime = BI.deepClone(o.currentTime);
this.last = {
lastH: o.currentTime.hour,
lastM: o.currentTime.minute,
lastS: o.currentTime.second
}
//时
this.h = BI.createWidget({
type: "bi.test_editor",
value: this.currentTime.hour,
min: 0,
max: 23,
width: 60,
height: 30
});
this.h.on(BI.FineTuningNumberEditor.EVENT_CONFIRM, function () {
self.fireEvent(BI.TimeTuning.EVENT_CHANGE);
});
//分
this.m = BI.createWidget({
type: "bi.test_editor",
value: this.currentTime.minute,
min: 0,
max: 59,
width: 60,
height: 30
})
this.m.on(BI.FineTuningNumberEditor.EVENT_CONFIRM, function () {
self._reviseHour();
self.fireEvent(BI.TimeTuning.EVENT_CHANGE);
});
//秒
this.s = BI.createWidget({
type: "bi.test_editor",
value: this.currentTime.second,
min: 0,
max: 59,
width: 60,
height: 30
})
this.s.on(BI.FineTuningNumberEditor.EVENT_CONFIRM, function () {
self._reviseMinute();
self.fireEvent(BI.TimeTuning.EVENT_CHANGE);
});
this.editor = BI.createWidget({
type: "bi.horizontal",
items: [{
type: "bi.label",
text: "时间",
width: 45,
height: 30
},
this.h,
{
type: "bi.text",
text: ":",
textAlign: "center",
width: 15
},
this.m,
{
type: "bi.text",
text: ":",
textAlign: "center",
width: 15
},
this.s
]
});
BI.createWidget({
type: "bi.htape",
cls: "demo-clolor",
element: this,
items: [this.editor],
width: 270,
height: 50
});
},
_reviseMinute: function () {
this.m._finetuning(this.s.getIsNeedRevise());
this._reviseHour();
},
_reviseHour: function () {
this.h._finetuning(this.m.getIsNeedRevise());
},
getCurrentTime: function () {
return {
hour: this.h.getValue(),
minute: this.m.getValue(),
second: this.s.getValue()
};
},
_format: function (p) {
return p < 10 ? ('0' + p) : p
},
getCurrentTimeStr: function () {
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 (timeObj) {
this.h.setValue(timeObj.hour);
this.m.setValue(timeObj.minute);
this.s.setValue(timeObj.second);
}
});
BI.TimeTuning.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.time_tunning", BI.TimeTuning);

71
src/widget/dailertest/trigger.date.time.js

@ -1,71 +0,0 @@
BI.DateTimeTrigger = BI.inherit(BI.Trigger, {
_defaultConfig: function () {
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.DateTimeTrigger.superclass._init.apply(this, arguments);
var self = this,
o = this.options;
this.label = BI.createWidget({
type: "bi.label",
textAlign: "left",
text: "",
height: o.height
});
BI.createWidget({
type: "bi.htape",
element: this,
items: [{
el: BI.createWidget({
type: "bi.icon_button",
cls: "search-font"
}),
width: 30
}, {
el: this.label
}]
})
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);
},
_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;
},
setValue: function (v) {
this.label.setValue(this._parseTimeObjToStr(v));
},
getValue: function () {
}
});
BI.shortcut("bi.date_time_trigger1", BI.DateTimeTrigger);
Loading…
Cancel
Save