Browse Source

BI-84927 细化日期类型控件标红提示

es6
windy 3 years ago
parent
commit
e6dfde7c67
  1. 1
      changelog.md
  2. 16
      src/widget/dynamicdate/dynamicdate.trigger.js
  3. 18
      src/widget/dynamicdatetime/dynamicdatetime.trigger.js
  4. 12
      src/widget/year/trigger.year.js
  5. 16
      src/widget/yearmonth/trigger.yearmonth.js
  6. 14
      src/widget/yearquarter/trigger.yearquarter.js

1
changelog.md

@ -1,5 +1,6 @@
# 更新日志 # 更新日志
2.0(2021-07) 2.0(2021-07)
- 优化了日期类型控件标红时的报错提示
- 支持虚拟dom - 支持虚拟dom
- 修复了树控件节点未初始化时调用树的getValue始终为空的问题 - 修复了树控件节点未初始化时调用树的getValue始终为空的问题

16
src/widget/dynamicdate/dynamicdate.trigger.js

@ -22,6 +22,8 @@ BI.DynamicDateTrigger = BI.inherit(BI.Trigger, {
BI.DynamicDateTrigger.superclass._init.apply(this, arguments); BI.DynamicDateTrigger.superclass._init.apply(this, arguments);
var self = this, o = this.options, c = this._const; var self = this, o = this.options, c = this._const;
this.storeTriggerValue = ""; this.storeTriggerValue = "";
var start = BI.parseDateTime(o.min, "%Y-%X-%d");
var end = BI.parseDateTime(o.max, "%Y-%X-%d");
this.editor = BI.createWidget({ this.editor = BI.createWidget({
type: "bi.sign_editor", type: "bi.sign_editor",
height: o.height, height: o.height,
@ -42,11 +44,23 @@ BI.DynamicDateTrigger = BI.inherit(BI.Trigger, {
vgap: c.vgap, vgap: c.vgap,
allowBlank: true, allowBlank: true,
watermark: BI.isKey(o.watermark) ? o.watermark : BI.i18nText("BI-Basic_Unrestricted"), watermark: BI.isKey(o.watermark) ? o.watermark : BI.i18nText("BI-Basic_Unrestricted"),
errorText: function () { errorText: function (v) {
var str = ""; var str = "";
if (!BI.isKey(o.format)) { if (!BI.isKey(o.format)) {
if (!self._dateCheck(v)) {
str = self.editor.isEditing() ? BI.i18nText("BI-Date_Trigger_Error_Text") : BI.i18nText("BI-Year_Trigger_Invalid_Text"); str = self.editor.isEditing() ? BI.i18nText("BI-Date_Trigger_Error_Text") : BI.i18nText("BI-Year_Trigger_Invalid_Text");
} else {
str = BI.i18nText("BI-Basic_Date_Range_Error",
start.getFullYear(),
start.getMonth() + 1,
start.getDate(),
end.getFullYear(),
end.getMonth() + 1,
end.getDate()
);
}
} }
return str; return str;
}, },
title: BI.bind(this._getTitle, this) title: BI.bind(this._getTitle, this)

18
src/widget/dynamicdatetime/dynamicdatetime.trigger.js

@ -22,6 +22,8 @@ BI.DynamicDateTimeTrigger = BI.inherit(BI.Trigger, {
BI.DynamicDateTimeTrigger.superclass._init.apply(this, arguments); BI.DynamicDateTimeTrigger.superclass._init.apply(this, arguments);
var self = this, o = this.options, c = this._const; var self = this, o = this.options, c = this._const;
this.storeTriggerValue = ""; this.storeTriggerValue = "";
var start = BI.parseDateTime(o.min, "%Y-%X-%d");
var end = BI.parseDateTime(o.max, "%Y-%X-%d");
this.editor = BI.createWidget({ this.editor = BI.createWidget({
type: "bi.sign_editor", type: "bi.sign_editor",
height: o.height, height: o.height,
@ -42,11 +44,23 @@ BI.DynamicDateTimeTrigger = BI.inherit(BI.Trigger, {
vgap: c.vgap, vgap: c.vgap,
allowBlank: true, allowBlank: true,
watermark: BI.isKey(o.watermark) ? o.watermark : BI.i18nText("BI-Basic_Unrestricted"), watermark: BI.isKey(o.watermark) ? o.watermark : BI.i18nText("BI-Basic_Unrestricted"),
errorText: function () { errorText: function (v) {
var str = ""; var str = "";
if (!BI.isKey(o.format)) { if (!BI.isKey(o.format)) {
str = self.editor.isEditing() ? BI.i18nText("BI-Basic_Date_Time_Error_Text") : BI.i18nText("BI-Year_Trigger_Invalid_Text"); if (!self._dateCheck(v)) {
str = self.editor.isEditing() ? BI.i18nText("BI-Date_Trigger_Error_Text") : BI.i18nText("BI-Year_Trigger_Invalid_Text");
} else {
str = BI.i18nText("BI-Basic_Date_Range_Error",
start.getFullYear(),
start.getMonth() + 1,
start.getDate(),
end.getFullYear(),
end.getMonth() + 1,
end.getDate()
);
}
} }
return str; return str;
}, },
title: BI.bind(this._getTitle, this) title: BI.bind(this._getTitle, this)

12
src/widget/year/trigger.year.js

@ -22,6 +22,8 @@ BI.DynamicYearTrigger = BI.inherit(BI.Trigger, {
_init: function () { _init: function () {
BI.DynamicYearTrigger.superclass._init.apply(this, arguments); BI.DynamicYearTrigger.superclass._init.apply(this, arguments);
var self = this, o = this.options, c = this._const; var self = this, o = this.options, c = this._const;
var start = BI.parseDateTime(o.min, "%Y-%X-%d");
var end = BI.parseDateTime(o.max, "%Y-%X-%d");
this.editor = BI.createWidget({ this.editor = BI.createWidget({
type: "bi.sign_editor", type: "bi.sign_editor",
height: o.height, height: o.height,
@ -35,9 +37,15 @@ BI.DynamicYearTrigger = BI.inherit(BI.Trigger, {
vgap: c.vgap, vgap: c.vgap,
watermark: BI.i18nText("BI-Basic_Unrestricted"), watermark: BI.i18nText("BI-Basic_Unrestricted"),
allowBlank: true, allowBlank: true,
errorText: function () { errorText: function (v) {
return BI.i18nText("BI-Year_Trigger_Invalid_Text"); if (BI.isPositiveInteger(v)) {
return BI.i18nText("BI-Basic_Year_Range_Error",
start.getFullYear(),
end.getFullYear());
} }
return BI.i18nText("BI-Year_Trigger_Invalid_Text");
},
}); });
this.editor.on(BI.SignEditor.EVENT_KEY_DOWN, function () { this.editor.on(BI.SignEditor.EVENT_KEY_DOWN, function () {
self.fireEvent(BI.DynamicYearTrigger.EVENT_KEY_DOWN, arguments); self.fireEvent(BI.DynamicYearTrigger.EVENT_KEY_DOWN, arguments);

16
src/widget/yearmonth/trigger.yearmonth.js

@ -21,6 +21,9 @@ BI.DynamicYearMonthTrigger = BI.inherit(BI.Trigger, {
BI.DynamicYearMonthTrigger.superclass._init.apply(this, arguments); BI.DynamicYearMonthTrigger.superclass._init.apply(this, arguments);
var o = this.options; var o = this.options;
var start = BI.parseDateTime(o.min, "%Y-%X-%d");
var end = BI.parseDateTime(o.max, "%Y-%X-%d");
this.yearEditor = this._createEditor(true); this.yearEditor = this._createEditor(true);
this.monthEditor = this._createEditor(false); this.monthEditor = this._createEditor(false);
@ -62,6 +65,8 @@ BI.DynamicYearMonthTrigger = BI.inherit(BI.Trigger, {
_createEditor: function (isYear) { _createEditor: function (isYear) {
var self = this, o = this.options, c = this._const; var self = this, o = this.options, c = this._const;
var start = BI.parseDateTime(o.min, "%Y-%X-%d");
var end = BI.parseDateTime(o.max, "%Y-%X-%d");
var editor = BI.createWidget({ var editor = BI.createWidget({
type: "bi.sign_editor", type: "bi.sign_editor",
height: o.height, height: o.height,
@ -78,7 +83,18 @@ BI.DynamicYearMonthTrigger = BI.inherit(BI.Trigger, {
}, },
watermark: BI.i18nText("BI-Basic_Unrestricted"), watermark: BI.i18nText("BI-Basic_Unrestricted"),
errorText: function (v) { errorText: function (v) {
var year = isYear ? v : self.yearEditor.getValue();
var month = isYear ? self.monthEditor.getValue() : v;
if (!BI.isPositiveInteger(year) || !BI.isPositiveInteger(month) || month > 12) {
return BI.i18nText("BI-Year_Trigger_Invalid_Text"); return BI.i18nText("BI-Year_Trigger_Invalid_Text");
}
return BI.i18nText("BI-Basic_Year_Month_Range_Error",
start.getFullYear(),
start.getMonth() + 1,
end.getFullYear(),
end.getMonth() + 1
);
}, },
hgap: c.hgap, hgap: c.hgap,
vgap: c.vgap, vgap: c.vgap,

14
src/widget/yearquarter/trigger.yearquarter.js

@ -60,6 +60,8 @@ BI.DynamicYearQuarterTrigger = BI.inherit(BI.Trigger, {
_createEditor: function (isYear) { _createEditor: function (isYear) {
var self = this, o = this.options, c = this._const; var self = this, o = this.options, c = this._const;
var start = BI.parseDateTime(o.min, "%Y-%X-%d");
var end = BI.parseDateTime(o.max, "%Y-%X-%d");
var editor = BI.createWidget({ var editor = BI.createWidget({
type: "bi.sign_editor", type: "bi.sign_editor",
height: o.height, height: o.height,
@ -75,12 +77,22 @@ BI.DynamicYearQuarterTrigger = BI.inherit(BI.Trigger, {
return false; return false;
}, },
errorText: function (v) { errorText: function (v) {
var year = isYear ? v : self.yearEditor.getValue();
var quarter = isYear ? self.quarterEditor.getValue() : v;
if (!BI.isPositiveInteger(year) || !BI.isPositiveInteger(quarter) || quarter > 4) {
return BI.i18nText("BI-Year_Trigger_Invalid_Text"); return BI.i18nText("BI-Year_Trigger_Invalid_Text");
}
return BI.i18nText("BI-Basic_Year_Quarter_Range_Error",
start.getFullYear(),
BI.getQuarter(start),
end.getFullYear(),
BI.getQuarter(end)
);
}, },
watermark: BI.i18nText("BI-Basic_Unrestricted"), watermark: BI.i18nText("BI-Basic_Unrestricted"),
hgap: c.hgap, hgap: c.hgap,
vgap: c.vgap, vgap: c.vgap,
title: "",
allowBlank: true allowBlank: true
}); });
editor.on(BI.SignEditor.EVENT_KEY_DOWN, function () { editor.on(BI.SignEditor.EVENT_KEY_DOWN, function () {

Loading…
Cancel
Save