From 02716aa69000d22a7f85fecc1eddcb7ef0612949 Mon Sep 17 00:00:00 2001 From: "xinxin.wu" Date: Mon, 21 Oct 2024 18:40:41 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8E=A5=E5=8F=A3=E6=96=87=E6=A1=A3=E5=88=86?= =?UTF-8?q?=E4=BA=AB=E6=97=B6=E9=97=B4=E9=BB=98=E8=AE=A4=E4=B8=BA=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pure/ms-time-selector/MsTimeSelector.vue | 17 ++++++++++++----- .../management/api/createShareModal.vue | 2 +- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/frontend/src/components/pure/ms-time-selector/MsTimeSelector.vue b/frontend/src/components/pure/ms-time-selector/MsTimeSelector.vue index 35174c9c27..1e5e7b5136 100644 --- a/frontend/src/components/pure/ms-time-selector/MsTimeSelector.vue +++ b/frontend/src/components/pure/ms-time-selector/MsTimeSelector.vue @@ -31,7 +31,11 @@ const { t } = useI18n(); - const props = defineProps<{ defaultValue?: string; disabled?: boolean }>(); + const props = defineProps<{ + defaultValue?: string; + disabled?: boolean; + allowEmpty?: boolean; // 允许为空 + }>(); const emit = defineEmits<{ (e: 'change', value: string): void; }>(); @@ -43,7 +47,7 @@ function parseValue(v?: string) { // 使用正则表达式匹配输入字符串,提取类型和值 if (!v) { - return { type: 'H', value: 0 }; + return { type: 'H', value: props.allowEmpty ? '' : 0 }; } const match = v.match(/^(\d+(\.\d+)?)([MYHD])$/); if (match) { @@ -52,9 +56,9 @@ return { type, value }; } // 如果输入字符串不匹配格式,可以抛出错误或返回一个默认值 - return { type: 'H', value: 0 }; + return { type: 'H', value: props.allowEmpty ? '' : 0 }; } - const numberValue = ref(0); + const numberValue = ref(); const typeValue = ref('H'); function initNumberAndType() { @@ -103,7 +107,10 @@ watch( () => modelValue.value, () => { - initNumberAndType(); + if (!props.allowEmpty) { + numberValue.value = 0; + initNumberAndType(); + } }, { immediate: true, diff --git a/frontend/src/views/api-test/management/components/management/api/createShareModal.vue b/frontend/src/views/api-test/management/components/management/api/createShareModal.vue index 910704f6d1..fac7288ec3 100644 --- a/frontend/src/views/api-test/management/components/management/api/createShareModal.vue +++ b/frontend/src/views/api-test/management/components/management/api/createShareModal.vue @@ -59,7 +59,7 @@ - +