princeLee 4 年之前
父節點
當前提交
8653acfa6f
共有 1 個文件被更改,包括 6 次插入3 次删除
  1. 6 3
      src/layout/components/Navbar.vue

+ 6 - 3
src/layout/components/Navbar.vue

@@ -75,12 +75,14 @@ export default {
           window.location.href = redirect[redirectUrl]
           window.location.reload()
         }
+        // 如果业务线列表不存在,请求获取路由业务线列表
+        if (this.sumTypeArray.length < 1) await this.settingGetBizList()
+        // 如果没有业务线,但是页面又是工作台
+        if (this.bizId === -1 && (to.name === '个人工作台' || to.name === '团队工作台')) this.settingUserGetBiz(true)
         // 如果是业务线选择页面,不作处理
         if (to.name === '业务线选择' || to.name === '个人工作台' || to.name === '团队工作台') return
         // 如果与原路由相同,不作处理
         if (from && to.path === from.path) return
-        // 如果业务线列表不存在,请求获取路由业务线列表
-        if (this.sumTypeArray.length < 1) await this.settingGetBizList()
         // 如果已存在业务线ID
         if (this.bizId !== -1) {
           const existBizId_id = needIdList.find(item => item === this.$route.name)
@@ -132,12 +134,13 @@ export default {
       const res = await settingGetBizList({})
       this.sumTypeArray = res.data || []
     },
-    async settingUserGetBiz() { // 获取人员默认业务线
+    async settingUserGetBiz(noQuery = false) { // 获取人员默认业务线
       const res = await settingUserGetBiz()
       const nowBiz = this.sumTypeArray.find(item => res.data.bizId === item.code)
       if (nowBiz) {
         this.$store.dispatch('data/setBizId', nowBiz.code)
         localStorage.setItem('bizId', nowBiz.code)
+        if (noQuery) return // 如果是不需要url参数的,直接返回
         const existBizId_id = needIdList.find(item => item === this.$route.name)
         // 如果不是在需要bizId_id的详情页,就去给路由添加bizId
         existBizId_id