From 49ab2d678f599b663b48e9c0f96ac7c26a7505fb Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Wed, 1 Dec 2021 11:31:37 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BB=AA=E8=A1=A8=E6=9D=BF=E6=97=A5?= =?UTF-8?q?=E6=9C=9F=E7=BB=84=E4=BB=B6=E6=97=A0=E6=B3=95=E4=BA=8C=E6=AC=A1?= =?UTF-8?q?=E7=BC=96=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/widget/DeWidget/DeDate.vue | 24 ++++++++++++++----- frontend/src/utils/index.js | 3 +++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/frontend/src/components/widget/DeWidget/DeDate.vue b/frontend/src/components/widget/DeWidget/DeDate.vue index 4018dd5110..94eeb76d41 100644 --- a/frontend/src/components/widget/DeWidget/DeDate.vue +++ b/frontend/src/components/widget/DeWidget/DeDate.vue @@ -2,7 +2,7 @@ @@ -42,11 +43,13 @@ export default { }, created() { this.options = this.element.options - if ((this.options.attrs.type === 'date' || this.options.attrs.type === 'daterange') && Array.isArray(this.options.value) && this.options.value.length === 0) { - this.options.value = null - } - if (!!this.options && !!this.options.value && Object.keys(this.options.value).length === 0) { - this.options.value = null + + if (this.options.value) { + if (this.options.attrs.type !== 'daterange') { + this.values = Array.isArray(this.options.value) ? this.options.value[0] : this.options.value + } else { + this.values = this.options.value + } } }, methods: { @@ -54,6 +57,15 @@ export default { this.setCondition() }, setCondition() { + if (this.values) { + if (this.options.attrs.type !== 'daterange') { + this.options.value = Array.isArray(this.values) ? this.values[0] : this.values + } else { + this.options.value = this.values + } + } else { + this.options.value = [] + } const param = { component: this.element, value: Array.isArray(this.options.value) ? this.options.value : [this.options.value], diff --git a/frontend/src/utils/index.js b/frontend/src/utils/index.js index 7cc1eae425..75644be2ed 100644 --- a/frontend/src/utils/index.js +++ b/frontend/src/utils/index.js @@ -4,6 +4,9 @@ export function timeSection(date, type) { if (!date) { return null } + if (!(date instanceof Date)) { + date = new Date(date) + } const timeRanger = new Array(2) date.setHours(0)