Browse Source

REPORT-18389 fix: 限制日期后,年份的选择

es6
windy 5 years ago
parent
commit
4133468906
  1. 2
      src/base/single/button/button.basic.js
  2. 5
      src/case/calendar/calendar.year.js
  3. 5
      src/widget/date/calendar/popup.year.js

2
src/base/single/button/button.basic.js

@ -409,4 +409,4 @@ BI.BasicButton = BI.inherit(BI.Single, {
BI.BasicButton.superclass.destroy.apply(this, arguments); BI.BasicButton.superclass.destroy.apply(this, arguments);
} }
}); });
BI.BasicButton.EVENT_CHANGE = "EVENT_CHANGE"; BI.BasicButton.EVENT_CHANGE = "BasicButton.EVENT_CHANGE";

5
src/case/calendar/calendar.year.js

@ -24,9 +24,12 @@ BI.YearCalendar = BI.inherit(BI.Widget, {
Y = Y | 0; Y = Y | 0;
var start = BI.YearCalendar.getStartYear(Y); var start = BI.YearCalendar.getStartYear(Y);
var items = []; var items = [];
// 对于年控件来说,只要传入的minDate和maxDate的year区间包含v就是合法的
var startDate = BI.parseDateTime(o.min, "%Y-%X-%d");
var endDate = BI.parseDateTime(o.max, "%Y-%X-%d");
BI.each(BI.range(BI.YearCalendar.INTERVAL), function (i) { BI.each(BI.range(BI.YearCalendar.INTERVAL), function (i) {
var td = {}; var td = {};
if (BI.checkDateVoid(start + i, 1, 1, o.min, o.max)[0]) { if (BI.checkDateVoid(start + i, 1, 1, BI.print(BI.getDate(startDate.getFullYear(), 0, 1), "%Y-%X-%d"), BI.print(BI.getDate(endDate.getFullYear(), 0, 1), "%Y-%X-%d"))[0]) {
td.disabled = true; td.disabled = true;
} }
td.text = start + i; td.text = start + i;

5
src/widget/date/calendar/popup.year.js

@ -95,7 +95,10 @@ BI.YearPopup = BI.inherit(BI.Widget, {
setValue: function (v) { setValue: function (v) {
var o = this.options; var o = this.options;
v = BI.parseInt(v); v = BI.parseInt(v);
if (BI.checkDateVoid(v, 1, 1, o.min, o.max)[0]) { // 对于年控件来说,只要传入的minDate和maxDate的year区间包含v就是合法的
var startDate = BI.parseDateTime(o.min, "%Y-%X-%d");
var endDate = BI.parseDateTime(o.max, "%Y-%X-%d");
if (BI.checkDateVoid(v, 1, 1, BI.print(BI.getDate(startDate.getFullYear(), 0, 1), "%Y-%X-%d"), BI.print(BI.getDate(endDate.getFullYear(), 0, 1), "%Y-%X-%d"))[0]) {
v = BI.getDate().getFullYear(); v = BI.getDate().getFullYear();
this.selectedYear = ""; this.selectedYear = "";
this.navigation.setSelect(BI.YearCalendar.getPageByYear(v)); this.navigation.setSelect(BI.YearCalendar.getPageByYear(v));

Loading…
Cancel
Save