lilei преди 1 година
родител
ревизия
70c626b7ad
променени са 3 файла, в които са добавени 27 реда и са изтрити 1 реда
  1. 2 0
      src/store/getters.js
  2. 13 1
      src/store/modules/app.js
  3. 12 0
      src/utils/request.js

+ 2 - 0
src/store/getters.js

@@ -26,6 +26,8 @@ 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
 }
 
 export default getters

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

@@ -48,9 +48,21 @@ const app = {
     warehouseAllList: null, // 无权限所有仓库列表
     defWarehouse: null, // 默认仓库
     isWarehouse: false,// 仓库管理权限
-    isShowCustomerSearch:false //客服查询权限
+    isShowCustomerSearch:false ,//客服查询权限
+    mainInterfaceList: [
+      'sales/findBySn', // 销售单
+      'dispatch/findBySalesBillSn', // 下推
+      'salesReturn/findBySn', // 销售退货
+      'sparePartsReturn/queryBySn', // 采购退货
+      'allocateBill/findBySn', // 调拨
+      'allocateReturn/queryBySn', //调拨退货
+    ], // 主单接口
+    noRestTimeStr: '', // 时间戳
   },
   mutations: {
+    SET_noRestTimeStr: (state, time) => {
+      state.noRestTimeStr = time
+    },
     SET_SIDEBAR_TYPE: (state, type) => {
       state.sidebar = type
       Vue.ls.set(SIDEBAR_TYPE, type)

+ 12 - 0
src/utils/request.js

@@ -112,9 +112,13 @@ 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['lock-time'] = noRestTimeStr
+  }
   config.headers['auth-price'] = authPrice.join(',') // 价格权限
   config.retry = 3
   config.retryDelay = 1000
@@ -161,6 +165,14 @@ service.interceptors.response.use((response) => {
     store.state.app.curActionPermission = ''
     store.commit('SET_loadingStatus', false)
   }
+  
+  // 防重复提交时间戳
+  const mainInterfaceList = store.getters.mainInterfaceList
+  const hasPath = mainInterfaceList.find(item => response.config.url.indexOf(item)>=0)
+  if(hasPath){
+    store.commit('SET_noRestTimeStr', response.data.data.updateDate)
+  }
+  
   return response.data
 }, err)