From f92b07c555b64143bd82f54b5d550e64096e40d6 Mon Sep 17 00:00:00 2001 From: stt Date: Mon, 8 Dec 2025 14:21:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9"=E4=B8=8B=E4=B8=80=E4=B8=AA"?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E7=9A=84=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/form/datePicker/index.vue | 30 +++++++++++++++++------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/components/form/datePicker/index.vue b/src/components/form/datePicker/index.vue index 7216ba7..ee66a44 100644 --- a/src/components/form/datePicker/index.vue +++ b/src/components/form/datePicker/index.vue @@ -20,6 +20,7 @@ value-format="YYYY-MM-DD" :shortcuts="shortcuts" /> + 当前 @@ -35,7 +36,7 @@ interface Props { theCurrentTime?: boolean initialInterval?: number initialTimeValue?: any - timeKeyList?: string[] //日期下拉 + timeKeyList?: string[] //日期下拉 } const props = withDefaults(defineProps(), { @@ -97,11 +98,8 @@ const filteredTimeOptions = computed(() => { if (!props.timeKeyList || props.timeKeyList.length === 0) { return timeOptions.value } - - return timeOptions.value.filter((option: any) => - props.timeKeyList.includes(option.value.toString()) - ) + return timeOptions.value.filter((option: any) => props.timeKeyList.includes(option.value.toString())) }) onMounted(() => { @@ -143,6 +141,11 @@ const emitChange = () => { timeValue: timeValue.value, timeFlag: timeFlag.value }) + + // preClick 操作后不执行按钮状态检查 + if (!isUserAction) { + checkButtonStatus() + } }) } // 选择时间范围 @@ -186,8 +189,17 @@ const timeChange = (e: number) => { emitChange() } -// 添加按钮状态检查方法 -const checkButtonStatus = () => { +// 添加一个标志来跟踪是否由用户操作触发 +let isUserAction = true + +// 修改 checkButtonStatus 方法 +const checkButtonStatus = (forceEnable = false) => { + // 如果是强制启用,则直接启用 + if (forceEnable) { + preDisabled.value = false + return + } + if (timeValue.value && timeValue.value.length >= 2) { const endTime = timeValue.value[1] const currentDate = window.XEUtils.toDateString(new Date(), 'yyyy-MM-dd') @@ -270,8 +282,10 @@ const preClick = () => { // var temp = NowgetEndTime() // timeStatus(temp, endTime) - // 触发 change 事件 + // 触发 change 事件,但临时标记为用户操作 + isUserAction = true emitChange() + isUserAction = false } //下一个 const next = () => {