Browse Source

台账管理-质量报告-导出excel时 请求头统一加上projectId、groupCode

niuheng 3 years ago
parent
commit
77b0598ccd
1 changed files with 16 additions and 5 deletions
  1. 16 5
      src/api/scan/fetch.js

+ 16 - 5
src/api/scan/fetch.js

@@ -3,6 +3,7 @@ import axios from 'axios'
 import vueAxios from 'vue-axios'
 import store from '@/store'
 import { message } from '@/api/scan/config.js'
+import lStorage from '@/utils/localStorage';
 
 Vue.use(vueAxios, axios)
 //创建实例
@@ -14,11 +15,21 @@ const service = axios.create({
 
 //request拦截
 service.interceptors.request.use(config => {
-    config.cancelToken = new axios.CancelToken(cancel => {
-        if (config.url !== `${message}/message/update-state` || config.url !== '/image-service/common/multipart_upload') {
-            store.commit('setAxiosArr', {cancel})
-        }
-    })
+  config.cancelToken = new axios.CancelToken(cancel => {
+    if (config.url !== `${message}/message/update-state` || config.url !== '/image-service/common/multipart_upload') {
+      store.commit('setAxiosArr', { cancel })
+    }
+  });
+  let projectId = store.state.layout.projectId
+    ? store.state.layout.projectId
+    : lStorage.get("projectId");
+  let group_code = store.state.layout.group_code
+    ? store.state.layout.group_code
+    : lStorage.get("group_code");
+  config.headers = {
+    projectId: projectId,
+    groupCode: group_code
+  };
   return config
 }, error => {
   console.log(error)