fix(api): 优化导出接口错误提示信息

- 将 plan_id_eq 为空时的错误信息修改为“请选择计划”
- 导出错误时优先显示后端返回的 msg 字段,增强错误提示的准确性
- 使用模态框弹出更友好的错误提示,提升用户体验
This commit is contained in:
zhouyonggao 2025-12-22 17:19:26 +08:00
parent 55058abf0d
commit fe45f8fa6f
2 changed files with 4 additions and 2 deletions

View File

@ -218,7 +218,7 @@ func (a *ExportsAPI) create(w http.ResponseWriter, r *http.Request) {
} }
// 验证 plan_id_eq 为必选字段 // 验证 plan_id_eq 为必选字段
if v, ok := p.Filters["plan_id_eq"]; !ok || v == nil || v == "" || v == 0 { if v, ok := p.Filters["plan_id_eq"]; !ok || v == nil || v == "" || v == 0 {
fail(w, r, http.StatusBadRequest, "plan_id_eq 为必选字段") fail(w, r, http.StatusBadRequest, "请选择计划")
return return
} }
} }

View File

@ -866,7 +866,9 @@ const app = createApp({
} }
} catch (error) { } catch (error) {
// 使用模态框显示错误信息 // 使用模态框显示错误信息
ElementPlus.ElMessageBox.alert(error.message || '导出失败', '提示', { // 优先使用 msg 字段(从后端 JSON 响应中提取),否则使用 message
const errorMsg = error.msg || error.message || '导出失败';
ElementPlus.ElMessageBox.alert(errorMsg, '提示', {
type: 'error', type: 'error',
confirmButtonText: '确定' confirmButtonText: '确定'
}); });