|
|
@ -136,49 +136,68 @@ BI.DatePicker = BI.inherit(BI.Widget, { |
|
|
|
if (!BI.contains(allowMonth, month)) { |
|
|
|
if (!BI.contains(allowMonth, month)) { |
|
|
|
month = allowMonth[0]; |
|
|
|
month = allowMonth[0]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return month; |
|
|
|
return month; |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
_getAllowMonths: function () { |
|
|
|
_getAllowMonths: function () { |
|
|
|
var self = this, o = this.options; |
|
|
|
var obj = this._getCheckMinMaxDate(); |
|
|
|
var minDate = BI.parseDateTime(o.min, "%Y-%X-%d"); |
|
|
|
var year = this.year.getValue() || this._year; |
|
|
|
var maxDate = BI.parseDateTime(o.max, "%Y-%X-%d"); |
|
|
|
|
|
|
|
minDate.setDate(1); |
|
|
|
|
|
|
|
maxDate.setDate(1); |
|
|
|
|
|
|
|
var calcMin = BI.print(minDate, "%Y-%X-%d"); |
|
|
|
|
|
|
|
var calcMax = BI.print(maxDate, "%Y-%X-%d"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return BI.filter(BI.range(1, 13), function (idx, v) { |
|
|
|
return BI.filter(BI.range(1, 13), function (idx, v) { |
|
|
|
return !BI.checkDateVoid(self.year.getValue(), v, 1, calcMin, calcMax)[0]; |
|
|
|
return !BI.checkDateVoid(year, v, 1, obj.min, obj.max)[0]; |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 上一年月不合法则灰化
|
|
|
|
_checkLeftValid: function () { |
|
|
|
_checkLeftValid: function () { |
|
|
|
var o = this.options; |
|
|
|
var obj = this._getCheckMinMaxDate(); |
|
|
|
var minDate = BI.parseDateTime(o.min, "%Y-%X-%d"); |
|
|
|
var year = this._month === 1 ? this._year - 1 : this._year; |
|
|
|
var valid = !(this._month <= (minDate.getMonth() + 1) && this._year <= minDate.getFullYear()); |
|
|
|
var month = this._month === 1 ? 12 : this.month - 1; |
|
|
|
|
|
|
|
var valid = BI.isNull(BI.checkDateVoid(year, month, 1, obj.min, obj.max)[0]); |
|
|
|
this.left.setEnable(valid); |
|
|
|
this.left.setEnable(valid); |
|
|
|
|
|
|
|
|
|
|
|
return valid; |
|
|
|
return valid; |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 下一年月不合法则灰化
|
|
|
|
_checkRightValid: function () { |
|
|
|
_checkRightValid: function () { |
|
|
|
var o = this.options; |
|
|
|
var obj = this._getCheckMinMaxDate(); |
|
|
|
var maxDate = BI.parseDateTime(o.max, "%Y-%X-%d"); |
|
|
|
var year = this._month === 12 ? this._year + 1 : this._year; |
|
|
|
var valid = !(this._month >= (maxDate.getMonth() + 1) && this._year >= maxDate.getFullYear()); |
|
|
|
var month = this._month === 12 ? 1 : this.month + 1; |
|
|
|
|
|
|
|
var valid = BI.isNull(BI.checkDateVoid(year, month, 1, obj.min, obj.max)[0]); |
|
|
|
this.right.setEnable(valid); |
|
|
|
this.right.setEnable(valid); |
|
|
|
|
|
|
|
|
|
|
|
return valid; |
|
|
|
return valid; |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_getCheckMinMaxDate() { |
|
|
|
|
|
|
|
var o = this.options; |
|
|
|
|
|
|
|
var minDate = BI.parseDateTime(o.min, "%Y-%X-%d"); |
|
|
|
|
|
|
|
var maxDate = BI.parseDateTime(o.max, "%Y-%X-%d"); |
|
|
|
|
|
|
|
minDate.setDate(1); |
|
|
|
|
|
|
|
maxDate.setDate(1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
|
|
|
min: BI.print(minDate, "%Y-%X-%d"), |
|
|
|
|
|
|
|
max: BI.print(maxDate, "%Y-%X-%d") |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
setMinDate: function (minDate) { |
|
|
|
setMinDate: function (minDate) { |
|
|
|
this.options.min = minDate; |
|
|
|
this.options.min = minDate; |
|
|
|
this.year.setMinDate(minDate); |
|
|
|
this.year.setMinDate(minDate); |
|
|
|
|
|
|
|
this._refreshMonth(); |
|
|
|
|
|
|
|
this._checkLeftValid(); |
|
|
|
|
|
|
|
this._checkRightValid(); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
setMaxDate: function (maxDate) { |
|
|
|
setMaxDate: function (maxDate) { |
|
|
|
this.options.max = maxDate; |
|
|
|
this.options.max = maxDate; |
|
|
|
this.year.setMaxDate(maxDate); |
|
|
|
this.year.setMaxDate(maxDate); |
|
|
|
|
|
|
|
this._refreshMonth(); |
|
|
|
|
|
|
|
this._checkLeftValid(); |
|
|
|
|
|
|
|
this._checkRightValid(); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
setValue: function (ob) { |
|
|
|
setValue: function (ob) { |
|
|
|