fineui是帆软报表和BI产品线所使用的前端框架。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 lines
3.3 KiB

8 years ago
/**
* Created by GUY on 2015/9/7.
* @class BI.DateCalendarPopup
* @extends BI.Widget
*/
BI.DateCalendarPopup = BI.inherit(BI.Widget, {
_defaultConfig: function () {
var conf = BI.DateCalendarPopup.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: "bi-date-calendar-popup",
7 years ago
min: "1900-01-01", // 最小日期
max: "2099-12-31", // 最大日期
8 years ago
selectedTime: null
7 years ago
});
8 years ago
},
_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
});
7 years ago
return calendar;
8 years ago
},
_init: function () {
BI.DateCalendarPopup.superclass._init.apply(this, arguments);
8 years ago
var self = this,
o = this.options;
this.today = BI.getDate();
8 years ago
this._year = this.today.getFullYear();
7 years ago
this._month = this.today.getMonth() + 1;
8 years ago
this._day = this.today.getDate();
this.selectedTime = o.selectedTime || {
8 years ago
year: this._year,
month: this._month,
day: this._day
};
8 years ago
this.datePicker = BI.createWidget({
type: "bi.date_picker",
behaviors: o.behaviors,
8 years ago
min: o.min,
max: o.max
});
this.calendar = BI.createWidget({
direction: "top",
logic: {
dynamic: true
},
type: "bi.navigation",
tab: this.datePicker,
cardCreator: BI.bind(this._createNav, this),
afterCardCreated: function () {
},
afterCardShow: function () {
this.setValue(self.selectedTime);
}
});
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.setValue(self.selectedTime);
self.fireEvent(BI.DateCalendarPopup.EVENT_CHANGE);
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: this.calendar,
left: 10,
right: 10
}, {
el: {
type: "bi.layout",
cls: "bi-border-top"
},
height: 1,
top: 40,
left: 0,
right: 0
}]
});
8 years ago
},
setValue: function (timeOb) {
this.datePicker.setValue(timeOb);
this.calendar.setSelect(BI.Calendar.getPageByDateJSON(timeOb));
this.calendar.setValue(timeOb);
this.selectedTime = timeOb;
},
getValue: function () {
return this.selectedTime;
}
});
BI.DateCalendarPopup.EVENT_CHANGE = "EVENT_CHANGE";
8 years ago
BI.shortcut("bi.date_calendar_popup", BI.DateCalendarPopup);