Browse Source

所有接口在header头添加机构编号参数

lex-xin 3 years ago
parent
commit
1dbc89d593
2 changed files with 8 additions and 19 deletions
  1. 4 10
      src/utils/request.js
  2. 4 9
      src/utils/request2.js

+ 4 - 10
src/utils/request.js

@@ -80,16 +80,10 @@ service.interceptors.request.use(
       config.headers['Authorization'] = getToken()
       // config.headers['content-type'] = "application/x-www-form-urlencoded"
     }
-    // const tenantId = sessionStorage.getItem('tenantId') || null
-    // const configData = {
-    //   ...config.data,
-    //   tenantId
-    // }
-    // const configParams = {
-    //   ...config.params,
-    //   tenantId
-    // }
-    // config.data = cleanDeep(config.data)
+    const tenantId = sessionStorage.getItem('tenantId') || null
+    if(tenantId) {
+      config.headers['tenantId'] = tenantId
+    }
     config.params = cleanDeep(config.params)
     //  params: cleanDeep(options.params),
     //  (config)

+ 4 - 9
src/utils/request2.js

@@ -81,15 +81,10 @@ service.interceptors.request.use(
       // please modify it according to the actual situation
       config.headers['Authorization'] = getToken()
     }
-    // const tenantId = sessionStorage.getItem('tenantId') || null
-    // const configData = {
-    //   ...config.data,
-    //   tenantId
-    // }
-    // const configParams = {
-    //   ...config.params,
-    //   tenantId
-    // }
+    const tenantId = sessionStorage.getItem('tenantId') || null
+    if(tenantId) {
+      config.headers['tenantId'] = tenantId
+    }
     if (config.requestType === 'form') {
       config.headers['Content-Type'] = 'application/x-www-form-urlencoded'
       config.data = qs.stringify(cleanDeep(config.data))