lilei 1 year ago
parent
commit
06d2320e47
4 changed files with 67 additions and 24 deletions
  1. 1 2
      src/store/getters.js
  2. 44 13
      src/store/modules/app.js
  3. 20 7
      src/utils/request.js
  4. 2 2
      vue.config.js

+ 1 - 2
src/store/getters.js

@@ -26,8 +26,7 @@ const getters = {
   isWarehouse: state => state.app.isWarehouse,
   defWarehouse: state => state.app.defWarehouse,
   isShowCustomerSearch: state => state.app.isShowCustomerSearch,
-  mainInterfaceList: state => state.app.mainInterfaceList,
-  noRestTimeStr: state => state.app.noRestTimeStr
+  interFaceList: state => state.app.interFaceList,
 }
 
 export default getters

+ 44 - 13
src/store/modules/app.js

@@ -49,21 +49,52 @@ const app = {
     defWarehouse: null, // 默认仓库
     isWarehouse: false,// 仓库管理权限
     isShowCustomerSearch:false ,//客服查询权限
-    mainInterfaceList: [
-      'sales/findBySn', // 销售单,下推
-      'salesReturn/findBySn', // 销售退货
-      'spareParts/queryDetailPageCount', // 散件入库
-      'sparePartsReturn/queryBySn', // 采购退货
-      'allocateBill/findBySn', // 调拨
-      'allocateReturn/queryBySn', //调拨退货
-      'sendBill/findBySn', // 发货单
-    ], // 主单接口
-    noRestTimeStr: '', // 时间戳
+    interFaceList: [
+      // 销售单,下推
+     {
+        a: 'sales/findBySn',
+        b: ['sales/submit','dispatch/pushDown'],
+        timeStr: ''
+      },
+      // 销售退货
+      {
+        a: 'salesReturn/findBySn',
+        b: ['salesReturn/submitVerify','salesReturn/submit'],
+        timeStr: ''
+      },
+      // 散件入库
+      {
+        a: 'spareParts/queryDetailPageCount',
+        b: ['spareParts/saveDetail','spareParts/detail/parseProducts'],
+        timeStr: ''
+      },
+      // 采购退货
+      {
+        a: 'sparePartsReturn/queryBySn',
+        b: ['sparePartsReturn/submit'],
+        timeStr: ''
+      },
+      // 调拨
+     {
+        a: 'allocateBill/findBySn',
+        b: ['allocateBill/submit'],
+        timeStr: ''
+      },
+      //调拨退货
+      {
+        a: 'allocateReturn/queryBySn',
+        b: ['allocateReturn/submit'],
+        timeStr: ''
+      },
+      // 发货单
+      {
+        a: 'sendBill/findBySn',
+        b: ['sendBill/update'],
+        timeStr: ''
+      },
+    ]
   },
   mutations: {
-    SET_noRestTimeStr: (state, time) => {
-      state.noRestTimeStr = time
-    },
     SET_SIDEBAR_TYPE: (state, type) => {
       state.sidebar = type
       Vue.ls.set(SIDEBAR_TYPE, type)

+ 20 - 7
src/utils/request.js

@@ -112,13 +112,24 @@ const err = (error) => {
 service.interceptors.request.use(config => {
   const authPrice = getAuthPriceCode(config, router, store)
   const token = store.getters.token
-  const noRestTimeStr = store.getters.noRestTimeStr
   if (token) {
     config.headers['access-token'] = token // 让每个请求携带自定义 token 请根据实际情况自行修改
   }
-  if(noRestTimeStr){
-    config.headers['biz-updatedate'] = noRestTimeStr
+  
+  // 获取当前时间撮
+  const interFaceList = store.getters.interFaceList
+  const curPath = config.url
+  if(interFaceList){
+    const hasPath = interFaceList.find(item => {
+      const hasSp = item.b.find(k => curPath.indexOf(k)>=0)
+      return hasSp
+    })
+    console.log(hasPath,'submit time')
+    if(hasPath){
+      config.headers['biz-updatedate'] = hasPath.timeStr
+    }
   }
+   
   config.headers['auth-price'] = authPrice.join(',') // 价格权限
   config.retry = 3
   config.retryDelay = 1000
@@ -167,11 +178,13 @@ service.interceptors.response.use((response) => {
   }
   
   // 防重复提交时间戳
-  const mainInterfaceList = store.getters.mainInterfaceList
-  if(mainInterfaceList){
-    const hasPath = mainInterfaceList.find(item => response.config.url.indexOf(item)>=0)
+  const interFaceList = store.getters.interFaceList
+  const curPath = response.config.url
+  if(interFaceList){
+    const hasPath = interFaceList.find(item => curPath.indexOf(item.a)>=0)
+    console.log(hasPath,'get time')
     if(hasPath){
-      store.commit('SET_noRestTimeStr', response.data.data.updateDate)
+      hasPath.timeStr = response.data.data.updateDate
     }
   }
   return response.data

+ 2 - 2
vue.config.js

@@ -108,9 +108,9 @@ const vueConfig = {
     // If you want to turn on the proxy, please remosve the mockjs /src/main.jsL11
     proxy: {
       '/api': {
-        target: 'http://192.168.2.113:8660/ocs-admin',
+        // target: 'http://192.168.2.113:8660/ocs-admin',
         // target: 'https://t.ocs.360arrow.com/ocs-admin', //  练习
-        // target: 'https://p.ocs.360arrow.com/ocs-admin', //  预发布
+        target: 'https://p.ocs.360arrow.com/ocs-admin', //  预发布
         ws: false,
         changeOrigin: true,
         pathRewrite: {