From 2a30a6c59ba1c23a2338249e680b7aadcc3a96d9 Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Tue, 25 Jun 2019 12:19:42 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-18382=20fix:=20=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E5=88=86=E9=9A=94=E7=AC=A6=E7=9A=84=E6=97=A5=E6=9C=9F=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/widget/dynamicdate/dynamicdate.trigger.js | 7 +++++++ .../dynamicdatetime/dynamicdatetime.trigger.js | 13 ++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/widget/dynamicdate/dynamicdate.trigger.js b/src/widget/dynamicdate/dynamicdate.trigger.js index ebec4efc9..8f9067719 100644 --- a/src/widget/dynamicdate/dynamicdate.trigger.js +++ b/src/widget/dynamicdate/dynamicdate.trigger.js @@ -166,6 +166,13 @@ BI.DynamicDateTrigger = BI.inherit(BI.Trigger, { break; } }); + // 这边不能直接用\d+去切日期, 因为format格式可能是20190607这样的没有分割符的 = = + // 先看一下是否是合法的, 如果合法就变成标准格式的走原来的流程, 不合法不关心 + var date = BI.parseDateTime(v, this._getFormatString()); + if(BI.print(date, this._getFormatString()) === v) { + v = BI.print(date, c.compareFormat); + result = [0, 1, 2]; + } var dateArray = v.match(/\d+/g); var newArray = []; BI.each(dateArray, function (idx) { diff --git a/src/widget/dynamicdatetime/dynamicdatetime.trigger.js b/src/widget/dynamicdatetime/dynamicdatetime.trigger.js index 1d3234aa1..61d99d447 100644 --- a/src/widget/dynamicdatetime/dynamicdatetime.trigger.js +++ b/src/widget/dynamicdatetime/dynamicdatetime.trigger.js @@ -145,6 +145,7 @@ BI.DynamicDateTimeTrigger = BI.inherit(BI.Trigger, { }, _getStandardDateStr: function (v) { + var c = this._const; var result = []; var hasSecond = false; var formatArray = this._getFormatString().match(/%./g); @@ -169,7 +170,13 @@ BI.DynamicDateTimeTrigger = BI.inherit(BI.Trigger, { break; } }); - + // 这边不能直接用\d+去切日期, 因为format格式可能是20190607这样的没有分割符的 = = + // 先看一下是否是合法的, 如果合法就变成标准格式的走原来的流程, 不合法不关心 + var date = BI.parseDateTime(v, this._getFormatString()); + if(BI.print(date, this._getFormatString()) === v) { + v = BI.print(date, c.compareFormat); + result = [0, 1, 2]; + } var dateArray = v.match(/\d+/g); var newArray = []; // 处理乱序的年月日 @@ -178,6 +185,10 @@ BI.DynamicDateTimeTrigger = BI.inherit(BI.Trigger, { }); // 拼接时分秒和pm var suffixArray = dateArray.slice(3); + // 时分秒补0 + BI.each(suffixArray, function (idx, v) { + BI.isNumeric(v) && v.length === 1 && (suffixArray[idx] = "0" + v); + }); // hh:mm if(suffixArray.length === 2 && !hasSecond) { suffixArray.push("00");