diff --git a/changelog.md b/changelog.md index fc788165f..fd7e96c5c 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,6 @@ # 更新日志 2.0(2021-01) +- 修改了日期下拉面板中的当前时间按钮的交互效果 - 新增年区间和年季度区间控件 - 日期类型控件不操作下拉面板收起不发Confirm事件 - 日期类型控件全系列可设置是否显示动态日期 diff --git a/src/widget/dynamicdate/dynamicdate.popup.js b/src/widget/dynamicdate/dynamicdate.popup.js index 30d8e955c..d004604fe 100644 --- a/src/widget/dynamicdate/dynamicdate.popup.js +++ b/src/widget/dynamicdate/dynamicdate.popup.js @@ -40,8 +40,9 @@ BI.DynamicDatePopup = BI.inherit(BI.Widget, { shadow: true, textHeight: c.buttonHeight - 1, text: BI.i18nText("BI-Multi_Date_Today"), + disabled: this._checkTodayValid(), ref: function () { - self.textButton = this; + self.todayButton = this; }, listeners: [{ eventName: BI.TextButton.EVENT_CHANGE, @@ -169,13 +170,13 @@ BI.DynamicDatePopup = BI.inherit(BI.Widget, { _setInnerValue: function () { if (this.dateTab.getSelect() === BI.DynamicDateCombo.Static) { - this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today")); - this.textButton.setEnable(true); + this.todayButton.setValue(BI.i18nText("BI-Multi_Date_Today")); + this.textButton.setEnable(!this._checkTodayValid()); } else { var date = BI.DynamicDateHelper.getCalculation(this.dynamicPane.getValue()); date = BI.print(date, "%Y-%X-%d"); - this.textButton.setValue(date); - this.textButton.setEnable(false); + this.todayButton.setValue(date); + this.todayButton.setEnable(false); } }, @@ -183,6 +184,12 @@ BI.DynamicDatePopup = BI.inherit(BI.Widget, { return BI.isNull(value) || BI.isEmptyObject(value) || BI.isEmptyString(value); }, + _checkTodayValid: function () { + var o = this.options; + var today = BI.getDate(); + return !!BI.checkDateVoid(today.getFullYear(), today.getMonth() + 1, today.getDate(), o.min, o.max)[0]; + }, + setMinDate: function (minDate) { if (this.options.min !== minDate) { this.options.min = minDate; @@ -221,12 +228,12 @@ BI.DynamicDatePopup = BI.inherit(BI.Widget, { month: date.getMonth() + 1, day: date.getDate() }); - this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today")); + this.todayButton.setValue(BI.i18nText("BI-Multi_Date_Today")); } else { this.ymd.setValue(value); - this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today")); + this.todayButton.setValue(BI.i18nText("BI-Multi_Date_Today")); } - this.textButton.setEnable(true); + this.todayButton.setEnable(!this._checkTodayValid()); break; } }, diff --git a/src/widget/dynamicdatetime/dynamicdatetime.popup.js b/src/widget/dynamicdatetime/dynamicdatetime.popup.js index 1bb404717..f38528f36 100644 --- a/src/widget/dynamicdatetime/dynamicdatetime.popup.js +++ b/src/widget/dynamicdatetime/dynamicdatetime.popup.js @@ -40,8 +40,9 @@ BI.DynamicDateTimePopup = BI.inherit(BI.Widget, { textHeight: c.buttonHeight - 1, shadow: true, text: BI.i18nText("BI-Multi_Date_Today"), + disabled: this._checkTodayValid(), ref: function () { - self.textButton = this; + self.todayButton = this; }, listeners: [{ eventName: BI.TextButton.EVENT_CHANGE, @@ -177,13 +178,13 @@ BI.DynamicDateTimePopup = BI.inherit(BI.Widget, { _setInnerValue: function () { if (this.dateTab.getSelect() === BI.DynamicDateCombo.Static) { - this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today")); - this.textButton.setEnable(true); + this.todayButton.setValue(BI.i18nText("BI-Multi_Date_Today")); + this.todayButton.setEnable(!this._checkTodayValid()); } else { var date = BI.DynamicDateHelper.getCalculation(this.dynamicPane.getValue()); date = BI.print(date, "%Y-%X-%d"); - this.textButton.setValue(date); - this.textButton.setEnable(false); + this.todayButton.setValue(date); + this.todayButton.setEnable(false); } }, @@ -191,6 +192,12 @@ BI.DynamicDateTimePopup = BI.inherit(BI.Widget, { return BI.isNull(value) || BI.isEmptyObject(value) || BI.isEmptyString(value); }, + _checkTodayValid: function () { + var o = this.options; + var today = BI.getDate(); + return !!BI.checkDateVoid(today.getFullYear(), today.getMonth() + 1, today.getDate(), o.min, o.max)[0]; + }, + setMinDate: function (minDate) { if (this.options.min !== minDate) { this.options.min = minDate; @@ -228,7 +235,7 @@ BI.DynamicDateTimePopup = BI.inherit(BI.Widget, { day: date.getDate() }); this.timeSelect.setValue(); - this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today")); + this.todayButton.setValue(BI.i18nText("BI-Multi_Date_Today")); } else { this.ymd.setValue(value); this.timeSelect.setValue({ @@ -236,9 +243,9 @@ BI.DynamicDateTimePopup = BI.inherit(BI.Widget, { minute: value.minute, second: value.second }); - this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today")); + this.todayButton.setValue(BI.i18nText("BI-Multi_Date_Today")); } - this.textButton.setEnable(true); + this.todayButton.setEnable(!this._checkTodayValid()); break; } }, diff --git a/src/widget/year/combo.year.js b/src/widget/year/combo.year.js index d329bd521..830af2988 100644 --- a/src/widget/year/combo.year.js +++ b/src/widget/year/combo.year.js @@ -63,6 +63,7 @@ BI.DynamicYearCombo = BI.inherit(BI.Widget, { isNeedAdjustHeight: false, isNeedAdjustWidth: false, el: this.trigger, + destroyWhenHide: true, popup: { minWidth: 85, stopPropagation: false, diff --git a/src/widget/year/popup.year.js b/src/widget/year/popup.year.js index 81667384a..d9ea9a249 100644 --- a/src/widget/year/popup.year.js +++ b/src/widget/year/popup.year.js @@ -48,8 +48,9 @@ BI.DynamicYearPopup = BI.inherit(BI.Widget, { cls: "bi-split-left bi-split-right bi-high-light bi-split-top", shadow: true, text: BI.i18nText("BI-Basic_Current_Year"), + disabled: this._checkTodayValid(), ref: function () { - self.textButton = this; + self.yearButton = this; }, listeners: [{ eventName: BI.TextButton.EVENT_CHANGE, @@ -78,16 +79,22 @@ BI.DynamicYearPopup = BI.inherit(BI.Widget, { _setInnerValue: function () { if (this.dateTab.getSelect() === BI.DynamicDateCombo.Static) { - this.textButton.setValue(BI.i18nText("BI-Basic_Current_Year")); - this.textButton.setEnable(true); + this.yearButton.setValue(BI.i18nText("BI-Basic_Current_Year")); + this.yearButton.setEnable(!this._checkYearValid()); } else { var date = BI.DynamicDateHelper.getCalculation(this.dynamicPane.getValue()); date = BI.print(date, "%Y"); - this.textButton.setValue(date); - this.textButton.setEnable(false); + this.yearButton.setValue(date); + this.yearButton.setEnable(false); } }, + _checkYearValid: function () { + var o = this.options; + var today = BI.getDate(); + return !!BI.checkDateVoid(today.getFullYear(), today.getMonth() + 1, today.getDate(), o.min, o.max)[0]; + }, + _getTabJson: function () { var self = this, o = this.options; return { @@ -176,6 +183,12 @@ BI.DynamicYearPopup = BI.inherit(BI.Widget, { }; }, + _checkTodayValid: function () { + var o = this.options; + var today = BI.getDate(); + return !!BI.checkDateVoid(today.getFullYear(), today.getMonth() + 1, today.getDate(), o.min, o.max)[0]; + }, + setMinDate: function (minDate) { if (this.options.min !== minDate) { this.options.min = minDate; @@ -208,8 +221,8 @@ BI.DynamicYearPopup = BI.inherit(BI.Widget, { case BI.DynamicDateCombo.Static: default: this.year.setValue(value); - this.textButton.setValue(BI.i18nText("BI-Basic_Current_Year")); - this.textButton.setEnable(true); + this.yearButton.setValue(BI.i18nText("BI-Basic_Current_Year")); + this.yearButton.setEnable(!this._checkTodayValid()); break; } }, diff --git a/src/widget/yearmonth/combo.yearmonth.js b/src/widget/yearmonth/combo.yearmonth.js index 0976f3657..45713f96c 100644 --- a/src/widget/yearmonth/combo.yearmonth.js +++ b/src/widget/yearmonth/combo.yearmonth.js @@ -61,6 +61,7 @@ BI.DynamicYearMonthCombo = BI.inherit(BI.Single, { isNeedAdjustHeight: false, isNeedAdjustWidth: false, el: this.trigger, + destroyWhenHide: true, popup: { minWidth: 100, stopPropagation: false, diff --git a/src/widget/yearmonth/popup.yearmonth.js b/src/widget/yearmonth/popup.yearmonth.js index c1dc0d058..cb94da3f7 100644 --- a/src/widget/yearmonth/popup.yearmonth.js +++ b/src/widget/yearmonth/popup.yearmonth.js @@ -48,6 +48,7 @@ BI.DynamicYearMonthPopup = BI.inherit(BI.Widget, { textHeight: c.buttonHeight - 1, shadow: true, text: BI.i18nText("BI-Basic_Current_Month"), + disabled: this._checkTodayValid(), ref: function () { self.textButton = this; }, @@ -79,7 +80,7 @@ BI.DynamicYearMonthPopup = BI.inherit(BI.Widget, { _setInnerValue: function () { if (this.dateTab.getSelect() === BI.DynamicDateCombo.Static) { this.textButton.setValue(BI.i18nText("BI-Basic_Current_Month")); - this.textButton.setEnable(true); + this.textButton.setEnable(!this._checkTodayValid()); } else { var date = BI.DynamicDateHelper.getCalculation(this.dynamicPane.getValue()); date = BI.print(date, "%Y-%x"); @@ -88,6 +89,12 @@ BI.DynamicYearMonthPopup = BI.inherit(BI.Widget, { } }, + _checkTodayValid: function () { + var o = this.options; + var today = BI.getDate(); + return !!BI.checkDateVoid(today.getFullYear(), today.getMonth() + 1, today.getDate(), o.min, o.max)[0]; + }, + _getTabJson: function () { var self = this, o = this.options; return { @@ -210,7 +217,7 @@ BI.DynamicYearMonthPopup = BI.inherit(BI.Widget, { default: this.year.setValue(value); this.textButton.setValue(BI.i18nText("BI-Basic_Current_Month")); - this.textButton.setEnable(true); + this.textButton.setEnable(!this._checkTodayValid()); break; } }, diff --git a/src/widget/yearquarter/combo.yearquarter.js b/src/widget/yearquarter/combo.yearquarter.js index 8823af7b6..13fdd8c60 100644 --- a/src/widget/yearquarter/combo.yearquarter.js +++ b/src/widget/yearquarter/combo.yearquarter.js @@ -61,6 +61,7 @@ BI.DynamicYearQuarterCombo = BI.inherit(BI.Widget, { isNeedAdjustHeight: false, isNeedAdjustWidth: false, el: this.trigger, + destroyWhenHide: true, popup: { minWidth: 85, stopPropagation: false, diff --git a/src/widget/yearquarter/popup.yearquarter.js b/src/widget/yearquarter/popup.yearquarter.js index 6b94d9284..9f51cd954 100644 --- a/src/widget/yearquarter/popup.yearquarter.js +++ b/src/widget/yearquarter/popup.yearquarter.js @@ -41,6 +41,7 @@ BI.DynamicYearQuarterPopup = BI.inherit(BI.Widget, { textHeight: c.buttonHeight - 1, shadow: true, text: BI.i18nText("BI-Basic_Current_Quarter"), + disabled: this._checkTodayValid(), ref: function () { self.textButton = this; }, @@ -72,7 +73,7 @@ BI.DynamicYearQuarterPopup = BI.inherit(BI.Widget, { _setInnerValue: function () { if (this.dateTab.getSelect() === BI.DynamicYearQuarterCombo.Static) { this.textButton.setValue(BI.i18nText("BI-Basic_Current_Quarter")); - this.textButton.setEnable(true); + this.textButton.setEnable(!this._checkTodayValid()); } else { var date = BI.DynamicDateHelper.getCalculation(this.dynamicPane.getValue()); date = BI.print(date, "%Y-%Q"); @@ -81,6 +82,12 @@ BI.DynamicYearQuarterPopup = BI.inherit(BI.Widget, { } }, + _checkTodayValid: function () { + var o = this.options; + var today = BI.getDate(); + return !!BI.checkDateVoid(today.getFullYear(), today.getMonth() + 1, today.getDate(), o.min, o.max)[0]; + }, + _getTabJson: function () { var self = this, o = this.options; return { @@ -203,7 +210,7 @@ BI.DynamicYearQuarterPopup = BI.inherit(BI.Widget, { default: this.year.setValue(value); this.textButton.setValue(BI.i18nText("BI-Basic_Current_Quarter")); - this.textButton.setEnable(true); + this.textButton.setEnable(!this._checkTodayValid()); break; } },