From 2a85eacfab2e16498903cce79ba155234ac26fb9 Mon Sep 17 00:00:00 2001 From: buaixuexideshitongxue <2936013465@qq.com> Date: Tue, 11 Aug 2026 10:19:34 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=94=99=E8=AF=AF=E5=93=8D=E5=BA=94?= =?UTF-8?q?=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/request.ts | 16 +++++++++++++--- src/api/warning/business.ts | 24 ++++++++++++++++-------- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/src/api/request.ts b/src/api/request.ts index 77be619..3100276 100644 --- a/src/api/request.ts +++ b/src/api/request.ts @@ -13,7 +13,7 @@ type Options = { params?: Record, body?: string | FormData | Record, config?:Object - showErrorMsg: bool + showErrorMsg?: boolean }; function get(options: Options) { @@ -90,7 +90,7 @@ function ajax(url: string, options: Options) { headers: { ...headers, ...options.headers } }).then(response => { if (response.status === 413) { - return; + throw new Error('请求内容过大,请缩小文件后重试'); } if( isBlob){ return response.blob(); @@ -127,10 +127,20 @@ function ajax(url: string, options: Options) { // }else{ // feedback.msgError("请联系开发人员,数据存在问题") // } - console.log(message) + if (options.showErrorMsg) { + feedback.msgError(message || '操作失败,请稍后重试') + } reject(res) } } + }).catch(error => { + if (options.showErrorMsg) { + const message = error?.message === '请求内容过大,请缩小文件后重试' + ? error.message + : '网络异常,请检查网络后重试' + feedback.msgError(message) + } + reject(error) }) }) } diff --git a/src/api/warning/business.ts b/src/api/warning/business.ts index c504c4c..a18d329 100644 --- a/src/api/warning/business.ts +++ b/src/api/warning/business.ts @@ -7,7 +7,8 @@ import request from "@/api/request"; */ export function getWarningBusiness(reportId: string) { return request.get({ - url: `/warning/business/${reportId}` + url: `/warning/business/${reportId}`, + showErrorMsg: true }); } @@ -17,7 +18,8 @@ export function getWarningBusiness(reportId: string) { export function saveWarningBusiness(data: any) { return request.post({ url: '/warning/business/save', - body: data + body: data, + showErrorMsg: true }); } @@ -27,7 +29,8 @@ export function saveWarningBusiness(data: any) { export function submitWarningBusiness(data: any) { return request.post({ url: '/warning/business/submit', - body: data + body: data, + showErrorMsg: true }); } @@ -37,7 +40,8 @@ export function submitWarningBusiness(data: any) { export function endWarningBusiness(data: any) { return request.post({ url: '/warning/business/end', - body: data + body: data, + showErrorMsg: true }); } @@ -47,7 +51,8 @@ export function endWarningBusiness(data: any) { export function auditPassWarningDistribute(data: any) { return request.post({ url: '/warning/business/audit/pass/distribute', - body: data + body: data, + showErrorMsg: true }); } @@ -57,7 +62,8 @@ export function auditPassWarningDistribute(data: any) { export function auditRejectWarning(data: any) { return request.post({ url: '/warning/business/audit/reject', - body: data + body: data, + showErrorMsg: true }); } @@ -66,7 +72,8 @@ export function auditRejectWarning(data: any) { */ export function getWarningFlowList(reportId: string) { return request.get({ - url: `/warning/business/flow/${reportId}` + url: `/warning/business/flow/${reportId}`, + showErrorMsg: true }); } @@ -74,6 +81,7 @@ export function getWarningFlowList(reportId: string) { export const getCompilePage=(body)=>{ return request.post({ url:`/warning/business/compile/page`, - body + body, + showErrorMsg: true }) }