Explorar o código

工作台bizId处理

wangziqian %!s(int64=4) %!d(string=hai) anos
pai
achega
79ebfb9c35

+ 30 - 22
src/layout/components/Navbar.vue

@@ -44,7 +44,7 @@
 <script>
 import { mapGetters } from 'vuex'
 import { needIdList } from '@/router/needIdList'
-import { desDecryptId } from '@/utils/crypto-js.js'
+import { EncryptId, desDecryptId } from '@/utils/crypto-js.js'
 // import Breadcrumb from '@/components/Breadcrumb' // 面包屑
 // import Hamburger from '@/components/Hamburger'  // 导航开关
 import { logoutUrl } from '@/apiConfig/requestIP.js'
@@ -88,7 +88,7 @@ export default {
           return
         }// 如果参数中bizId和bizId_id都不存在,去获取默认bizId
         const existBizId_id = needIdList.find(item => item === to.name)
-        existBizId_id ? this.handerIdAndBizId() : this.handerBizId()
+        existBizId_id ? this.handlerIdAndBizId() : this.handlerBizId()
       },
       immediate: true
     }
@@ -97,17 +97,41 @@ export default {
     this.getLoginMember()
   },
   methods: {
-    handerBizId() { // 只处理bizId
+    handlerBizId() { // 只处理bizId
       const bizId = Number(desDecryptId(this.$route.query.bizId))
-      const isExistBizId = this.sumTypeArray.find(item => bizId === item.code)
+      const isExistBizId = this.sumTypeArray.find(item => bizId === item.code)// 业务线id是否存在
       isExistBizId ? this.$store.dispatch('data/setBizId', bizId) : this.settingUserGetBiz()
     },
-    handerIdAndBizId() { // 处理bizId和id
+    handlerIdAndBizId() { // 处理bizId和id
       const bizId_id = this.$route.query.bizId_id
       const arr = Number(desDecryptId(bizId_id)).split('_')
-      const isExistBizId = this.sumTypeArray.find(item => arr[0] === item.code)
+      const isExistBizId = this.sumTypeArray.find(item => arr[0] === item.code)// 业务线id是否存在
       isExistBizId ? this.$store.dispatch('data/setBizId', arr[0]) : this.settingUserGetBiz()
     },
+    async settingGetBizList() { // 获取业务线列表
+      const res = await settingGetBizList({})
+      this.sumTypeArray = res.data || []
+    },
+    async settingUserGetBiz() { // 获取人员默认业务线
+      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)
+        const existBizId_id = needIdList.find(item => item === this.$route.name)
+        if (!existBizId_id) {
+          this.$router.push({
+            path: this.$route.path,
+            query: {
+              ...this.$route.query,
+              bizId: EncryptId(nowBiz.code)
+            }
+          })
+        }
+      } else {
+        console.log('重定向到业务线选择页面')
+      }
+    },
     async remoteMethod(query) {
       if (query !== '') {
         const res = await settingGetBizList({ bizName: query })
@@ -133,22 +157,6 @@ export default {
         window.location.reload()
       }
     },
-    async settingGetBizList() { // 获取业务线列表
-      const res = await settingGetBizList({})
-      this.sumTypeArray = res.data || []
-    },
-    async settingUserGetBiz() { // 获取人员默认业务线
-      const res = await settingUserGetBiz()
-      if (res.data) {
-        const nowBiz = this.sumTypeArray.find(item => res.data.bizId === item.code)
-        if (nowBiz) {
-          this.sumType = nowBiz.name
-          this.$store.dispatch('data/setBizId', nowBiz.code)
-        } else {
-          console.log('重定向到业务线选择页面')
-        }
-      }
-    },
     async getLoginMember() { // 获取登录人员信息
       const res = await memberGetLoginInMemberInfoByLdap()
       this.options = res.data

+ 17 - 3
src/views/projectManage/projectList/components/modifySchedule.vue

@@ -152,10 +152,12 @@
 </template>
 <script>
 const _ = require('lodash')
+import { mapGetters } from 'vuex'
 import searchPeople from '@/components/select/searchPeople'
 import normalDialog from '@/components/dialog/normalDialog'
 import selDatePicker from '@/components/picker/SelDatePicker'
 import { taskList, configShowTaskEnum, taskGet, listRequireAndTask } from '@/api/taskIndex'
+import { settingGetBizList } from '@/api/projectIndex'
 import { getSeprateDayInfo, scheduleCreate, scheduleGet, scheduleUpdate, scheduleDelete } from '@/api/projectViewDetails'
 import danger from '@/assets/感叹@2x.png'
 export default {
@@ -214,9 +216,10 @@ export default {
       show: this.visible,
       isDeleteStatus: this.isDelete,
       taskScheduleEvent: [], // 排期类型选项
+      bizIdList: [], // bizId列表
       form: {
-        bizId: localStorage.getItem('bizId'),
-        bizName: localStorage.getItem('bizName'),
+        bizId: this.bizId,
+        bizName: null,
         type: '',
         peopleList: [],
         taskList: [],
@@ -243,6 +246,11 @@ export default {
       hiddenList: [] // 隐藏的需求列表
     }
   },
+  computed: {
+    ...mapGetters([
+      'bizId'
+    ])
+  },
   watch: {
     visible: {
       handler(newV, old) {
@@ -293,6 +301,7 @@ export default {
   },
   mounted() {
     if (!this.isDeleteStatus) this.loadObserve()
+    if (this.form.bizName === null) this.settingGetBizList()
   },
   destroyed() {
     if (this.observer) this.observer.disconnect()
@@ -315,6 +324,12 @@ export default {
         this.observer.observe(document.getElementById('load-more'))
       })
     },
+    async settingGetBizList() { // 获取bizId列表
+      const res = await settingGetBizList({})
+      this.bizIdList = res.data || []
+      const nowBiz = this.bizIdList.find(item => item.code === this.bizId)
+      this.form.bizName = nowBiz.name
+    },
     async initTask() { // 任务页面下获取当前任务
       const res = await taskGet(this.$route.query.id)
       if (res.code === 200) {
@@ -426,7 +441,6 @@ export default {
             }
           })
         }
-        console.log(this.tasksByOptions)
         if (this.taskTotal <= this.tasksByOptions.length) this.loadMore = false// 全部数据已加载完成
       }
       this.loading = false

+ 7 - 12
src/views/workbench/person/index.vue

@@ -143,7 +143,7 @@
             <el-tab-pane label="日历视图" name="1" />
             <el-tab-pane label="列表视图" name="3" />
           </el-tabs>
-          <list-view v-if="activeSchedule === '3'" ref="listView" :biz="bizCode" :type="'个人'" />
+          <list-view v-if="activeSchedule === '3'" ref="listView" :biz="bizId" :type="'个人'" />
           <search-section
             v-show="activeSchedule === '1'"
             :value.sync="filtrate"
@@ -295,7 +295,6 @@ export default {
     return {
       activeName: '1', // 顶部导航栏
       bizName: '业务线', // 状态Name
-      bizCode: '',
       calendarView: null,
       chirdrenClass: -1,
       myTeamTableData: [],
@@ -323,7 +322,7 @@ export default {
       },
       searchForm: { // 搜索条件
         teamId: null,
-        bizId: null
+        bizId: this.bizId
       },
       dialog_schedule_visible: false, // 删除日程弹窗
       DialogTitle: '编辑排期', // 排期弹框标题
@@ -370,7 +369,7 @@ export default {
   },
   computed: {
     ...mapGetters([
-      'notice'
+      'bizId'
     ])
   },
   watch: {
@@ -448,13 +447,9 @@ export default {
     },
     handleBizId(e) { // 业务线变动
       const res = this.searchEnum.find(item => item.code === e)
-      this.bizCode = res.code
       this.bizName = res.name
-      localStorage.setItem('bizId', res.code)
-      localStorage.setItem('bizName', res.name)
-      if (this.activeSchedule === '1') {
-        this.queryWorkListByTime(this.calendarView)
-      }
+      this.$store.dispatch('data/setBizId', res.code)
+      if (this.activeSchedule === '1') this.queryWorkListByTime(this.calendarView)
     },
     addCalender(arg) { // 新建日程弹框
       this.createSchedule.data = arg
@@ -472,7 +467,7 @@ export default {
       const form = { // 日程的form
         detailDayList: dayArr,
         id: this.nowDetailData.id,
-        bizName: this.nowDetailData.bizName,
+        bizName: '',
         name: this.nowDetailData.name,
         dayList: Array.from(new Set([dayArr[0], dayArr[dayArr.length - 1]])),
         syncTeam: this.nowDetailData.syncTeam, // 是否同步 0 不同步 1同步
@@ -533,7 +528,7 @@ export default {
             ? moment(this.calendarView.activeEnd).format('YYYY.MM.DD')
             : moment().endOf('month').format('YYYY.MM.DD')
         },
-        teamSearchInfo: { bizId: this.bizCode },
+        teamSearchInfo: { bizId: this.bizId },
         searchScheduleInfo: {
           origin: this.filtrate.origin,
           scheduleTypeList: this.filtrate.scheduleTypeList,

+ 8 - 5
src/views/workbench/team/index.vue

@@ -52,7 +52,7 @@
           <el-tab-pane label="列表视图" name="3" />
           <el-tab-pane label="甘特图" name="2" />
         </el-tabs>
-        <list-view v-show="activeSchedule === '3'" :type="'团队'" :biz="bizCode" />
+        <list-view v-show="activeSchedule === '3'" :type="'团队'" :biz="bizId" />
         <search-section
           v-show="activeSchedule === '1'"
           ref="search-section"
@@ -212,6 +212,7 @@
 <script>
 import moment from 'moment'
 import dayjs from 'dayjs'
+import { mapGetters } from 'vuex'
 import { settingGetBizList } from '@/api/defectManage'
 import {
   queryTeamInfoList,
@@ -284,7 +285,6 @@ export default {
         }
       ],
       loading: true,
-      bizCode: '',
       calendarView: null, // 日程图表数据
       showDetail: false, // 显示详情弹框
       nowDetailData: {}, // 当前选中日程的数据
@@ -326,6 +326,11 @@ export default {
       getTeamBugDisDataBy: getTeamBugDisDataBy// 缺陷按状态统计数据接口
     }
   },
+  computed: {
+    ...mapGetters([
+      'bizId'
+    ])
+  },
   watch: {
     activeName: {
       handler(newV) {
@@ -389,9 +394,7 @@ export default {
       this.searchForm.bizId = e
       const res = this.searchEnum.businesslines.find(item => item.code === e)
       this.bizName = res.name
-      this.bizCode = res.code
-      localStorage.setItem('bizId', res.code)
-      localStorage.setItem('bizName', res.name)
+      this.$store.dispatch('data/setBizId', res.code)
       if (this.$refs['search-section']) {
         this.$refs['search-section'].queryTeamMember()
       }