From aac76e9de530a1093549aea08cb469fb3106e539 Mon Sep 17 00:00:00 2001 From: Mio Date: Sun, 20 Jun 2021 14:12:03 +0800 Subject: [PATCH] =?UTF-8?q?JSY-7193=C2=B7=20feat:=20=E6=8F=90=E4=BE=9B?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E6=97=B6=E9=97=B4=E8=AE=A1=E7=AE=97=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dynamicdate/dynamicdate.caculate.js | 51 +++++++++++++++++++ src/widget/dynamicdate/dynamicdate.trigger.js | 49 +----------------- 2 files changed, 52 insertions(+), 48 deletions(-) diff --git a/src/widget/dynamicdate/dynamicdate.caculate.js b/src/widget/dynamicdate/dynamicdate.caculate.js index 3b49a9118..665661d9e 100644 --- a/src/widget/dynamicdate/dynamicdate.caculate.js +++ b/src/widget/dynamicdate/dynamicdate.caculate.js @@ -7,6 +7,57 @@ return this.getCalculationByDate(date, obj); }, + getDescription: function (obj) { + var value = ""; + var endText = ""; + if(BI.isNotNull(obj.year)) { + if(BI.parseInt(obj.year) !== 0) { + value += Math.abs(obj.year) + BI.i18nText("BI-Basic_Year") + (obj.year < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); + } + endText = getPositionText(BI.i18nText("BI-Basic_Year"), obj.position); + } + if(BI.isNotNull(obj.quarter)) { + if(BI.parseInt(obj.quarter) !== 0) { + value += Math.abs(obj.quarter) + BI.i18nText("BI-Basic_Single_Quarter") + (obj.quarter < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); + } + endText = getPositionText(BI.i18nText("BI-Basic_Single_Quarter"), obj.position); + } + if(BI.isNotNull(obj.month)) { + if(BI.parseInt(obj.month) !== 0) { + value += Math.abs(obj.month) + BI.i18nText("BI-Basic_Month") + (obj.month < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); + } + endText = getPositionText(BI.i18nText("BI-Basic_Month"), obj.position); + } + if(BI.isNotNull(obj.week)) { + if(BI.parseInt(obj.week) !== 0) { + value += Math.abs(obj.week) + BI.i18nText("BI-Basic_Week") + (obj.week < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); + } + endText = getPositionText(BI.i18nText("BI-Basic_Week"), obj.position); + } + if(BI.isNotNull(obj.day)) { + if(BI.parseInt(obj.day) !== 0) { + value += Math.abs(obj.day) + BI.i18nText("BI-Basic_Day") + (obj.day < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); + } + endText = BI.size(obj) === 1 ? getPositionText(BI.i18nText("BI-Basic_Month"), obj.position) : ""; + } + if(BI.isNotNull(obj.workDay) && BI.parseInt(obj.workDay) !== 0) { + value += Math.abs(obj.workDay) + BI.i18nText("BI-Basic_Work_Day") + (obj.workDay < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); + } + return value + endText; + + function getPositionText (baseText, position) { + switch (position) { + case BI.DynamicDateCard.OFFSET.BEGIN: + return baseText + BI.i18nText("BI-Basic_Begin_Start"); + case BI.DynamicDateCard.OFFSET.END: + return baseText + BI.i18nText("BI-Basic_End_Stop"); + case BI.DynamicDateCard.OFFSET.CURRENT: + default: + return BI.i18nText("BI-Basic_Current_Day"); + } + } + }, + getCalculationByDate: function (date, obj) { if (BI.isNotNull(obj.year)) { date = BI.getDate((date.getFullYear() + BI.parseInt(obj.year)), date.getMonth(), date.getDate()); diff --git a/src/widget/dynamicdate/dynamicdate.trigger.js b/src/widget/dynamicdate/dynamicdate.trigger.js index 3ec9d1c18..ae8fcda03 100644 --- a/src/widget/dynamicdate/dynamicdate.trigger.js +++ b/src/widget/dynamicdate/dynamicdate.trigger.js @@ -240,54 +240,7 @@ BI.DynamicDateTrigger = BI.inherit(BI.Trigger, { }, _getText: function (obj) { - var value = ""; - var endText = ""; - if(BI.isNotNull(obj.year)) { - if(BI.parseInt(obj.year) !== 0) { - value += Math.abs(obj.year) + BI.i18nText("BI-Basic_Year") + (obj.year < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); - } - endText = getPositionText(BI.i18nText("BI-Basic_Year"), obj.position); - } - if(BI.isNotNull(obj.quarter)) { - if(BI.parseInt(obj.quarter) !== 0) { - value += Math.abs(obj.quarter) + BI.i18nText("BI-Basic_Single_Quarter") + (obj.quarter < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); - } - endText = getPositionText(BI.i18nText("BI-Basic_Single_Quarter"), obj.position); - } - if(BI.isNotNull(obj.month)) { - if(BI.parseInt(obj.month) !== 0) { - value += Math.abs(obj.month) + BI.i18nText("BI-Basic_Month") + (obj.month < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); - } - endText = getPositionText(BI.i18nText("BI-Basic_Month"), obj.position); - } - if(BI.isNotNull(obj.week)) { - if(BI.parseInt(obj.week) !== 0) { - value += Math.abs(obj.week) + BI.i18nText("BI-Basic_Week") + (obj.week < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); - } - endText = getPositionText(BI.i18nText("BI-Basic_Week"), obj.position); - } - if(BI.isNotNull(obj.day)) { - if(BI.parseInt(obj.day) !== 0) { - value += Math.abs(obj.day) + BI.i18nText("BI-Basic_Day") + (obj.day < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); - } - endText = BI.size(obj) === 1 ? getPositionText(BI.i18nText("BI-Basic_Month"), obj.position) : ""; - } - if(BI.isNotNull(obj.workDay) && BI.parseInt(obj.workDay) !== 0) { - value += Math.abs(obj.workDay) + BI.i18nText("BI-Basic_Work_Day") + (obj.workDay < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); - } - return value + endText; - - function getPositionText (baseText, position) { - switch (position) { - case BI.DynamicDateCard.OFFSET.BEGIN: - return baseText + BI.i18nText("BI-Basic_Begin_Start"); - case BI.DynamicDateCard.OFFSET.END: - return baseText + BI.i18nText("BI-Basic_End_Stop"); - case BI.DynamicDateCard.OFFSET.CURRENT: - default: - return BI.i18nText("BI-Basic_Current_Day"); - } - } + return BI.DynamicDateHelper.getDescription(obj); }, setValue: function (v) {