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.

106 lines
3.0 KiB

/**
* 年份展示面板
*
* Created by GUY on 2015/9/2.
* @class BI.YearPopup
* @extends BI.Trigger
*/
BI.YearPopup = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.YearPopup.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-year-popup",
8 years ago
behaviors: {},
min: '1900-01-01', //最小日期
max: '2099-12-31' //最大日期
});
},
_createYearCalendar: function (v) {
var o = this.options, y = this._year;
var calendar = BI.createWidget({
type: "bi.year_calendar",
8 years ago
behaviors: o.behaviors,
min: o.min,
max: o.max,
logic: {
dynamic: true
},
year: y + v * 12
});
calendar.setValue(this._year);
return calendar;
},
_init: function () {
BI.YearPopup.superclass._init.apply(this, arguments);
var self = this;
this.selectedYear = this._year = Date.getDate().getFullYear();
var backBtn = BI.createWidget({
type: "bi.icon_button",
cls: "pre-page-h-font",
width: 25,
height: 25,
value: -1
});
var preBtn = BI.createWidget({
type: "bi.icon_button",
cls: "next-page-h-font",
width: 25,
height: 25,
value: 1
});
this.navigation = BI.createWidget({
type: "bi.navigation",
element: this,
8 years ago
single: true,
logic: {
dynamic: true
},
tab: {
8 years ago
cls: "year-popup-navigation bi-high-light bi-border-top",
height: 25,
items: [backBtn, preBtn]
},
cardCreator: BI.bind(this._createYearCalendar, this),
afterCardShow: function () {
this.setValue(self.selectedYear);
var calendar = this.getSelectedCard();
backBtn.setEnable(!calendar.isFrontYear());
preBtn.setEnable(!calendar.isFinalYear());
}
});
this.navigation.on(BI.Navigation.EVENT_CHANGE, function () {
self.selectedYear = this.getValue();
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
self.fireEvent(BI.YearPopup.EVENT_CHANGE, self.selectedYear);
});
},
getValue: function () {
return this.selectedYear;
},
setValue: function (v) {
var o = this.options;
if (Date.checkVoid(v, 1, 1, o.min, o.max)[0]) {
v = Date.getDate().getFullYear();
this.selectedYear = "";
this.navigation.setSelect(BI.YearCalendar.getPageByYear(v));
this.navigation.setValue("");
} else {
this.selectedYear = v;
this.navigation.setSelect(BI.YearCalendar.getPageByYear(v));
this.navigation.setValue(v);
}
}
});
BI.YearPopup.EVENT_CHANGE = "EVENT_CHANGE";
8 years ago
BI.shortcut("bi.year_popup", BI.YearPopup);