From e6dfde7c671bbf8a7e1f3724c70c23e819e4dad6 Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Mon, 12 Jul 2021 13:44:09 +0800 Subject: [PATCH 1/3] =?UTF-8?q?BI-84927=20=E7=BB=86=E5=8C=96=E6=97=A5?= =?UTF-8?q?=E6=9C=9F=E7=B1=BB=E5=9E=8B=E6=8E=A7=E4=BB=B6=E6=A0=87=E7=BA=A2?= =?UTF-8?q?=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- changelog.md | 1 + src/widget/dynamicdate/dynamicdate.trigger.js | 18 ++++++++++++++++-- .../dynamicdatetime/dynamicdatetime.trigger.js | 18 ++++++++++++++++-- src/widget/year/trigger.year.js | 12 ++++++++++-- src/widget/yearmonth/trigger.yearmonth.js | 18 +++++++++++++++++- src/widget/yearquarter/trigger.yearquarter.js | 16 ++++++++++++++-- 6 files changed, 74 insertions(+), 9 deletions(-) diff --git a/changelog.md b/changelog.md index 5185abbcf7..4506df6804 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,6 @@ # 更新日志 2.0(2021-07) +- 优化了日期类型控件标红时的报错提示 - 支持虚拟dom - 修复了树控件节点未初始化时调用树的getValue始终为空的问题 diff --git a/src/widget/dynamicdate/dynamicdate.trigger.js b/src/widget/dynamicdate/dynamicdate.trigger.js index ae8fcda030..6a6170e917 100644 --- a/src/widget/dynamicdate/dynamicdate.trigger.js +++ b/src/widget/dynamicdate/dynamicdate.trigger.js @@ -22,6 +22,8 @@ BI.DynamicDateTrigger = BI.inherit(BI.Trigger, { BI.DynamicDateTrigger.superclass._init.apply(this, arguments); var self = this, o = this.options, c = this._const; this.storeTriggerValue = ""; + var start = BI.parseDateTime(o.min, "%Y-%X-%d"); + var end = BI.parseDateTime(o.max, "%Y-%X-%d"); this.editor = BI.createWidget({ type: "bi.sign_editor", height: o.height, @@ -42,11 +44,23 @@ BI.DynamicDateTrigger = BI.inherit(BI.Trigger, { vgap: c.vgap, allowBlank: true, watermark: BI.isKey(o.watermark) ? o.watermark : BI.i18nText("BI-Basic_Unrestricted"), - errorText: function () { + errorText: function (v) { var str = ""; if (!BI.isKey(o.format)) { - str = self.editor.isEditing() ? BI.i18nText("BI-Date_Trigger_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; }, title: BI.bind(this._getTitle, this) diff --git a/src/widget/dynamicdatetime/dynamicdatetime.trigger.js b/src/widget/dynamicdatetime/dynamicdatetime.trigger.js index 53fd8ef6b7..1d2066516b 100644 --- a/src/widget/dynamicdatetime/dynamicdatetime.trigger.js +++ b/src/widget/dynamicdatetime/dynamicdatetime.trigger.js @@ -22,6 +22,8 @@ BI.DynamicDateTimeTrigger = BI.inherit(BI.Trigger, { BI.DynamicDateTimeTrigger.superclass._init.apply(this, arguments); var self = this, o = this.options, c = this._const; this.storeTriggerValue = ""; + var start = BI.parseDateTime(o.min, "%Y-%X-%d"); + var end = BI.parseDateTime(o.max, "%Y-%X-%d"); this.editor = BI.createWidget({ type: "bi.sign_editor", height: o.height, @@ -42,11 +44,23 @@ BI.DynamicDateTimeTrigger = BI.inherit(BI.Trigger, { vgap: c.vgap, allowBlank: true, watermark: BI.isKey(o.watermark) ? o.watermark : BI.i18nText("BI-Basic_Unrestricted"), - errorText: function () { + errorText: function (v) { var str = ""; 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; }, title: BI.bind(this._getTitle, this) diff --git a/src/widget/year/trigger.year.js b/src/widget/year/trigger.year.js index 577e9c3172..be289ee71d 100644 --- a/src/widget/year/trigger.year.js +++ b/src/widget/year/trigger.year.js @@ -22,6 +22,8 @@ BI.DynamicYearTrigger = BI.inherit(BI.Trigger, { _init: function () { BI.DynamicYearTrigger.superclass._init.apply(this, arguments); 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({ type: "bi.sign_editor", height: o.height, @@ -35,9 +37,15 @@ BI.DynamicYearTrigger = BI.inherit(BI.Trigger, { vgap: c.vgap, watermark: BI.i18nText("BI-Basic_Unrestricted"), allowBlank: true, - errorText: function () { + errorText: function (v) { + 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 () { self.fireEvent(BI.DynamicYearTrigger.EVENT_KEY_DOWN, arguments); diff --git a/src/widget/yearmonth/trigger.yearmonth.js b/src/widget/yearmonth/trigger.yearmonth.js index 0266d7aa45..a41747a8c0 100644 --- a/src/widget/yearmonth/trigger.yearmonth.js +++ b/src/widget/yearmonth/trigger.yearmonth.js @@ -21,6 +21,9 @@ BI.DynamicYearMonthTrigger = BI.inherit(BI.Trigger, { BI.DynamicYearMonthTrigger.superclass._init.apply(this, arguments); 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.monthEditor = this._createEditor(false); @@ -62,6 +65,8 @@ BI.DynamicYearMonthTrigger = BI.inherit(BI.Trigger, { _createEditor: function (isYear) { 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({ type: "bi.sign_editor", height: o.height, @@ -78,7 +83,18 @@ BI.DynamicYearMonthTrigger = BI.inherit(BI.Trigger, { }, watermark: BI.i18nText("BI-Basic_Unrestricted"), errorText: function (v) { - return BI.i18nText("BI-Year_Trigger_Invalid_Text"); + 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-Basic_Year_Month_Range_Error", + start.getFullYear(), + start.getMonth() + 1, + end.getFullYear(), + end.getMonth() + 1 + ); }, hgap: c.hgap, vgap: c.vgap, diff --git a/src/widget/yearquarter/trigger.yearquarter.js b/src/widget/yearquarter/trigger.yearquarter.js index eb807eff27..bf19e80cb9 100644 --- a/src/widget/yearquarter/trigger.yearquarter.js +++ b/src/widget/yearquarter/trigger.yearquarter.js @@ -60,6 +60,8 @@ BI.DynamicYearQuarterTrigger = BI.inherit(BI.Trigger, { _createEditor: function (isYear) { 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({ type: "bi.sign_editor", height: o.height, @@ -75,12 +77,22 @@ BI.DynamicYearQuarterTrigger = BI.inherit(BI.Trigger, { return false; }, errorText: function (v) { - return BI.i18nText("BI-Year_Trigger_Invalid_Text"); + 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-Basic_Year_Quarter_Range_Error", + start.getFullYear(), + BI.getQuarter(start), + end.getFullYear(), + BI.getQuarter(end) + ); }, watermark: BI.i18nText("BI-Basic_Unrestricted"), hgap: c.hgap, vgap: c.vgap, - title: "", allowBlank: true }); editor.on(BI.SignEditor.EVENT_KEY_DOWN, function () { From c8a2c2577a554859662dc2b3e800a0ea3a8a9836 Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Mon, 12 Jul 2021 14:04:57 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/widget/dynamicdate/dynamicdate.trigger.js | 4 ++-- src/widget/dynamicdatetime/dynamicdatetime.trigger.js | 4 ++-- src/widget/year/trigger.year.js | 5 +++-- src/widget/yearmonth/trigger.yearmonth.js | 5 +++-- src/widget/yearquarter/trigger.yearquarter.js | 5 +++-- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/widget/dynamicdate/dynamicdate.trigger.js b/src/widget/dynamicdate/dynamicdate.trigger.js index 6a6170e917..807d6e3a53 100644 --- a/src/widget/dynamicdate/dynamicdate.trigger.js +++ b/src/widget/dynamicdate/dynamicdate.trigger.js @@ -22,8 +22,6 @@ BI.DynamicDateTrigger = BI.inherit(BI.Trigger, { BI.DynamicDateTrigger.superclass._init.apply(this, arguments); var self = this, o = this.options, c = this._const; this.storeTriggerValue = ""; - var start = BI.parseDateTime(o.min, "%Y-%X-%d"); - var end = BI.parseDateTime(o.max, "%Y-%X-%d"); this.editor = BI.createWidget({ type: "bi.sign_editor", height: o.height, @@ -50,6 +48,8 @@ BI.DynamicDateTrigger = BI.inherit(BI.Trigger, { if (!self._dateCheck(v)) { str = self.editor.isEditing() ? BI.i18nText("BI-Date_Trigger_Error_Text") : BI.i18nText("BI-Year_Trigger_Invalid_Text"); } else { + var start = BI.parseDateTime(o.min, "%Y-%X-%d"); + var end = BI.parseDateTime(o.max, "%Y-%X-%d"); str = BI.i18nText("BI-Basic_Date_Range_Error", start.getFullYear(), start.getMonth() + 1, diff --git a/src/widget/dynamicdatetime/dynamicdatetime.trigger.js b/src/widget/dynamicdatetime/dynamicdatetime.trigger.js index 1d2066516b..6e23f36544 100644 --- a/src/widget/dynamicdatetime/dynamicdatetime.trigger.js +++ b/src/widget/dynamicdatetime/dynamicdatetime.trigger.js @@ -22,8 +22,6 @@ BI.DynamicDateTimeTrigger = BI.inherit(BI.Trigger, { BI.DynamicDateTimeTrigger.superclass._init.apply(this, arguments); var self = this, o = this.options, c = this._const; this.storeTriggerValue = ""; - var start = BI.parseDateTime(o.min, "%Y-%X-%d"); - var end = BI.parseDateTime(o.max, "%Y-%X-%d"); this.editor = BI.createWidget({ type: "bi.sign_editor", height: o.height, @@ -50,6 +48,8 @@ BI.DynamicDateTimeTrigger = BI.inherit(BI.Trigger, { if (!self._dateCheck(v)) { str = self.editor.isEditing() ? BI.i18nText("BI-Date_Trigger_Error_Text") : BI.i18nText("BI-Year_Trigger_Invalid_Text"); } else { + var start = BI.parseDateTime(o.min, "%Y-%X-%d"); + var end = BI.parseDateTime(o.max, "%Y-%X-%d"); str = BI.i18nText("BI-Basic_Date_Range_Error", start.getFullYear(), start.getMonth() + 1, diff --git a/src/widget/year/trigger.year.js b/src/widget/year/trigger.year.js index be289ee71d..545f422f5c 100644 --- a/src/widget/year/trigger.year.js +++ b/src/widget/year/trigger.year.js @@ -22,8 +22,6 @@ BI.DynamicYearTrigger = BI.inherit(BI.Trigger, { _init: function () { BI.DynamicYearTrigger.superclass._init.apply(this, arguments); 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({ type: "bi.sign_editor", height: o.height, @@ -39,6 +37,9 @@ BI.DynamicYearTrigger = BI.inherit(BI.Trigger, { allowBlank: true, errorText: function (v) { if (BI.isPositiveInteger(v)) { + var start = BI.parseDateTime(o.min, "%Y-%X-%d"); + var end = BI.parseDateTime(o.max, "%Y-%X-%d"); + return BI.i18nText("BI-Basic_Year_Range_Error", start.getFullYear(), end.getFullYear()); diff --git a/src/widget/yearmonth/trigger.yearmonth.js b/src/widget/yearmonth/trigger.yearmonth.js index a41747a8c0..c08e1e67f3 100644 --- a/src/widget/yearmonth/trigger.yearmonth.js +++ b/src/widget/yearmonth/trigger.yearmonth.js @@ -65,8 +65,6 @@ BI.DynamicYearMonthTrigger = BI.inherit(BI.Trigger, { _createEditor: function (isYear) { 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({ type: "bi.sign_editor", height: o.height, @@ -89,6 +87,9 @@ BI.DynamicYearMonthTrigger = BI.inherit(BI.Trigger, { return BI.i18nText("BI-Year_Trigger_Invalid_Text"); } + var start = BI.parseDateTime(o.min, "%Y-%X-%d"); + var end = BI.parseDateTime(o.max, "%Y-%X-%d"); + return BI.i18nText("BI-Basic_Year_Month_Range_Error", start.getFullYear(), start.getMonth() + 1, diff --git a/src/widget/yearquarter/trigger.yearquarter.js b/src/widget/yearquarter/trigger.yearquarter.js index bf19e80cb9..2d4a3f06e2 100644 --- a/src/widget/yearquarter/trigger.yearquarter.js +++ b/src/widget/yearquarter/trigger.yearquarter.js @@ -60,8 +60,6 @@ BI.DynamicYearQuarterTrigger = BI.inherit(BI.Trigger, { _createEditor: function (isYear) { 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({ type: "bi.sign_editor", height: o.height, @@ -83,6 +81,9 @@ BI.DynamicYearQuarterTrigger = BI.inherit(BI.Trigger, { return BI.i18nText("BI-Year_Trigger_Invalid_Text"); } + var start = BI.parseDateTime(o.min, "%Y-%X-%d"); + var end = BI.parseDateTime(o.max, "%Y-%X-%d"); + return BI.i18nText("BI-Basic_Year_Quarter_Range_Error", start.getFullYear(), BI.getQuarter(start), From 3f7e29498b796e556b74594397d703daf9acf5ca Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Mon, 12 Jul 2021 14:06:14 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/widget/yearmonth/trigger.yearmonth.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/widget/yearmonth/trigger.yearmonth.js b/src/widget/yearmonth/trigger.yearmonth.js index c08e1e67f3..021c52fe6c 100644 --- a/src/widget/yearmonth/trigger.yearmonth.js +++ b/src/widget/yearmonth/trigger.yearmonth.js @@ -21,9 +21,6 @@ BI.DynamicYearMonthTrigger = BI.inherit(BI.Trigger, { BI.DynamicYearMonthTrigger.superclass._init.apply(this, arguments); 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.monthEditor = this._createEditor(false);