Browse Source

feat: 错误响应显示

main
buaixuexideshitongxue 1 month ago
parent
commit
2a85eacfab
  1. 16
      src/api/request.ts
  2. 24
      src/api/warning/business.ts

16
src/api/request.ts

@ -13,7 +13,7 @@ type Options = {
params?: Record<string, any>,
body?: string | FormData | Record<string, any>,
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)
})
})
}

24
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
})
}

Loading…
Cancel
Save