Sfoglia il codice sorgente

加跳过错误提示字段

@dongkboy 3 mesi fa
parent
commit
e862dd2755
2 ha cambiato i file con 9 aggiunte e 6 eliminazioni
  1. 7 4
      src/api/index.ts
  2. 2 2
      src/api/modules/insurancePolicy.ts

+ 7 - 4
src/api/index.ts

@@ -79,14 +79,17 @@ axiosInstance.interceptors.response.use(
      * 规则是当 status 为 1 时表示请求成功,为 0 时表示接口需要登录或者登录状态失效,需要重新登录
      * 请求出错时 error 会返回错误信息
      */
+    // 检查是否需要跳过全局错误提示
+    const skipGlobalError = response.config?.skipGlobalError || response.config?.headers?.['skip-global-error']
+
     if (response.data.code === 500) {
-      if (response.data.msg !== '') {
+      if (response.data.msg !== '' && !skipGlobalError) {
         // 错误提示
         Message.error(response.data.msg, {
           zIndex: 9000,
         })
-        return Promise.resolve(response.data)
       }
+      return Promise.resolve(response.data)
     }
     else {
       if (response.data.code === 401) {
@@ -96,7 +99,7 @@ axiosInstance.interceptors.response.use(
           duration: 2000,
         })
         useUserStore().logout()
-      } else if(response.data.code === 400) {
+      } else if(response.data.code === 400 && !skipGlobalError) {
         ElMessage({
           message: `${response.data.msg}!!!`,
           type: 'error',
@@ -155,4 +158,4 @@ const api = {
   dictApi: dictApi(axiosInstance),
   homeApi: homeApi(axiosInstance)
 }
-export default api
+export default api

+ 2 - 2
src/api/modules/insurancePolicy.ts

@@ -3,7 +3,7 @@ import { ApiInstance } from '../type'
 const insurancePolicyApi = (axiosInstance: ApiInstance) => ({
   againLogin: (data: any) => axiosInstance.post('/unify/order/guoRenlogin', data), // 保司重新登录
   getGuoRenCaptcha: (data: any) => axiosInstance.post('/unify/order/getGuoRenCaptcha', data), // 保司重新登录
-  quote: (data: any) => axiosInstance.post('/unify/order/quote', data), // 报价
+  quote: (data: any, config?: any) => axiosInstance.post('/unify/order/quote', data, config), // 报价
   getQuoteNo:(data: any) => axiosInstance.get(`/unify/order/getQuoteNo?licenseNo=${data.licenseNo}&vinNo=${data.vinNo}&engineNo=${data.engineNo}`), // 获取报价号
   ruleFilterCompany: (data: any) => axiosInstance.post('/scheme/ruleFilterCompany', data, {
     headers: {
@@ -47,4 +47,4 @@ const insurancePolicyApi = (axiosInstance: ApiInstance) => ({
   downloadPolicy: (data: any) => axiosInstance.post(`/unify/order/downloadPolicy`,data), // 下载电子保单
 })
 
-export default insurancePolicyApi
+export default insurancePolicyApi