diff --git a/changelog.md b/changelog.md index e2e6d9c9e..d0aa79f1b 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,6 @@ # 更新日志 2.0(2021-03) +- 时间类型控件无翻页限制 - 时间类型控件优化动态时间面板的交互 2.0(2021-02) diff --git a/src/widget/date/calendar/picker.year.js b/src/widget/date/calendar/picker.year.js index f07941be1..ac94ecd2b 100644 --- a/src/widget/date/calendar/picker.year.js +++ b/src/widget/date/calendar/picker.year.js @@ -83,9 +83,7 @@ BI.YearPicker = BI.inherit(BI.Widget, { width: 25 }] }); - this.setValue({ - year: this._year - }); + this.setValue(this._year); }, _checkLeftValid: function () { diff --git a/src/widget/date/calendar/popup.month.js b/src/widget/date/calendar/popup.month.js index 251511e77..2add27d54 100644 --- a/src/widget/date/calendar/popup.month.js +++ b/src/widget/date/calendar/popup.month.js @@ -18,6 +18,8 @@ BI.MonthPopup = BI.inherit(BI.Widget, { BI.MonthPopup.superclass._init.apply(this, arguments); var self = this, o = this.options; + this.selectedMonth = BI.getDate().getMonth() + 1; + this.month = BI.createWidget({ type: "bi.button_group", element: this, @@ -38,7 +40,8 @@ BI.MonthPopup = BI.inherit(BI.Widget, { value: o.value }); - this.month.on(BI.Controller.EVENT_CHANGE, function (type) { + this.month.on(BI.Controller.EVENT_CHANGE, function (type, value) { + self.selectedMonth = value; self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); if (type === BI.Events.CLICK) { self.fireEvent(BI.MonthPopup.EVENT_CHANGE); @@ -82,11 +85,12 @@ BI.MonthPopup = BI.inherit(BI.Widget, { }, getValue: function () { - return this.month.getValue()[0]; + return this.selectedMonth; }, setValue: function (v) { v = BI.parseInt(v); + this.selectedMonth = v; this.month.setValue([v]); } }); diff --git a/src/widget/date/calendar/popup.year.js b/src/widget/date/calendar/popup.year.js index 7480c9d4d..8c6c4d614 100644 --- a/src/widget/date/calendar/popup.year.js +++ b/src/widget/date/calendar/popup.year.js @@ -119,12 +119,13 @@ BI.YearPopup = BI.inherit(BI.Widget, { setValue: function (v) { var o = this.options; v = BI.parseInt(v); + // 切换年不受范围限制 // 对于年控件来说,只要传入的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(); - } + // 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(); + // } this.selectedYear = v; this.navigation.setSelect(BI.YearCalendar.getPageByYear(v)); diff --git a/src/widget/datepane/datepane.js b/src/widget/datepane/datepane.js index d83b72022..3537797c3 100644 --- a/src/widget/datepane/datepane.js +++ b/src/widget/datepane/datepane.js @@ -123,7 +123,7 @@ BI.DynamicDatePane = BI.inherit(BI.Widget, { action: function () { var type = self.dateTab.getSelect(); if (type === BI.DynamicDateCombo.Dynamic) { - self.dynamicPane.checkValidation(true) && self.fireEvent(BI.DynamicDatePopup.BUTTON_OK_EVENT_CHANGE); + self.dynamicPane.checkValidation(true) && self.fireEvent(BI.DynamicDatePopup.EVENT_CHANGE); } else { self.fireEvent(BI.DynamicDatePane.EVENT_CHANGE); } diff --git a/src/widget/datetimepane/datetimepane.js b/src/widget/datetimepane/datetimepane.js index 4b971aa8c..166d016e8 100644 --- a/src/widget/datetimepane/datetimepane.js +++ b/src/widget/datetimepane/datetimepane.js @@ -123,7 +123,7 @@ BI.DynamicDateTimePane = BI.inherit(BI.Widget, { action: function () { var type = self.dateTab.getSelect(); if (type === BI.DynamicDateCombo.Dynamic) { - self.dynamicPane.checkValidation(true) && self.fireEvent(BI.DynamicDatePopup.BUTTON_OK_EVENT_CHANGE); + self.dynamicPane.checkValidation(true) && self.fireEvent(BI.DynamicDatePane.EVENT_CHANGE); } else { self.fireEvent(BI.DynamicDatePane.EVENT_CHANGE); } diff --git a/src/widget/dynamicdate/dynamicdate.combo.js b/src/widget/dynamicdate/dynamicdate.combo.js index 05f48e61e..a99fa2ede 100644 --- a/src/widget/dynamicdate/dynamicdate.combo.js +++ b/src/widget/dynamicdate/dynamicdate.combo.js @@ -271,10 +271,13 @@ BI.DynamicDateCombo = BI.inherit(BI.Single, { }, _checkValue: function (v) { + var o = this.options; switch (v.type) { case BI.DynamicDateCombo.Dynamic: return BI.isNotEmptyObject(v.value); case BI.DynamicDateCombo.Static: + var value = v.value || {}; + return !BI.checkDateVoid(value.year, value.month, value.day, o.minDate, o.maxDate)[0]; default: return true; } diff --git a/src/widget/dynamicdatetime/dynamicdatetime.combo.js b/src/widget/dynamicdatetime/dynamicdatetime.combo.js index 05f63156b..915430b12 100644 --- a/src/widget/dynamicdatetime/dynamicdatetime.combo.js +++ b/src/widget/dynamicdatetime/dynamicdatetime.combo.js @@ -279,10 +279,13 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, { }, _checkValue: function (v) { + var o = this.options; switch (v.type) { case BI.DynamicDateCombo.Dynamic: return BI.isNotEmptyObject(v.value); case BI.DynamicDateCombo.Static: + var value = v.value || {}; + return !BI.checkDateVoid(value.year, value.month, value.day, o.minDate, o.maxDate)[0]; default: return true; } diff --git a/src/widget/yearmonth/combo.yearmonth.js b/src/widget/yearmonth/combo.yearmonth.js index 3bb38968f..d1500d969 100644 --- a/src/widget/yearmonth/combo.yearmonth.js +++ b/src/widget/yearmonth/combo.yearmonth.js @@ -99,7 +99,10 @@ BI.DynamicYearMonthCombo = BI.inherit(BI.Single, { }, { eventName: BI.DynamicYearMonthPopup.BUTTON_OK_EVENT_CHANGE, action: function () { - self.setValue(self.popup.getValue()); + var value = self.popup.getValue(); + if (self._checkValue(value)) { + self.setValue(value); + } self.combo.hideView(); self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM); } @@ -159,6 +162,19 @@ BI.DynamicYearMonthCombo = BI.inherit(BI.Single, { } }, + _checkValue: function (v) { + var o = this.options; + switch (v.type) { + case BI.DynamicDateCombo.Dynamic: + return BI.isNotEmptyObject(v.value); + case BI.DynamicDateCombo.Static: + var value = v.value || {}; + return !BI.checkDateVoid(value.year, value.month, 1, o.minDate, o.maxDate)[0]; + default: + return true; + } + }, + setMinDate: function (minDate) { var o = this.options; o.minDate = minDate; diff --git a/src/widget/yearquarter/combo.yearquarter.js b/src/widget/yearquarter/combo.yearquarter.js index 6812ec99c..fca8ce2f1 100644 --- a/src/widget/yearquarter/combo.yearquarter.js +++ b/src/widget/yearquarter/combo.yearquarter.js @@ -99,7 +99,10 @@ BI.DynamicYearQuarterCombo = BI.inherit(BI.Widget, { }, { eventName: BI.DynamicYearQuarterPopup.BUTTON_OK_EVENT_CHANGE, action: function () { - self.setValue(self.popup.getValue()); + var value = self.popup.getValue(); + if (self._checkValue(value)) { + self.setValue(value); + } self.combo.hideView(); self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM); } @@ -159,6 +162,19 @@ BI.DynamicYearQuarterCombo = BI.inherit(BI.Widget, { } }, + _checkValue: function (v) { + var o = this.options; + switch (v.type) { + case BI.DynamicDateCombo.Dynamic: + return BI.isNotEmptyObject(v.value); + case BI.DynamicDateCombo.Static: + var value = v.value || {}; + return !BI.checkDateVoid(value.year, (value.quarter - 1) * 3 + 1, 1, o.minDate, o.maxDate)[0]; + default: + return true; + } + }, + setMinDate: function (minDate) { var o = this.options; o.minDate = minDate;