Bladeren bron

路由fix bug

wangziqian 4 jaren geleden
bovenliggende
commit
317dd25a1c

+ 18 - 5
src/layout/components/Navbar.vue

@@ -45,7 +45,6 @@ export default {
       value: '',
       arr_data: [],
       sumTypeArray: [],
-      sumType: '',
       formulaArea: '', // 公式的文本框
       typeObj: {},
       showBizId: false
@@ -60,6 +59,11 @@ export default {
     ]),
     username() {
       return localStorage.getItem('realname')
+    },
+    sumType() {
+      const nowBiz = this.sumTypeArray.find(item => item.code === this.bizId)
+      if (nowBiz) return nowBiz.name
+      return ''
     }
   },
   watch: {
@@ -71,11 +75,23 @@ export default {
         if (from && to.path === from.path) return
         // 如果业务线列表不存在,请求获取路由业务线列表
         if (this.sumTypeArray.length < 1) await this.settingGetBizList()
-        // 如果参数中bizId和bizId_id都不存在,去获取默认bizId
+        // 如果已存在业务线ID
+        if (this.bizId !== -1) {
+          const existBizId_id = needIdList.find(item => item === this.$route.name)
+          existBizId_id
+            ? ''
+            : this.$router.replace({
+              path: this.$route.path,
+              query: { ...this.$route.query, bizId: EncryptId(this.bizId) }
+            })
+          return
+        }
+        // 如果前往路由中参数中bizId和bizId_id都不存在,去获取默认bizId
         if (!to.query.bizId && !to.query.bizId_id) {
           this.settingUserGetBiz()
           return
         }
+        // 如果是需要bizId和id的详情页
         const existBizId_id = needIdList.find(item => item === to.name)
         existBizId_id ? this.handlerIdAndBizId() : this.handlerBizId()
       },
@@ -91,7 +107,6 @@ export default {
       const isExistBizId = this.sumTypeArray.find(item => bizId === item.code)// 业务线id是否存在
       if (isExistBizId) {
         this.$store.dispatch('data/setBizId', bizId)
-        this.sumType = isExistBizId.name
       } else {
         this.settingUserGetBiz()
       }
@@ -103,7 +118,6 @@ export default {
       const isExistBizId = this.sumTypeArray.find(item => Number(arr[0]) === item.code)// 业务线id是否存在
       if (isExistBizId) {
         this.$store.dispatch('data/setBizId', Number(arr[0]))
-        this.sumType = isExistBizId.name
       } else {
         this.settingUserGetBiz()
       }
@@ -117,7 +131,6 @@ export default {
       const res = await settingUserGetBiz()
       const nowBiz = this.sumTypeArray.find(item => res.data.bizId === item.code)
       if (nowBiz) {
-        this.sumType = nowBiz.name
         this.$store.dispatch('data/setBizId', nowBiz.code)
         localStorage.setItem('bizId', nowBiz.code)
         const existBizId_id = needIdList.find(item => item === this.$route.name)

+ 23 - 13
src/views/quality/defectStatistics.vue

@@ -306,6 +306,7 @@
 <script>
 import moment from 'moment'
 moment.locale('zh-cn')
+import { mapGetters } from 'vuex'
 import { settingQueryBizModuleList } from '@/api/defectManage'
 import { teamQueryTeamInfoList } from '@/api/configure'
 import {
@@ -371,14 +372,23 @@ export default {
       childParams: null // 二级子图表的筛选项
     }
   },
+  computed: {
+    ...mapGetters(['bizId'])
+  },
+  watch: {
+    bizId: {
+      handler(newV) {
+        if (newV === -1) return
+        this.$nextTick(() => { this.onSubmit() })
+      },
+      immediate: true
+    }
+  },
   created() {
     this.$store.state.data.status = true
     this.setDate(this.dateType)
     this.getTeamList()
   },
-  mounted() {
-    this.onSubmit()
-  },
   methods: {
     onSubmit() {
       this.getSummary()
@@ -403,7 +413,7 @@ export default {
       }]
     },
     async bugDataGet() { // 所属模块
-      const res = await settingQueryBizModuleList(Number(localStorage.getItem('bizId')))
+      const res = await settingQueryBizModuleList(this.bizId)
       this.moduleList = this.handlerModules(res.data)
     },
     handlerModules(arr) {
@@ -454,7 +464,7 @@ export default {
       const params = {
         startTime: this.stratAndEnd[0] || null,
         endTime: this.stratAndEnd[1] || null,
-        bizId: Number(localStorage.getItem('bizId')),
+        bizId: this.bizId,
         teamIds: this.defectForm.team || null,
         moduleIds: moduleIds && moduleIds.length > 0 ? moduleIds : null
       }
@@ -466,7 +476,7 @@ export default {
       const params = {
         beginTime: this.stratAndEnd[0] || null,
         endTime: this.stratAndEnd[1] || null,
-        bizId: Number(localStorage.getItem('bizId')),
+        bizId: this.bizId,
         teamIds: this.defectForm.team || null,
         moduleIds: moduleIds && moduleIds.length > 0 ? moduleIds : null,
         timeType: this.bugCountTimeType
@@ -492,7 +502,7 @@ export default {
       const params = {
         startTime: this.stratAndEnd[0] || null,
         endTime: this.stratAndEnd[1] || null,
-        bizId: Number(localStorage.getItem('bizId')),
+        bizId: this.bizId,
         teamIds: this.defectForm.team || null,
         type: this.activeTab,
         distributeType: this.defectStatus,
@@ -563,7 +573,7 @@ export default {
       this.childParams = {
         startTime: this.stratAndEnd[0] || null,
         endTime: this.stratAndEnd[1] || null,
-        bizId: Number(localStorage.getItem('bizId')),
+        bizId: this.bizId,
         teamIds: this.defectForm.team || null,
         type: this.activeTab,
         distributeType: 8,
@@ -576,7 +586,7 @@ export default {
       const params = {
         startTime: this.stratAndEnd[0] || null,
         endTime: this.stratAndEnd[1] || null,
-        bizId: Number(localStorage.getItem('bizId')),
+        bizId: this.bizId,
         teamIds: this.defectForm.team || null,
         type: this.activeTab,
         moduleIds: moduleIds && moduleIds.length > 0 ? moduleIds : null
@@ -597,7 +607,7 @@ export default {
       const params = {
         startTime: this.stratAndEnd[0] || null,
         endTime: this.stratAndEnd[1] || null,
-        bizId: Number(localStorage.getItem('bizId')),
+        bizId: this.bizId,
         teamIds: this.defectForm.team || null,
         type: this.activeTab,
         moduleIds: moduleIds && moduleIds.length > 0 ? moduleIds : null
@@ -611,7 +621,7 @@ export default {
       const params = {
         startTime: this.stratAndEnd[0] || null,
         endTime: this.stratAndEnd[1] || null,
-        bizId: Number(localStorage.getItem('bizId')),
+        bizId: this.bizId,
         teamIds: this.defectForm.team || null,
         type: this.activeTab,
         moduleIds: moduleIds && moduleIds.length > 0 ? moduleIds : null
@@ -681,7 +691,7 @@ export default {
       const params = {
         startTime: this.stratAndEnd[0] || null,
         endTime: this.stratAndEnd[1] || null,
-        bizId: Number(localStorage.getItem('bizId')),
+        bizId: this.bizId,
         teamIds: this.defectForm.team || null,
         moduleIds: moduleIds && moduleIds.length > 0 ? moduleIds : null,
         type: this.activeTab,
@@ -707,7 +717,7 @@ export default {
       const params = {
         startTime: this.stratAndEnd[0] || null,
         endTime: this.stratAndEnd[1] || null,
-        bizId: Number(localStorage.getItem('bizId')),
+        bizId: this.bizId,
         teamIds: this.defectForm.team || null,
         moduleIds: moduleIds && moduleIds.length > 0 ? moduleIds : null,
         type: this.activeTab,

+ 21 - 8
src/views/quality/requireStatistics.vue

@@ -171,6 +171,7 @@
 <script>
 import moment from 'moment'
 moment.locale('zh-cn')
+import { mapGetters } from 'vuex'
 import { settingQueryBizRqmtOrntList } from '@/api/requirement'
 import { teamQueryTeamInfoList } from '@/api/configure'
 import {
@@ -254,6 +255,7 @@ export default {
     }
   },
   computed: {
+    ...mapGetters(['bizId']),
     globalParams: { // 通用接口参数
       get() {
         const rqmtOrntIds = this.chartForm.rqmtOrntIds
@@ -261,7 +263,7 @@ export default {
         const params = {
           startTime: this.stratAndEnd[0] || null,
           endTime: this.stratAndEnd[1] || null,
-          bizId: Number(localStorage.getItem('bizId')),
+          bizId: this.bizId,
           teamIds: team && team.length > 0 ? team : null,
           rqmtOrntIds: rqmtOrntIds && rqmtOrntIds.length > 0 ? rqmtOrntIds : null
         }
@@ -289,14 +291,25 @@ export default {
       }
     }
   },
-  async created() {
+  watch: {
+    bizId: {
+      handler(newV) {
+        if (newV === -1) return
+        this.init()
+      },
+      immediate: true
+    }
+  },
+  created() {
     this.$store.state.data.status = true
-    await this.getRequireCountTitleEnum()
-    this.setDate(this.dateType)
-    this.getTeamList()
-    this.getRequireDirection()
   },
   methods: {
+    async init() {
+      await this.getRequireCountTitleEnum()
+      this.setDate(this.dateType)
+      this.getTeamList()
+      this.getRequireDirection()
+    },
     onSubmit() {
       if (this.activeTab === '2' && this.distributeStatus === 1) {
         this.distributeStatus = 2
@@ -336,14 +349,14 @@ export default {
       this.onSubmit()
     },
     async getRequireCountTitleEnum() { // 趋势图的动态title枚举
-      const res = await getRequireCountTitleEnum({ bizId: Number(localStorage.getItem('bizId')) })
+      const res = await getRequireCountTitleEnum({ bizId: this.bizId })
       if (res.code === 200) {
         this.countTitle = res.data || []
         this.activeTab = `${res.data[0].code}`
       }
     },
     async getRequireDirection() { // 需求方向列表
-      const res = await settingQueryBizRqmtOrntList(Number(localStorage.getItem('bizId')))
+      const res = await settingQueryBizRqmtOrntList(this.bizId)
       if (res.code === 200) {
         this.moduleList = this.getRequireData(res.data)
       }

+ 17 - 4
src/views/quality/taskStatistics.vue

@@ -172,6 +172,7 @@
 <script>
 import moment from 'moment'
 moment.locale('zh-cn')
+import { mapGetters } from 'vuex'
 import { settingQueryBizModuleList } from '@/api/defectManage'
 import { teamQueryTeamInfoList } from '@/api/configure'
 import {
@@ -258,6 +259,7 @@ export default {
     }
   },
   computed: {
+    ...mapGetters(['bizId']),
     globalParams: { // 通用接口参数
       get() {
         const moduleIds = this.chartForm.moduleIds
@@ -293,13 +295,24 @@ export default {
       }
     }
   },
+  watch: {
+    bizId: {
+      handler(newV) {
+        if (newV === -1) return
+        this.init()
+      },
+      immediate: true
+    }
+  },
   created() {
     this.$store.state.data.status = true
-    this.setDate(this.dateType)
-    this.getTeamList()
-    this.getMoudlesList()
   },
   methods: {
+    async init() {
+      this.setDate(this.dateType)
+      this.getTeamList()
+      this.getMoudlesList()
+    },
     onSubmit() {
       if (this.activeTab === '2' && this.distributeStatus === 1) {
         this.distributeStatus = 2
@@ -341,7 +354,7 @@ export default {
       this.onSubmit()
     },
     async getMoudlesList() { // 技术模块
-      const res = await settingQueryBizModuleList(Number(localStorage.getItem('bizId')))
+      const res = await settingQueryBizModuleList(this.bizId)
       if (res.code === 200) {
         this.moduleList = this.handlerModules(res.data)
       }