wenbobowen 4 سال پیش
والد
کامیت
bb6238d3d4
1فایلهای تغییر یافته به همراه20 افزوده شده و 3 حذف شده
  1. 20 3
      src/components/newLayout/Main.vue

+ 20 - 3
src/components/newLayout/Main.vue

@@ -17,12 +17,13 @@
 import { mapGetters } from 'vuex'
 import { needIdList } from '@/router/needIdList'
 import { EncryptId, desDecryptId, analysisBizId_id } from '@/utils/crypto-js.js'
-import { settingGetBizList, settingUserGetBiz } from '@/api/projectIndex'
+import { settingGetBizList, settingUserGetBiz, settingUserSetBiz } from '@/api/projectIndex'
 export default {
   data() {
     return {
       bizIdList: [], // 业务线列表
-      showpage: false
+      showpage: false,
+      getBizId: -1
     }
   },
   computed: {
@@ -36,6 +37,9 @@ export default {
       immediate: true
     }
   },
+  created() {
+    this.resetBizId()
+  },
   // created() {
   // this.settingUserGetBiz()
   // },
@@ -65,6 +69,14 @@ export default {
     //   //   this.showpage = true
     //   // }
     // },
+    async resetBizId() {
+      const res = await settingUserGetBiz()
+      if (res.code === 200) {
+        // this.showpage = true
+        // this.$store.dispatch('global/setBizId', res.data.bizId)
+        this.getBizId = res.data.bizId
+      }
+    },
     // 获取业务线列表
     async settingGetBizList() {
       const res = await settingGetBizList({})
@@ -103,7 +115,7 @@ export default {
       }
     },
     // 页面处理
-    handlerPage() {
+    async handlerPage() {
       // 是否是需要bizId_id的详情页
       const existBizId_id = needIdList.find(item => item === this.$route.name)
       let bizId = -1
@@ -116,6 +128,11 @@ export default {
       if (isExistBizId) {
         this.$store.dispatch('global/setBizId', bizId)
         this.$store.dispatch('global/setBizName', isExistBizId.name)
+        // 如果路由和数据库的bizid不相同则重置数据库中bizid为路由id
+        if (this.getBizId !== bizId) {
+          await settingUserSetBiz({ bizId })
+          this.getBizId = bizId
+        }
       } else {
         this.getDefaultBizId()
       }