From 7f87aa735347a7b74a650a7a1d28b0130ad097d0 Mon Sep 17 00:00:00 2001 From: v6ole Date: Tue, 28 Jul 2026 11:02:26 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=AF=B7=E5=81=87=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E6=97=A5=E6=9C=9F=E5=BA=8F=E5=88=97=E5=8C=96=E4=B8=8E=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E6=B6=88=E6=81=AF=E6=A0=BC=E5=BC=8F=E5=8C=96=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - el-date-picker 添加 value-format="YYYY-MM-DD",确保日期以字符串格式发送而非 ISO datetime,修复后端 Pydantic date 校验 422 错误 - 错误处理中正确解析 FastAPI 422 返回的 detail 数组,提取 msg 字段拼接显示,修复 [object Object] 显示问题 Co-Authored-By: Claude --- frontend/src/views/desktop/Leaves.vue | 6 +++++- frontend/src/views/mobile/LeaveForm.vue | 8 +++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/frontend/src/views/desktop/Leaves.vue b/frontend/src/views/desktop/Leaves.vue index 27cd479..76c43a7 100644 --- a/frontend/src/views/desktop/Leaves.vue +++ b/frontend/src/views/desktop/Leaves.vue @@ -138,7 +138,9 @@ async function handleSave() { dialogVisible.value = false await loadLeaves() } catch (e: any) { - ElMessage.error('保存失败: ' + (e.response?.data?.detail || e.message)) + const detail = e.response?.data?.detail + const msg = Array.isArray(detail) ? detail.map((d: any) => d.msg).join('; ') : (detail || e.message) + ElMessage.error('保存失败: ' + msg) } } @@ -276,12 +278,14 @@ function onStatusChange(val: string) { type="date" placeholder="开始日期" style="width:100%; margin-bottom: 8px" + value-format="YYYY-MM-DD" /> diff --git a/frontend/src/views/mobile/LeaveForm.vue b/frontend/src/views/mobile/LeaveForm.vue index cafd8f2..14ba88b 100644 --- a/frontend/src/views/mobile/LeaveForm.vue +++ b/frontend/src/views/mobile/LeaveForm.vue @@ -70,7 +70,9 @@ async function handleSubmit() { } router.push('/m/leaves') } catch (e: any) { - ElMessage.error((isEdit ? '更新' : '提交') + '失败: ' + (e.response?.data?.detail || e.message)) + const detail = e.response?.data?.detail + const msg = Array.isArray(detail) ? detail.map((d: any) => d.msg).join('; ') : (detail || e.message) + ElMessage.error((isEdit ? '更新' : '提交') + '失败: ' + msg) } finally { submitLoading.value = false } } @@ -124,12 +126,12 @@ async function handleDelete() { - + - +