From 5d12c108068076d2dbf15384f3b48641cf70f1db Mon Sep 17 00:00:00 2001 From: dataeaseShu Date: Thu, 14 Mar 2024 10:07:53 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=9F=A5=E8=AF=A2=E7=BB=84=E4=BB=B6):=20?= =?UTF-8?q?=E6=96=87=E6=9C=AC=E4=B8=8B=E6=8B=89=E7=BB=84=E4=BB=B6=E7=9A=84?= =?UTF-8?q?=E9=80=89=E9=A1=B9=E6=96=B0=E5=A2=9E=E7=A9=BA=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../v-query/QueryConditionConfiguration.vue | 6 +++ .../src/custom-component/v-query/Select.vue | 39 ++++++++++++++++--- 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/core/core-frontend/src/custom-component/v-query/QueryConditionConfiguration.vue b/core/core-frontend/src/custom-component/v-query/QueryConditionConfiguration.vue index a114c3ceca..37827cf132 100644 --- a/core/core-frontend/src/custom-component/v-query/QueryConditionConfiguration.vue +++ b/core/core-frontend/src/custom-component/v-query/QueryConditionConfiguration.vue @@ -635,6 +635,7 @@ const parameterCompletion = () => { aroundRange: 'f', arbitraryTimeRange: new Date(), setTimeRange: false, + showEmpty: false, timeRange: { intervalType: 'none', dynamicWindow: false, @@ -1405,6 +1406,11 @@ defineExpose({ > +
+
+ +
+
diff --git a/core/core-frontend/src/custom-component/v-query/Select.vue b/core/core-frontend/src/custom-component/v-query/Select.vue index c25e5b45da..746693014e 100644 --- a/core/core-frontend/src/custom-component/v-query/Select.vue +++ b/core/core-frontend/src/custom-component/v-query/Select.vue @@ -8,6 +8,7 @@ interface SelectConfig { defaultValue: any checkedFieldsMap: object displayType: string + showEmpty: boolean id: string checkedFields: string[] field: { @@ -71,12 +72,14 @@ const handleFieldIdChange = (val: string[]) => { loading.value = true getEnumValue(val) .then(res => { - options.value = (res || []).map(ele => { - return { - label: ele, - value: ele - } - }) + options.value = (res || []) + .filter(ele => ele !== null) + .map(ele => { + return { + label: ele, + value: ele + } + }) }) .finally(() => { loading.value = false @@ -89,6 +92,7 @@ const handleFieldIdChange = (val: string[]) => { ? [...selectValue.value] : selectValue.value } + setEmptyData() }) } @@ -99,6 +103,28 @@ const visibleChange = (val: boolean) => { }, 50) } +watch( + () => config.value.showEmpty, + () => { + setEmptyData() + } +) + +const setEmptyData = () => { + const { showEmpty, displayType } = config.value + if (+displayType !== 0) return + const [s] = options.value + if (showEmpty) { + if (s?.value !== '_empty_$') { + options.value = [{ label: '空数据', value: '_empty_$' }, ...options.value] + } + } else { + if (s?.value === '_empty_$') { + options.value = options.value.slice(1) + } + } +} + watch( () => config.value.defaultValue, val => { @@ -214,6 +240,7 @@ const setOptions = (num: number) => { } }) ) + setEmptyData() break default: break