Browse Source

BI-81061 日期面板当前时间动态灰化

master
windy 4 years ago
parent
commit
a4337c5a5d
  1. 1
      changelog.md
  2. 23
      src/widget/dynamicdate/dynamicdate.popup.js
  3. 23
      src/widget/dynamicdatetime/dynamicdatetime.popup.js
  4. 1
      src/widget/year/combo.year.js
  5. 27
      src/widget/year/popup.year.js
  6. 1
      src/widget/yearmonth/combo.yearmonth.js
  7. 11
      src/widget/yearmonth/popup.yearmonth.js
  8. 1
      src/widget/yearquarter/combo.yearquarter.js
  9. 11
      src/widget/yearquarter/popup.yearquarter.js

1
changelog.md

@ -1,5 +1,6 @@
# 更新日志 # 更新日志
2.0(2021-01) 2.0(2021-01)
- 修改了日期下拉面板中的当前时间按钮的交互效果
- 新增年区间和年季度区间控件 - 新增年区间和年季度区间控件
- 日期类型控件不操作下拉面板收起不发Confirm事件 - 日期类型控件不操作下拉面板收起不发Confirm事件
- 日期类型控件全系列可设置是否显示动态日期 - 日期类型控件全系列可设置是否显示动态日期

23
src/widget/dynamicdate/dynamicdate.popup.js

