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.

97 lines
2.9 KiB

7 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", // 最大日期
7 years ago
selectedTime: null
7 years ago
});
7 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;
7 years ago
},
_init: function () {
BI.DateCalendarPopup.superclass._init.apply(this, arguments);
7 years ago
var self = this,
o = this.options;
this.today = BI.getDate();
7 years ago
this._year = this.today.getFullYear();
this._month = this.today.getMonth();
this._day = this.today.getDate();
this.selectedTime = o.selectedTime || {
7 years ago
year: this._year,
month: this._month,
day: this._day
};
7 years ago
this.datePicker = BI.createWidget({
type: "bi.date_picker",
min: o.min,
max: o.max
});
this.calendar = BI.createWidget({
direction: "top",
7 years ago
element: this,
7 years ago
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);
});
},
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";
7 years ago
BI.shortcut("bi.date_calendar_popup", BI.DateCalendarPopup);