Browse Source

项目页面业务线改动

wangziqian 4 years ago
parent
commit
843693848d

+ 21 - 10
src/layout/components/Navbar.vue

@@ -82,7 +82,8 @@ export default {
   watch: {
     $route: {
       async handler(to, from) {
-        await this.settingGetBizList()
+        if (from && to.path === from.path) return // 如果与原路由相同,return
+        if (this.sumTypeArray.length < 1) await this.settingGetBizList() // 如果业务线列表不存在,请求获取路由业务线列表
         if (!to.query.bizId && !to.query.bizId_id) {
           this.settingUserGetBiz()
           return
@@ -100,13 +101,25 @@ export default {
     handlerBizId() { // 只处理bizId
       const bizId = Number(desDecryptId(this.$route.query.bizId))
       const isExistBizId = this.sumTypeArray.find(item => bizId === item.code)// 业务线id是否存在
-      isExistBizId ? this.$store.dispatch('data/setBizId', bizId) : this.settingUserGetBiz()
+      if (isExistBizId) {
+        this.$store.dispatch('data/setBizId', bizId)
+        this.sumType = isExistBizId.name
+      } else {
+        this.settingUserGetBiz()
+      }
+      console.log('mainbizId', this.bizId)
     },
     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)// 业务线id是否存在
-      isExistBizId ? this.$store.dispatch('data/setBizId', arr[0]) : this.settingUserGetBiz()
+      const arr = desDecryptId(bizId_id).split('_')
+      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()
+      }
+      console.log('mainbizId', this.bizId)
     },
     async settingGetBizList() { // 获取业务线列表
       const res = await settingGetBizList({})
@@ -118,14 +131,12 @@ export default {
       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)
-        if (!existBizId_id) {
+        if (!existBizId_id) { // 如果不是在需要bizId_id的详情页,就去给路由添加bizId
           this.$router.push({
             path: this.$route.path,
-            query: {
-              ...this.$route.query,
-              bizId: EncryptId(nowBiz.code)
-            }
+            query: { ...this.$route.query, bizId: EncryptId(nowBiz.code) }
           })
         }
       } else {

+ 3 - 1
src/router/needIdList.js

@@ -1,3 +1,5 @@
 export const needIdList = [
-  '项目'
+  '项目详情',
+  '需求详情',
+  '任务详情'
 ]

+ 17 - 0
src/utils/crypto-js.js

@@ -33,3 +33,20 @@ export function desDecryptId(word) {
   })
   return CryptoJS.enc.Utf8.stringify(decrypted).toString()
 }
+
+// 解析Id和bizId的数据
+export function analysisBizId_id(bizId_id) {
+  if (!bizId_id) return [-1, -1]
+  try {
+    const newStr = desDecryptId(bizId_id)
+    const newArr = newStr.split('_')
+    if (newArr.length === 2) {
+      return [Number(newArr[0]), Number(newArr[1])]
+    } else {
+      return [-1, -1]
+    }
+  } catch (error) {
+    console.error(error)
+    return [-1, -1]
+  }
+}

+ 5 - 1
src/views/projectManage/projectList/components/dataStatistics.vue

@@ -58,6 +58,7 @@
   </div>
 </template>
 <script>
+import { analysisBizId_id } from '@/utils/crypto-js.js'
 import normalEchart from '@/components/chart/normalEchart'
 import RequirementCreate from '@/views/projectManage/requirement/list/create'
 import openDialog from '@/views/projectManage/dialog_vue'
@@ -97,7 +98,10 @@ export default {
   },
   methods: {
     async getProjectSumData() { // 获取数据
-      const res = await getProjectSumData(this.$route.query.id)
+      const bizId_id = analysisBizId_id(this.$route.query.bizId_id)
+      this.projectId = bizId_id[1]
+      if (this.projectId === -1) return
+      const res = await getProjectSumData(this.projectId)
       if (res.code === 200) {
         this.requireData = res.data.requireData
         this.taskData = res.data.taskData

+ 6 - 2
src/views/projectManage/projectList/components/modifyProject.vue

@@ -84,6 +84,7 @@
   </normal-dialog>
 </template>
 <script>
+import { analysisBizId_id } from '@/utils/crypto-js.js'
 import {
   projectList,
   projectUpdate,
@@ -109,7 +110,7 @@ export default {
       userInformation: localStorage.getItem('username'),
       userNames: localStorage.getItem('realname'),
       modify_project: false,
-      project_from: null,
+      project_from: { projectOwner: null, rdOwner: null },
       rules_form: {
         name: [{ required: true, message: '请输入项目名称', trigger: 'blur' }],
         bizType: [
@@ -158,8 +159,11 @@ export default {
       }
     },
     async getProjectList() {
+      const bizId_id = analysisBizId_id(this.$route.query.bizId_id)
+      this.projectId = bizId_id[1]
+      if (this.projectId === -1) return
       const params = {
-        id: this.$route.query.id
+        id: this.projectId
       }
       const res = await projectList(params)
       if (res.code === 200) {

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

@@ -152,6 +152,7 @@
 </template>
 <script>
 const _ = require('lodash')
+import { analysisBizId_id } from '@/utils/crypto-js.js'
 import { mapGetters } from 'vuex'
 import searchPeople from '@/components/select/searchPeople'
 import normalDialog from '@/components/dialog/normalDialog'
@@ -331,7 +332,8 @@ export default {
       this.form.bizName = nowBiz.name
     },
     async initTask() { // 任务页面下获取当前任务
-      const res = await taskGet(this.$route.query.id)
+      const bizId_id = analysisBizId_id(this.$route.query.bizId_id)
+      const res = await taskGet(Number(bizId_id[1]))
       if (res.code === 200) {
         // this.tasksOptions = [res.data]
         this.tasksDetailList = [res.data]
@@ -384,9 +386,9 @@ export default {
       if (resEnum.code === 200) this.taskScheduleEvent = resEnum.data.taskScheduleEvent
     },
     async getNowTask() { // 获取当前项目/需求下任务
-      if (!this.$route.query.id) return
+      const bizId_id = analysisBizId_id(this.$route.query.bizId_id)
       const params = {}
-      params[this.type] = this.$route.query.id
+      params[this.type] = Number(bizId_id[1])
       const res = await taskList(params)
       if (res.code === 200) {
         this.tasksOptions = res.data

+ 18 - 7
src/views/projectManage/projectList/components/needsList.vue

@@ -86,6 +86,8 @@
   </div>
 </template>
 <script>
+import { analysisBizId_id } from '@/utils/crypto-js.js'
+import { mapGetters } from 'vuex'
 import { requirementQueryRequirementInfoList } from '@/api/projectIndex'
 import { configShowRequireStatusEnum, updateRequirementStatus } from '@/api/requirement'
 import extraUrgent from '@/assets/extraUrgent.png'
@@ -103,25 +105,34 @@ export default {
       statusObj: {}
     }
   },
+  computed: {
+    ...mapGetters(['bizId'])
+  },
+  watch: {
+    bizId: {
+      handler() {
+        this.getTaskStatus()
+      },
+      immediate: true
+    }
+  },
   created() {
-    this.getTaskStatus()
     this.getNeedsList()
   },
   methods: {
     async getTaskStatus() { // 获取需求的所有状态
-      const res1 = await configShowRequireStatusEnum(localStorage.getItem('bizId'))
+      const res1 = await configShowRequireStatusEnum(this.bizId)
       if (res1.code === 200) {
         this.allStatus = []
         this.allStatus = res1.data.requirementStatus
       }
-      // const res = await showRequirementEnum()
-      // if (res.code === 200) {
-      //   this.allStatus = res.data.requirementStatus
-      // }
     },
     async getNeedsList() {
+      const bizId_id = analysisBizId_id(this.$route.query.bizId_id)
+      this.projectId = bizId_id[1]
+      if (this.projectId === -1) return
       this.rqmtStatusShow = false
-      const res = await requirementQueryRequirementInfoList({ belongingProject: this.$route.query.id })
+      const res = await requirementQueryRequirementInfoList({ belongingProject: this.projectId })
       if (res.code === 200) {
         this.needsDataList = res.data.list
       }

+ 18 - 3
src/views/projectManage/projectList/components/taskList.vue

@@ -120,6 +120,8 @@
   </div>
 </template>
 <script>
+import { analysisBizId_id } from '@/utils/crypto-js.js'
+import { mapGetters } from 'vuex'
 import imgUrl from '@/assets/建立档案@2x.png'
 import TestReport from '@/views/reportManagement/components/TestingReport' // 提测
 import DailyReport from '@/views/reportManagement/components/DailyReport' // 日报
@@ -167,14 +169,27 @@ export default {
       selectTaskList: [] // 已选任务的id
     }
   },
+  computed: {
+    ...mapGetters(['bizId'])
+  },
+  watch: {
+    bizId: {
+      handler() {
+        this.getTaskStatus()
+      },
+      immediate: true
+    }
+  },
   created() {
-    this.getTaskStatus()
     this.get_allTask()
   },
   methods: {
     async get_allTask() { // 获取全部任务
+      const bizId_id = analysisBizId_id(this.$route.query.bizId_id)
+      this.projectId = bizId_id[1]
+      if (this.projectId === -1) return
       const res = await taskList({
-        projectId: this.$route.query.id
+        projectId: this.projectId
       })
       if (res.code === 200) {
         this.all_task = res.data
@@ -185,7 +200,7 @@ export default {
       if (res.code === 200) {
         this.taskScheduleEvent = res.data.taskScheduleEvent || []
       }
-      const res1 = await configShowTaskStatusEnum(localStorage.getItem('bizId'))
+      const res1 = await configShowTaskStatusEnum(this.bizId)
       if (res1.code === 200) {
         this.allStatus = res1.data.taskStatus
       }

+ 17 - 26
src/views/projectManage/projectList/projectIndex.vue

@@ -326,6 +326,8 @@
 </template>
 
 <script>
+import { EncryptId } from '@/utils/crypto-js.js'
+import { mapGetters } from 'vuex'
 import {
   projectList,
   memberQueryMemberInfoByIDAPorName,
@@ -383,31 +385,18 @@ export default {
       ]
     }
   },
+  computed: {
+    ...mapGetters(['bizId'])
+  },
+  watch: {
+    bizId() {
+      this.get_projectList()
+    }
+  },
   created() {
     this.get_projectList()
     this.$store.state.data.status = true
   },
-  // beforeRouteLeave(to, from, next) {
-  //   this.$nextTick(() => {
-  //     if (this.form.name !== '') {
-  //     // 这里需要elementui的支持,如果使用其他界面组件自行替换即可
-  //       this.$confirm('正在离开本页面,本页面内所有未保存数据都会丢失', '警告', {
-  //         confirmButtonText: '确定',
-  //         cancelButtonText: '取消',
-  //         type: 'warning'
-  //       }).then(() => {
-  //         // 正常跳转
-  //         next(true)
-  //       }).catch(() => {
-  //         // 如果取消跳转地址栏会变化,这时保持地址栏不变
-  //         window.history.go(1)
-  //       })
-  //     }
-  //   })
-  //   next(false)
-
-  //   this.$store.state.data.status = false
-  // },
   destroyed() {
     this.$store.state.data.status = false
   },
@@ -421,9 +410,10 @@ export default {
       return item.idap
     },
     get_projectList() {
+      if (this.bizId === -1) return
       // 获取list
       this.table_loading = true
-      projectList({ bizId: Number(localStorage.getItem('bizId')), curIndex: 1, pageSize: 15 }).then(res => {
+      projectList({ bizId: this.bizId, curIndex: 1, pageSize: 15 }).then(res => {
         this.table_project = res.data
         this.total = res.total
         this.table_loading = false
@@ -450,11 +440,12 @@ export default {
       this.options = []
     },
     link_project(id) {
+      const bizId_id = EncryptId(`${this.bizId}_${id}`)
       if (this.newTabOpen) {
-        const newTab = this.$router.resolve({ name: '项目详情', query: { id: id }})
+        const newTab = this.$router.resolve({ name: '项目详情', query: { bizId_id: bizId_id }})
         window.open(newTab.href, '_blank')
       } else {
-        this.$router.push({ name: '项目详情', query: { id: id }})
+        this.$router.push({ name: '项目详情', query: { bizId_id: bizId_id }})
       }
     },
     showSelect() {
@@ -467,7 +458,7 @@ export default {
       this.$nextTick(() => {
         this.$refs['form'].clearValidate()
       })
-      this.$set(this.form, 'bizId', Number(localStorage.getItem('bizId')))
+      this.$set(this.form, 'bizId', this.bizId)
     },
     created_project(e) {
       // 创建(提交)
@@ -496,7 +487,7 @@ export default {
       this.table_loading = true
       this.query_object = {}
       this.query_object = e
-      this.query_object.bizId = Number(localStorage.getItem('bizId'))
+      this.query_object.bizId = this.bizId
       this.query_object.curIndex = this.curIndex
       this.query_object.pageSize = this.pageSize
       projectList(this.query_object).then(res => {

+ 18 - 14
src/views/projectManage/projectList/projectViewDetails.vue

@@ -139,7 +139,7 @@
       <!-- 缺陷 -->
       <el-container v-if="activeName === '4'" class="is-vertical">
         <section class="main-section contain">
-          <bugTableDialog ref="bugTableDialog" :obj-id="{ projectId: Number(this.$route.query.id) }" />
+          <bugTableDialog ref="bugTableDialog" :obj-id="{ projectId: projectId }" />
         </section>
       </el-container>
       <!-- 缺陷 -->
@@ -183,7 +183,7 @@
         @childValInput="childVal"
         @click.stop
       />
-      <modify-project :show.sync="modify_project" @change="get_list" />
+      <modify-project v-if="modify_project" :show.sync="modify_project" @change="get_list" />
     </el-container></div>
 </template>
 <script>
@@ -191,6 +191,8 @@ const _ = require('lodash')
 import Vue from 'vue'
 import VueClipboard from 'vue-clipboard2'
 Vue.use(VueClipboard)
+import { mapGetters } from 'vuex'
+import { analysisBizId_id } from '@/utils/crypto-js.js'
 import {
   projectList,
   projectUpdate,
@@ -205,7 +207,6 @@ import tasksList from './components/taskList'
 import needsList from './components/needsList'
 import modifyProject from './components/modifyProject'
 import openDialog from '@/views/projectManage/dialog_vue'
-import Utils from '../../../util.js'
 import RequirementCreate from '@/views/projectManage/requirement/list/create'
 import createdBug from '@/views/projectManage/bugList/file/createdBug'
 import '@/views/projectManage/projectList/css/index.css'
@@ -239,6 +240,7 @@ export default {
   },
   data() {
     return {
+      projectId: -1, // 项目id
       activeName: '1', // 顶部tab切换
       num: '',
       image_url: image_url,
@@ -266,7 +268,6 @@ export default {
       userInformation: localStorage.getItem('username'),
       userNames: localStorage.getItem('realname'),
       textarea: '', // 项目总目标
-      projectId: Number(this.$route.query.id), // 项目id
       form_query: {},
       modify_project: false,
       deleteVisible: false, // 删除项目弹框
@@ -275,12 +276,15 @@ export default {
       requirement: {}
     }
   },
+  computed: {
+    ...mapGetters(['bizId'])
+  },
   watch: {
     activeName: {
       handler(newV) {
         Number(newV) > 0
-          ? this.$router.push({ path: this.$route.path, query: { id: this.$route.query.id, page: newV }})
-          : this.$router.push({ path: this.$route.path, query: { id: this.$route.query.id, page: '1' }})
+          ? this.$router.push({ path: this.$route.path, query: { ...this.$route.query, page: newV }})
+          : this.$router.push({ path: this.$route.path, query: { ...this.$route.query, page: '1' }})
       }
     }
   },
@@ -288,16 +292,20 @@ export default {
     this.$nextTick(() => {
       this.activeName = this.$route.query.page ? this.$route.query.page : '1'
     })
-    this.get_list()
+    this.analysisBizId_id()
     this.initRequirementCreateDialog()
     this.$store.state.data.status = true
-    // this.$store.state.data.bizId = true
   },
   destroyed() {
     this.$store.state.data.status = false
-    // this.$store.state.data.bizId = false
   },
   methods: {
+    analysisBizId_id() { // 解析路由中的bizId_id
+      if (!this.$route.query.bizId_id) return
+      const bizId_id = analysisBizId_id(this.$route.query.bizId_id)
+      this.projectId = bizId_id[1]
+      this.get_list()
+    },
     async changeArea(e) { // area修改
       const projectInfo = _.cloneDeep(this.form_query)
       const res = await projectUpdate({ projectInfo, user: this.user })
@@ -310,7 +318,7 @@ export default {
     },
     initRequirementCreateDialog() { // 初始化新建需求弹框
       this.requirement.belongingProject = this.projectId // 这里传入项目id
-      this.requirement.bizId = localStorage.getItem('bizId') // 这里传入业务线id
+      this.requirement.bizId = this.bizId // 这里传入业务线id
       this.requirement.dependOnRelease = 0 // 这里传入是否依赖发版
     },
     closeDioang() { // 关闭新建需求弹框
@@ -322,16 +330,12 @@ export default {
     async get_list() {
       // 获取项目ID(查询)
       this.user = { name: this.userNames, ename: this.userInformation, id: '' }
-      this.projectId = this.$route.query.id
       this.get_project_detail()
       this.get_project_Milepost()
     },
     async get_project_detail() { // 获取项目详情
       const res = await projectList({ id: this.projectId })
       if (res.code === 200) {
-        if (res.data[0].bizId !== Number(localStorage.getItem('bizId'))) {
-          Utils.$emit('demo', res.data[0].bizId)
-        }
         this.form_query = res.data[0]
         this.project_from = res.data[0]
         this.form_query.status === 0 ? this.$set(this.form_query, 'statusString', '未开始') : ''

+ 1 - 1
src/views/workbench/components/listView.vue

@@ -170,7 +170,7 @@ export default {
   },
   props: {
     type: { type: String, required: true },
-    biz: { type: String, default: null }
+    biz: { type: Number, default: null }
   },
   data() {
     return {

+ 3 - 5
src/views/workbench/person/index.vue

@@ -368,16 +368,14 @@ export default {
     }
   },
   computed: {
-    ...mapGetters([
-      'bizId'
-    ])
+    ...mapGetters(['bizId'])
   },
   watch: {
     activeName: {
       handler(newV) {
         Number(newV) > 0
-          ? this.$router.push({ path: this.$route.path, query: { page: newV }})
-          : this.$router.push({ path: this.$route.path, query: { page: '1' }})
+          ? this.$router.push({ path: this.$route.path, query: { ...this.$route.query, page: newV }})
+          : this.$router.push({ path: this.$route.path, query: { ...this.$route.query, page: '1' }})
       }
     }
   },

+ 1 - 1
src/views/workbench/team/components/needsList.vue

@@ -166,7 +166,7 @@ export default {
       this.getNeedsList()
     },
     async getTaskStatus() { // 获取需求的所有状态
-      const res1 = await configShowRequireStatusEnum(localStorage.getItem('bizId'))
+      const res1 = await configShowRequireStatusEnum(this.$store.state.data.bizId)
       if (res1.code === 200) {
         this.allStatus = []
         this.allStatus = res1.data.requirementStatus

+ 10 - 7
src/views/workbench/team/components/projectList.vue

@@ -71,10 +71,9 @@
   </div>
 </template>
 <script>
-import {
-  projectSelfList,
-  projectTeamList
-} from '@/api/workSchedule'
+import { mapGetters } from 'vuex'
+import { EncryptId } from '@/utils/crypto-js.js'
+import { projectSelfList, projectTeamList } from '@/api/workSchedule'
 import { projectUpdate } from '@/api/projectIndex'
 export default {
   props: {
@@ -111,6 +110,9 @@ export default {
       status: null // 列表状态
     }
   },
+  computed: {
+    ...mapGetters(['bizId'])
+  },
   watch: {
     searchForm: {
       handler(newV) {
@@ -141,7 +143,7 @@ export default {
       this.pages.curIndex = val
       this.getProjectList()
     },
-    async getProjectList() { // 获取需求列表
+    async getProjectList() { // 获取项目列表
       const params = {
         teamSearchInfo: this.searchForm,
         status: this.status,
@@ -172,11 +174,12 @@ export default {
       }
     },
     project_link(id) {
+      const bizId_id = EncryptId(`${this.bizId}_${id}`)
       if (this.newTabOpen) {
-        const newTab = this.$router.resolve({ name: '项目详情', query: { id: id }})
+        const newTab = this.$router.resolve({ name: '项目详情', query: { bizId_id: bizId_id }})
         window.open(newTab.href, '_blank')
       } else {
-        this.$router.push({ name: '项目详情', query: { id: id }})
+        this.$router.push({ name: '项目详情', query: { bizId_id: bizId_id }})
       }
     }
   }

+ 1 - 1
src/views/workbench/team/components/taskList.vue

@@ -236,7 +236,7 @@ export default {
       if (res.code === 200) {
         this.taskScheduleEvent = res.data.taskScheduleEvent || []
       }
-      const res1 = await configShowTaskStatusEnum(localStorage.getItem('bizId'))
+      const res1 = await configShowTaskStatusEnum(this.$store.state.data.bizId)
       if (res1.code === 200) {
         this.allStatus = res1.data.taskStatus
       }

+ 2 - 2
src/views/workbench/team/index.vue

@@ -335,8 +335,8 @@ export default {
     activeName: {
       handler(newV) {
         Number(newV) > 0
-          ? this.$router.push({ path: this.$route.path, query: { page: newV }})
-          : this.$router.push({ path: this.$route.path, query: { page: '1' }})
+          ? this.$router.push({ path: this.$route.path, query: { ...this.$route.query, page: newV }})
+          : this.$router.push({ path: this.$route.path, query: { ...this.$route.query, page: '1' }})
       }
     }
   },