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.
 
 
 

113 lines
3.2 KiB

/**
* Created by GUY on 2015/9/7.
* @class BI.YearPicker
* @extends BI.Widget
*/
BI.YearPicker = BI.inherit(BI.Widget, {
_defaultConfig: function () {
var conf = BI.YearPicker.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: "bi-year-picker",
behaviors: {},
height: 40,
min: "1900-01-01", // 最小日期
max: "2099-12-31" // 最大日期
});
},
_init: function () {
BI.YearPicker.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this._year = BI.getDate().getFullYear();
this.left = BI.createWidget({
type: "bi.icon_button",
cls: "pre-page-h-font",
width: 25,
height: 25
});
this.left.on(BI.IconButton.EVENT_CHANGE, function () {
self.setValue(self.year.getValue() - 1);
self.fireEvent(BI.YearPicker.EVENT_CHANGE);
self._checkLeftValid();
self._checkRightValid();
});
this.right = BI.createWidget({
type: "bi.icon_button",
cls: "next-page-h-font",
width: 25,
height: 25
});
this.right.on(BI.IconButton.EVENT_CHANGE, function () {
self.setValue(self.year.getValue() + 1);
self.fireEvent(BI.YearPicker.EVENT_CHANGE);
self._checkLeftValid();
self._checkRightValid();
});
this.year = BI.createWidget({
type: "bi.year_date_combo",
min: o.min,
behaviors: o.behaviors,
max: o.max
});
this.year.on(BI.YearDateCombo.EVENT_CHANGE, function () {
self.setValue(self.year.getValue());
self.fireEvent(BI.YearPicker.EVENT_CHANGE);
});
BI.createWidget({
type: "bi.htape",
element: this,
items: [{
el: {
type: "bi.center_adapt",
items: [this.left]
},
width: 25
}, {
type: "bi.center_adapt",
items: [this.year]
}, {
el: {
type: "bi.center_adapt",
items: [this.right]
},
width: 25
}]
});
this.setValue({
year: this._year
});
},
_checkLeftValid: function () {
var o = this.options;
var valid = !(this._year === BI.parseDateTime(o.min, "%Y-%X-%d").getFullYear());
this.left.setEnable(valid);
return valid;
},
_checkRightValid: function () {
var o = this.options;
var valid = !(this._year === BI.parseDateTime(o.max, "%Y-%X-%d").getFullYear());
this.right.setEnable(valid);
return valid;
},
setValue: function (v) {
this._year = v;
this.year.setValue(v);
this._checkLeftValid();
this._checkRightValid();
},
getValue: function () {
return this.year.getValue();
}
});
BI.YearPicker.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.year_picker", BI.YearPicker);