From 56d25af37c98283e901cb28238f70f7f78855e1b Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Wed, 9 Nov 2022 10:45:48 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat(=E8=BF=87=E6=BB=A4=E5=99=A8):=20?= =?UTF-8?q?=E6=97=A5=E6=9C=9F=E8=8C=83=E5=9B=B4=E8=BF=87=E6=BB=A4=E5=99=A8?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E6=97=B6=E9=97=B4=E5=8F=AF=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E5=9B=BA=E5=AE=9A=E6=97=B6=E5=88=86=E7=A7=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../serviceImpl/TimeDateRangeServiceImpl.js | 32 ++++++++++ frontend/src/styles/index.scss | 2 +- .../defaultValue/DeDateRangeDefault.vue | 62 +++++++++++++++++-- .../panel/filter/filterMain/FilterControl.vue | 5 +- 4 files changed, 94 insertions(+), 7 deletions(-) diff --git a/frontend/src/components/widget/serviceImpl/TimeDateRangeServiceImpl.js b/frontend/src/components/widget/serviceImpl/TimeDateRangeServiceImpl.js index ec41b71476a..94dcb6321ec 100644 --- a/frontend/src/components/widget/serviceImpl/TimeDateRangeServiceImpl.js +++ b/frontend/src/components/widget/serviceImpl/TimeDateRangeServiceImpl.js @@ -222,6 +222,10 @@ class TimeDateRangeServiceImpl extends WidgetService { } } dynamicDateFormNow(element) { + const values = this.dynamicDateFormNowProxy(element) + return this.formatDynamicTimes(values, element) + } + dynamicDateFormNowProxy(element) { if (element.options.attrs.default === null || typeof element.options.attrs.default === 'undefined' || !element.options.attrs.default.isDynamic) return null if (element.options.attrs.default.dkey === 0) { @@ -265,6 +269,34 @@ class TimeDateRangeServiceImpl extends WidgetService { return [startTime, endTime] } } + + formatDynamicTimes(values, element) { + if (!values || !values.length || !element.options.attrs.default.isDynamic) { + return values + } + const baseTime = new Date('2022-11-09 00:00:00.000').getTime() + let labelFormat = 'yyyy-MM-dd' + if (element.options.attrs.showTime && element.options.attrs.accuracy) { + labelFormat = labelFormat + ' ' + element.options.attrs.accuracy + } + let start = values[0] + let end = values[1] + const attrs = element.options.attrs + + if (attrs.default.sDynamicSuffixTime && attrs.default.isDynamic && attrs.default.dkey === 4 && attrs.showTime) { + start = attrs.default.sDynamicSuffixTime - baseTime + timeSection(start, 'date')[0] + } else { + start = timeSection(start, 'date', labelFormat)[0] + } + if (attrs.default.eDynamicSuffixTime && attrs.default.isDynamic && attrs.default.dkey === 4 && attrs.showTime) { + end = attrs.default.eDynamicSuffixTime - baseTime + timeSection(end, 'date')[0] + } else { + end = timeSection(end, 'date', labelFormat)[1] + } + + const results = [start, end] + return results + } validDynamicValue(element) { if (!element.options.attrs.default.isDynamic) return true if (element.options.attrs.default.dkey !== 4) return true diff --git a/frontend/src/styles/index.scss b/frontend/src/styles/index.scss index 3b1b8cfb1dc..c7cf1088bca 100644 --- a/frontend/src/styles/index.scss +++ b/frontend/src/styles/index.scss @@ -770,7 +770,7 @@ div:focus { .no-label-item { .el-form-item__content { - margin-left: 10px !important; + margin-left: 5px !important; } } diff --git a/frontend/src/views/panel/filter/defaultValue/DeDateRangeDefault.vue b/frontend/src/views/panel/filter/defaultValue/DeDateRangeDefault.vue index a43ca1ea5a2..50f4324659d 100644 --- a/frontend/src/views/panel/filter/defaultValue/DeDateRangeDefault.vue +++ b/frontend/src/views/panel/filter/defaultValue/DeDateRangeDefault.vue @@ -13,10 +13,8 @@ @change="dynamicChange" > {{ $t('dynamic_time.fix') }} - {{ $t('dynamic_time.dynamic') }} + {{ $t('dynamic_time.dynamic') }} + @@ -82,6 +80,7 @@ > + + + +
@@ -153,6 +169,7 @@ > + + + +
time[0] || this.isOneDay)) this.element.options.manualModify = false + }, + + fillEmptySuffixTime() { + if (!this.element.options.attrs.default.sDynamicSuffixTime) { + this.$set(this.element.options.attrs.default, 'sDynamicSuffixTime', this.baseTime) + } + + if (!this.element.options.attrs.default.eDynamicSuffixTime) { + this.$set(this.element.options.attrs.default, 'eDynamicSuffixTime', new Date('2022-11-09 23:59:59.999').getTime()) + } + }, + eDynamicSuffixTimeChange(val) { + this.setDval() + }, + sDynamicSuffixTimeChange(val) { + this.setDval() } } } diff --git a/frontend/src/views/panel/filter/filterMain/FilterControl.vue b/frontend/src/views/panel/filter/filterMain/FilterControl.vue index d4234d9e74d..4067341c301 100644 --- a/frontend/src/views/panel/filter/filterMain/FilterControl.vue +++ b/frontend/src/views/panel/filter/filterMain/FilterControl.vue @@ -270,7 +270,10 @@ export default { }, showTimeChange(value) { this.attrs.accuracy = this.accuracyOptions[1].id - this.attrs.default.isDynamic = false + if (this.widget.name !== 'timeDateRangeWidget') { + this.attrs.default.isDynamic = false + } + this.fillAttrs2Filter() }, checkedViewsChange(values) { From e76788780af47a0a1e917084774dac14a9536450 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw <67260074+fit2cloud-chenyw@users.noreply.github.com> Date: Wed, 9 Nov 2022 10:59:02 +0800 Subject: [PATCH 2/2] =?UTF-8?q?perf(=E8=BF=87=E6=BB=A4=E5=99=A8):=E6=8C=89?= =?UTF-8?q?review=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../widget/serviceImpl/TimeDateRangeServiceImpl.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/widget/serviceImpl/TimeDateRangeServiceImpl.js b/frontend/src/components/widget/serviceImpl/TimeDateRangeServiceImpl.js index 94dcb6321ec..c411217f3ec 100644 --- a/frontend/src/components/widget/serviceImpl/TimeDateRangeServiceImpl.js +++ b/frontend/src/components/widget/serviceImpl/TimeDateRangeServiceImpl.js @@ -271,16 +271,16 @@ class TimeDateRangeServiceImpl extends WidgetService { } formatDynamicTimes(values, element) { - if (!values || !values.length || !element.options.attrs.default.isDynamic) { + if (!values?.length || !element.options.attrs.default.isDynamic) { return values } - const baseTime = new Date('2022-11-09 00:00:00.000').getTime() + const baseTime = +new Date('2022-11-09 00:00:00.000') let labelFormat = 'yyyy-MM-dd' if (element.options.attrs.showTime && element.options.attrs.accuracy) { labelFormat = labelFormat + ' ' + element.options.attrs.accuracy } - let start = values[0] - let end = values[1] + let [ start, end ] = values + const attrs = element.options.attrs if (attrs.default.sDynamicSuffixTime && attrs.default.isDynamic && attrs.default.dkey === 4 && attrs.showTime) {