Browse Source

Pull request #3103: REPORT-80978 fix: DynamicYearMonthPopup 左右切换年份后,默认选中消失

Merge in VISUAL/fineui from ~DAILER/fineui:master to master

* commit 'c5150fce697b977198e126198dbb1f82eae3ddf4':
  REPORT-80978 fix: DynamicYearMonthPopup 左右切换年份后,默认选中消失
es6
Dailer-刘荣歆 2 years ago
parent
commit
841311d73a
  1. 32
      src/widget/yearmonth/card.static.yearmonth.js

32
src/widget/yearmonth/card.static.yearmonth.js

@ -9,13 +9,7 @@ BI.StaticYearMonthCard = BI.inherit(BI.Widget, {
var self = this;
// 纵向排列月
var month = [1, 7, 2, 8, 3, 9, 4, 10, 5, 11, 6, 12];
var items = [];
items.push(month.slice(0, 2));
items.push(month.slice(2, 4));
items.push(month.slice(4, 6));
items.push(month.slice(6, 8));
items.push(month.slice(8, 10));
items.push(month.slice(10, 12));
var items = BI.chunk(month, 2);
return BI.map(items, function (i, item) {
return BI.map(item, function (j, td) {
return {
@ -57,10 +51,7 @@ BI.StaticYearMonthCard = BI.inherit(BI.Widget, {
action: function () {
var value = this.getValue();
self._checkMonthStatus(value);
self.setValue({
year: value,
month: self.selectedMonth
});
self._setYear(value);
}
}]
}, {
@ -106,7 +97,8 @@ BI.StaticYearMonthCard = BI.inherit(BI.Widget, {
var o = this.options;
var minDate = BI.parseDateTime(o.min, "%Y-%X-%d"), maxDate = BI.parseDateTime(o.max, "%Y-%X-%d");
var minYear = minDate.getFullYear(), maxYear = maxDate.getFullYear();
var minMonth = 0; var maxMonth = 11;
var minMonth = 0;
var maxMonth = 11;
minYear === year && (minMonth = minDate.getMonth());
maxYear === year && (maxMonth = maxDate.getMonth());
var yearInvalid = year < minYear || year > maxYear;
@ -116,6 +108,22 @@ BI.StaticYearMonthCard = BI.inherit(BI.Widget, {
});
},
_setYear: function (year) {
var o = this.options;
var dateVoid = BI.checkDateVoid(year, this.selectedMonth, 1, o.min, o.max);
// 在切换年的时候,如果月份不在区间内了,取消选中
if (BI.contains(["y", "m"], dateVoid[0])) {
this.selectedYear = year;
this.month.setValue();
return;
}
this.selectedYear = year;
this.month.setValue(this.selectedMonth);
},
setMinDate: function (minDate) {
if (this.options.min !== minDate) {
this.options.min = minDate;

Loading…
Cancel
Save