From f705ba3a2e7665d7f72069efc6fbecdc917c5c4f Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Fri, 23 Feb 2024 19:35:32 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AD=97=E5=85=B8=E6=A0=87=E7=AD=BE?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=8F=96=E9=BB=98=E8=AE=A4=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/DictTag/index.vue | 12 +++++++++++- .../overview/components/UserActivity/index.vue | 8 ++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/components/DictTag/index.vue b/src/components/DictTag/index.vue index e28dd097..5d4628bb 100644 --- a/src/components/DictTag/index.vue +++ b/src/components/DictTag/index.vue @@ -15,14 +15,24 @@ const props = defineProps({ type: [Number, String], default: '', }, + /**数据默认值,当前值不存在时 */ + valueOption: { + type: [Number, String], + }, }); /**遍历找到对应值数据项 */ const item = computed(() => { if (Array.isArray(props.options) && props.options.length > 0) { - const option = (props.options as any[]).find( + let option = (props.options as any[]).find( item => `${item[props.valueField]}` === `${props.value}` ); + // 数据默认值 + if (props.valueOption != undefined && !option) { + option = (props.options as any[]).find( + item => `${item[props.valueField]}` === `${props.valueOption }` + ); + } return option; } return undefined; diff --git a/src/views/dashboard/overview/components/UserActivity/index.vue b/src/views/dashboard/overview/components/UserActivity/index.vue index 8d2cbd83..f86e2f45 100644 --- a/src/views/dashboard/overview/components/UserActivity/index.vue +++ b/src/views/dashboard/overview/components/UserActivity/index.vue @@ -85,9 +85,9 @@ onMounted(() => {