ysy 2 年 前
コミット
d481602f3d
3 ファイル変更85 行追加78 行削除
  1. BIN
      dist.rar
  2. 83 78
      src/utils/request.js
  3. 2 0
      src/views/materialPlan/components/plan-edit-dialog.vue

BIN
dist.rar


+ 83 - 78
src/utils/request.js

@@ -1,81 +1,86 @@
 /**
  * axios 实例
  */
-import axios from 'axios';
-import router from '@/router';
-import { MessageBox, Message } from 'element-ui';
-import { API_BASE_URL, TOKEN_HEADER_NAME, LAYOUT_PATH } from '@/config/setting';
-import { getToken, setToken } from './token-util';
-import { logout } from './page-tab-util';
-import JSONBIG from 'json-bigint';
-
-const service = axios.create({
-  baseURL: API_BASE_URL,
-  transformResponse: [
-    function (data) {
-      const json = JSONBIG({
-        storeAsString: true
-      });
-      const res = json.parse(data);
-      return res;
-    }
-  ]
-});
-/**
- * 添加请求拦截器
- */
-service.interceptors.request.use(
-  (config) => {
-    // 添加 token 到 header
-    const token = getToken();
-    if (token && config.headers) {
-      config.headers.common[TOKEN_HEADER_NAME] = token;
-    }
-    return config;
-  },
-  (error) => {
-    return Promise.reject(error);
-  }
-);
-
-/**
- * 添加响应拦截器
- */
-service.interceptors.response.use(
-  (res) => {
-    // token 自动续期
-    if (res.data.code == '-1' && res.config?.showErrorToast !== false) {
-      Message.error(res.data.message);
-    }
-    const token = res.headers[TOKEN_HEADER_NAME.toLowerCase()];
-    if (token) {
-      setToken(token);
-    }
-    return res;
-  },
-  (error) => {
-    // 登录过期处理
-    if (error?.response?.status === 401) {
-      const currentPath = router.currentRoute.path;
-      if (currentPath === LAYOUT_PATH) {
-        logout(true);
-      } else {
-        MessageBox.alert('登录状态已过期, 请退出重新登录!', '系统提示', {
-          confirmButtonText: '重新登录',
-          callback: (action) => {
-            if (action === 'confirm') {
-              logout(false, currentPath);
-            }
-          },
-          beforeClose: () => {
-            MessageBox.close();
-          }
-        });
-      }
-      return Promise.reject(new Error(error.response.data?.message));
-    }
-    return Promise.reject(error);
-  }
-);
-
-export default service;
+ import axios from 'axios';
+ import router from '@/router';
+ import store from '@/store';
+ import { MessageBox, Message } from 'element-ui';
+ import { API_BASE_URL, TOKEN_HEADER_NAME, LAYOUT_PATH } from '@/config/setting';
+ import { getToken, setToken } from './token-util';
+ import { logout } from './page-tab-util';
+ import JSONBIG from 'json-bigint';
+ const service = axios.create({
+   baseURL: API_BASE_URL,
+   transformResponse: [
+     function (data) {
+       if (data instanceof Blob) {
+         return data;
+       }
+       const json = JSONBIG({
+         storeAsString: true
+       });
+       const res = json.parse(data);
+       return res;
+     }
+   ]
+ });
+ /**
+  * 添加请求拦截器
+  */
+ service.interceptors.request.use(
+   (config) => {
+     // 添加 token 到 header
+     const token = getToken();
+     if (token && config.headers) {
+       config.headers.common[TOKEN_HEADER_NAME] = token;
+     }
+ 
+     return config;
+   },
+   (error) => {
+     return Promise.reject(error);
+   }
+ );
+ 
+ /**
+  * 添加响应拦截器
+  */
+ service.interceptors.response.use(
+   (res) => {
+     // token 自动续期
+     if (res.data.code == '-1' && res.config?.showErrorToast !== false&&res.data.message) {
+       Message.error(res.data.message);
+     }
+     const token = res.headers[TOKEN_HEADER_NAME.toLowerCase()];
+     if (token) {
+       setToken(token);
+     }
+     return res;
+   },
+   (error) => {
+     // 登录过期处理
+     if (error?.response?.status === 401) {
+       const currentPath = router.currentRoute.path;
+       if (currentPath === LAYOUT_PATH) {
+         logout(true);
+       } else {
+         MessageBox.alert('登录状态已过期, 请退出重新登录!', '系统提示', {
+           confirmButtonText: '重新登录',
+           callback: (action) => {
+             if (action === 'confirm') {
+               logout(false, currentPath);
+             }
+           },
+           beforeClose: () => {
+             MessageBox.close();
+           }
+         });
+       }
+       return Promise.reject(new Error(error.response.data?.message));
+     }
+     return Promise.reject(error);
+   }
+ );
+ 
+ export default service;
+ 

+ 2 - 0
src/views/materialPlan/components/plan-edit-dialog.vue

@@ -390,6 +390,7 @@ export default {
           slot: 'imgUrl',
           action: ' imgUrl',
           align: 'center',
+          minWidth: 140
         },
 
 
@@ -398,6 +399,7 @@ export default {
           slot: 'files',
           action: ' files',
           align: 'center',
+          minWidth: 140
         },