fix: 请假表单日期序列化与错误消息格式化修复

- el-date-picker 添加 value-format="YYYY-MM-DD",确保日期以字符串格式发送而非 ISO datetime,修复后端 Pydantic date 校验 422 错误
- 错误处理中正确解析 FastAPI 422 返回的 detail 数组,提取 msg 字段拼接显示,修复 [object Object] 显示问题

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-07-28 11:02:26 +08:00
parent ccb436664b
commit 7f87aa7353
2 changed files with 10 additions and 4 deletions
+5 -1
View File
@@ -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"
/>
<el-date-picker
v-model="form.end_date"
type="date"
placeholder="结束日期"
style="width:100%"
value-format="YYYY-MM-DD"
/>
</el-form-item>
<el-form-item label="原因(选填)">