@ -40,8 +40,9 @@ BI.DynamicDatePopup = BI.inherit(BI.Widget, {
shadow: true, shadow: true,
textHeight: c.buttonHeight - 1, textHeight: c.buttonHeight - 1,
text: BI.i18nText("BI-Multi_Date_Today"), text: BI.i18nText("BI-Multi_Date_Today"),
disabled: this._checkTodayValid(),
ref: function () { ref: function () {
self.textButton = this; self.todayButton = this;
}, },
listeners: [{ listeners: [{
eventName: BI.TextButton.EVENT_CHANGE, eventName: BI.TextButton.EVENT_CHANGE,
@ -169,13 +170,13 @@ BI.DynamicDatePopup = BI.inherit(BI.Widget, {
_setInnerValue: function () { _setInnerValue: function () {
if (this.dateTab.getSelect() === BI.DynamicDateCombo.Static) { if (this.dateTab.getSelect() === BI.DynamicDateCombo.Static) {
this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today")); this.todayButton.setValue(BI.i18nText("BI-Multi_Date_Today"));
this.textButton.setEnable(true); this.textButton.setEnable(!this._checkTodayValid());
} else { } else {
var date = BI.DynamicDateHelper.getCalculation(this.dynamicPane.getValue()); var date = BI.DynamicDateHelper.getCalculation(this.dynamicPane.getValue());
date = BI.print(date, "%Y-%X-%d"); date = BI.print(date, "%Y-%X-%d");
this.textButton.setValue(date); this.todayButton.setValue(date);
this.textButton.setEnable(false); this.todayButton.setEnable(false);
} }
}, },
@ -183,6 +184,12 @@ BI.DynamicDatePopup = BI.inherit(BI.Widget, {
return BI.isNull(value) || BI.isEmptyObject(value) || BI.isEmptyString(value); 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) { setMinDate: function (minDate) {
if (this.options.min !== minDate) { if (this.options.min !== minDate) {
this.options.min = minDate; this.options.min = minDate;
@ -221,12 +228,12 @@ BI.DynamicDatePopup = BI.inherit(BI.Widget, {
month: date.getMonth() + 1, month: date.getMonth() + 1,
day: date.getDate() day: date.getDate()
}); });
this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today")); this.todayButton.setValue(BI.i18nText("BI-Multi_Date_Today"));
} else { } else {
this.ymd.setValue(value); 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; break;
} }
}, },

23
src/widget/dynamicdatetime/dynamicdatetime.popup.js

@ -40,8 +40,9 @@ BI.DynamicDateTimePopup = BI.inherit(BI.Widget, {
textHeight: c.buttonHeight - 1, textHeight: c.buttonHeight - 1,
shadow: true, shadow: true,
text: BI.i18nText("BI-Multi_Date_Today"), text: BI.i18nText("BI-Multi_Date_Today"),
disabled: this._checkTodayValid(),
ref: function () { ref: function () {
self.textButton = this; self.todayButton = this;
}, },
listeners: [{ listeners: [{
eventName: BI.TextButton.EVENT_CHANGE, eventName: BI.TextButton.EVENT_CHANGE,
@ -177,13 +178,13 @@ BI.DynamicDateTimePopup = BI.inherit(BI.Widget, {
_setInnerValue: function () { _setInnerValue: function () {
if (this.dateTab.getSelect() === BI.DynamicDateCombo.Static) { if (this.dateTab.getSelect() === BI.DynamicDateCombo.Static) {
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());
} else { } else {
var date = BI.DynamicDateHelper.getCalculation(this.dynamicPane.getValue()); var date = BI.DynamicDateHelper.getCalculation(this.dynamicPane.getValue());
date = BI.print(date, "%Y-%X-%d"); date = BI.print(date, "%Y-%X-%d");
this.textButton.setValue(date); this.todayButton.setValue(date);
this.textButton.setEnable(false); this.todayButton.setEnable(false);
} }
}, },
@ -191,6 +192,12 @@ BI.DynamicDateTimePopup = BI.inherit(BI.Widget, {
return BI.isNull(value) || BI.isEmptyObject(value) || BI.isEmptyString(value); 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) { setMinDate: function (minDate) {
if (this.options.min !== minDate) { if (this.options.min !== minDate) {
this.options.min = minDate; this.options.min = minDate;
@ -228,7 +235,7 @@ BI.DynamicDateTimePopup = BI.inherit(BI.Widget, {
day: date.getDate() day: date.getDate()
}); });
this.timeSelect.setValue(); this.timeSelect.setValue();
this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today")); this.todayButton.setValue(BI.i18nText("BI-Multi_Date_Today"));
} else { } else {
this.ymd.setValue(value); this.ymd.setValue(value);
this.timeSelect.setValue({ this.timeSelect.setValue({
@ -236,9 +243,9 @@ BI.DynamicDateTimePopup = BI.inherit(BI.Widget, {
minute: value.minute, minute: value.minute,
second: value.second 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; break;
} }
}, },

1
src/widget/year/combo.year.js

@ -63,6 +63,7 @@ BI.DynamicYearCombo = BI.inherit(BI.Widget, {
isNeedAdjustHeight: false, isNeedAdjustHeight: false,
isNeedAdjustWidth: false, isNeedAdjustWidth: false,
el: this.trigger, el: this.trigger,
destroyWhenHide: true,
popup: { popup: {
minWidth: 85, minWidth: 85,
stopPropagation: false, stopPropagation: false,

27
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", cls: "bi-split-left bi-split-right bi-high-light bi-split-top",
shadow: true, shadow: true,
text: BI.i18nText("BI-Basic_Current_Year"), text: BI.i18nText("BI-Basic_Current_Year"),
disabled: this._checkTodayValid(),
ref: function () { ref: function () {
self.textButton = this; self.yearButton = this;
}, },
listeners: [{ listeners: [{
eventName: BI.TextButton.EVENT_CHANGE, eventName: BI.TextButton.EVENT_CHANGE,
@ -78,16 +79,22 @@ BI.DynamicYearPopup = BI.inherit(BI.Widget, {
_setInnerValue: function () { _setInnerValue: function () {
if (this.dateTab.getSelect() === BI.DynamicDateCombo.Static) { if (this.dateTab.getSelect() === BI.DynamicDateCombo.Static) {
this.textButton.setValue(BI.i18nText("BI-Basic_Current_Year")); this.yearButton.setValue(BI.i18nText("BI-Basic_Current_Year"));
this.textButton.setEnable(true); this.yearButton.setEnable(!this._checkYearValid());
} else { } else {
var date = BI.DynamicDateHelper.getCalculation(this.dynamicPane.getValue()); var date = BI.DynamicDateHelper.getCalculation(this.dynamicPane.getValue());
date = BI.print(date, "%Y"); date = BI.print(date, "%Y");
this.textButton.setValue(date); this.yearButton.setValue(date);
this.textButton.setEnable(false); 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 () { _getTabJson: function () {
var self = this, o = this.options; var self = this, o = this.options;
return { 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) { setMinDate: function (minDate) {
if (this.options.min !== minDate) { if (this.options.min !== minDate) {
this.options.min = minDate; this.options.min = minDate;
@ -208,8 +221,8 @@ BI.DynamicYearPopup = BI.inherit(BI.Widget, {
case BI.DynamicDateCombo.Static: case BI.DynamicDateCombo.Static:
default: default:
this.year.setValue(value); this.year.setValue(value);
this.textButton.setValue(BI.i18nText("BI-Basic_Current_Year")); this.yearButton.setValue(BI.i18nText("BI-Basic_Current_Year"));
this.textButton.setEnable(true); this.yearButton.setEnable(!this._checkTodayValid());
break; break;
} }
}, },

1
src/widget/yearmonth/combo.yearmonth.js

@ -61,6 +61,7 @@ BI.DynamicYearMonthCombo = BI.inherit(BI.Single, {
isNeedAdjustHeight: false, isNeedAdjustHeight: false,
isNeedAdjustWidth: false, isNeedAdjustWidth: false,
el: this.trigger, el: this.trigger,
destroyWhenHide: true,
popup: { popup: {
minWidth: 100, minWidth: 100,
stopPropagation: false, stopPropagation: false,

11
src/widget/yearmonth/popup.yearmonth.js

@ -48,6 +48,7 @@ BI.DynamicYearMonthPopup = BI.inherit(BI.Widget, {
textHeight: c.buttonHeight - 1, textHeight: c.buttonHeight - 1,
shadow: true, shadow: true,
text: BI.i18nText("BI-Basic_Current_Month"), text: BI.i18nText("BI-Basic_Current_Month"),
disabled: this._checkTodayValid(),
ref: function () { ref: function () {
self.textButton = this; self.textButton = this;
}, },
@ -79,7 +80,7 @@ BI.DynamicYearMonthPopup = BI.inherit(BI.Widget, {
_setInnerValue: function () { _setInnerValue: function () {
if (this.dateTab.getSelect() === BI.DynamicDateCombo.Static) { if (this.dateTab.getSelect() === BI.DynamicDateCombo.Static) {
this.textButton.setValue(BI.i18nText("BI-Basic_Current_Month")); this.textButton.setValue(BI.i18nText("BI-Basic_Current_Month"));
this.textButton.setEnable(true); this.textButton.setEnable(!this._checkTodayValid());
} else { } else {
var date = BI.DynamicDateHelper.getCalculation(this.dynamicPane.getValue()); var date = BI.DynamicDateHelper.getCalculation(this.dynamicPane.getValue());
date = BI.print(date, "%Y-%x"); 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 () { _getTabJson: function () {
var self = this, o = this.options; var self = this, o = this.options;
return { return {
@ -210,7 +217,7 @@ BI.DynamicYearMonthPopup = BI.inherit(BI.Widget, {
default: default:
this.year.setValue(value); this.year.setValue(value);
this.textButton.setValue(BI.i18nText("BI-Basic_Current_Month")); this.textButton.setValue(BI.i18nText("BI-Basic_Current_Month"));
this.textButton.setEnable(true); this.textButton.setEnable(!this._checkTodayValid());
break; break;
} }
}, },

1
src/widget/yearquarter/combo.yearquarter.js

@ -61,6 +61,7 @@ BI.DynamicYearQuarterCombo = BI.inherit(BI.Widget, {
isNeedAdjustHeight: false, isNeedAdjustHeight: false,
isNeedAdjustWidth: false, isNeedAdjustWidth: false,
el: this.trigger, el: this.trigger,
destroyWhenHide: true,
popup: { popup: {
minWidth: 85, minWidth: 85,
stopPropagation: false, stopPropagation: false,

11
src/widget/yearquarter/popup.yearquarter.js

@ -41,6 +41,7 @@ BI.DynamicYearQuarterPopup = BI.inherit(BI.Widget, {
textHeight: c.buttonHeight - 1, textHeight: c.buttonHeight - 1,
shadow: true, shadow: true,
text: BI.i18nText("BI-Basic_Current_Quarter"), text: BI.i18nText("BI-Basic_Current_Quarter"),
disabled: this._checkTodayValid(),
ref: function () { ref: function () {
self.textButton = this; self.textButton = this;
}, },
@ -72,7 +73,7 @@ BI.DynamicYearQuarterPopup = BI.inherit(BI.Widget, {
_setInnerValue: function () { _setInnerValue: function () {
if (this.dateTab.getSelect() === BI.DynamicYearQuarterCombo.Static) { if (this.dateTab.getSelect() === BI.DynamicYearQuarterCombo.Static) {
this.textButton.setValue(BI.i18nText("BI-Basic_Current_Quarter")); this.textButton.setValue(BI.i18nText("BI-Basic_Current_Quarter"));
this.textButton.setEnable(true); this.textButton.setEnable(!this._checkTodayValid());
} else { } else {
var date = BI.DynamicDateHelper.getCalculation(this.dynamicPane.getValue()); var date = BI.DynamicDateHelper.getCalculation(this.dynamicPane.getValue());
date = BI.print(date, "%Y-%Q"); 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 () { _getTabJson: function () {
var self = this, o = this.options; var self = this, o = this.options;
return { return {
@ -203,7 +210,7 @@ BI.DynamicYearQuarterPopup = BI.inherit(BI.Widget, {
default: default:
this.year.setValue(value); this.year.setValue(value);
this.textButton.setValue(BI.i18nText("BI-Basic_Current_Quarter")); this.textButton.setValue(BI.i18nText("BI-Basic_Current_Quarter"));
this.textButton.setEnable(true); this.textButton.setEnable(!this._checkTodayValid());
break; break;
} }
}, },

Loading…
Cancel
Save