浏览代码

业务线选择页面

wangziqian 4 年之前
父节点
当前提交
deb8c314be

+ 28 - 39
src/layout/components/Navbar.vue

@@ -3,26 +3,9 @@
     <div class="bizIdSet">
       <!-- <hamburger :is-active="sidebar.opened" class="hamburger-container" @toggleClick="toggleSideBar" /> -->
       <!-- <breadcrumb class="breadcrumb-container" /> -->
-      <el-dropdown v-show="status" placement="bottom" trigger="click" @command="sumTypeCkeck">
-        <el-button :disabled="showBizId" type="primary">
-          {{ sumType }}<i class="el-icon-arrow-down el-icon--right" />
-        </el-button>
-        <el-dropdown-menu slot="dropdown">
-          <div style="margin: 0 10% 10px;">
-            <el-input v-model="value" clearable size="small" style="width: 100%" placeholder="业务线搜索" @input="remoteMethod" />
-          </div>
-          <div style="max-height: 200px; overflow:scroll; overflow-x: hidden">
-            <el-dropdown-item
-              v-for="(item,index) in sumTypeArray"
-              :key="index"
-              :label="item.name"
-              :value="item.code"
-              :command="item"
-              v-text="item.name"
-            />
-          </div>
-        </el-dropdown-menu>
-      </el-dropdown>
+      <el-button v-show="status" :disabled="showBizId" type="primary" @click="changeBizId">
+        {{ sumType }}
+      </el-button>
     </div>
     <div>
       <div class="right-menu" style="display: fiex; align-items: center; justify-content: space-between;">
@@ -82,12 +65,17 @@ export default {
   watch: {
     $route: {
       async handler(to, from) {
-        if (from && to.path === from.path) return // 如果与原路由相同,return
-        if (this.sumTypeArray.length < 1) await this.settingGetBizList() // 如果业务线列表不存在,请求获取路由业务线列表
+        // 如果是业务线选择页面,不作处理
+        if (to.name === '业务线选择') return
+        // 如果与原路由相同,不作处理
+        if (from && to.path === from.path) return
+        // 如果业务线列表不存在,请求获取路由业务线列表
+        if (this.sumTypeArray.length < 1) await this.settingGetBizList()
+        // 如果参数中bizId和bizId_id都不存在,去获取默认bizId
         if (!to.query.bizId && !to.query.bizId_id) {
           this.settingUserGetBiz()
           return
-        }// 如果参数中bizId和bizId_id都不存在,去获取默认bizId
+        }
         const existBizId_id = needIdList.find(item => item === to.name)
         existBizId_id ? this.handlerIdAndBizId() : this.handlerBizId()
       },
@@ -134,7 +122,7 @@ export default {
         localStorage.setItem('bizId', nowBiz.code)
         const existBizId_id = needIdList.find(item => item === this.$route.name)
         if (!existBizId_id) { // 如果不是在需要bizId_id的详情页,就去给路由添加bizId
-          this.$router.push({
+          this.$router.replace({
             path: this.$route.path,
             query: { ...this.$route.query, bizId: EncryptId(nowBiz.code) }
           })
@@ -151,21 +139,22 @@ export default {
         this.get_bizArr()
       }
     },
-    sumTypeCkeck(type) { // 下拉列表的点击事件x
-      this.sumType = type.name
-      this.$store.dispatch('data/setBizId', type.code)
-      this.settingUserSetBiz(type.code)
-      const name = this.$route.name
-      const isDetailPage = needIdList.find(item => item === name)
-      if (isDetailPage) {
-        this.$router.push({ name: name.substr(0, 2), query: { bizId: EncryptId(type.code) }})
-      } else {
-        this.$router.push({
-          path: this.$route.path,
-          query: { ...this.$route.query, bizId: EncryptId(type.code) }
-        })// 更新路由连接
-        this.$nextTick(() => { this.$router.go(0) }) // 重载页面
-      }
+    changeBizId(type) { // 下拉列表的点击事件x
+      this.$router.push({ name: '业务线选择' })
+      // this.sumType = type.name
+      // this.$store.dispatch('data/setBizId', type.code)
+      // this.settingUserSetBiz(type.code)
+      // const name = this.$route.name
+      // const isDetailPage = needIdList.find(item => item === name)
+      // if (isDetailPage) {
+      //   this.$router.push({ name: name.substr(0, 2), query: { bizId: EncryptId(type.code) }})
+      // } else {
+      //   this.$router.push({
+      //     path: this.$route.path,
+      //     query: { ...this.$route.query, bizId: EncryptId(type.code) }
+      //   })// 更新路由连接
+      //   this.$nextTick(() => { this.$router.go(0) }) // 重载页面
+      // }
     },
     async settingUserSetBiz(bizId) { // 设置成员登录业务线
       await settingUserSetBiz({ bizId: bizId })

+ 7 - 3
src/router/index.js

@@ -39,19 +39,16 @@ export const constantRoutes = [{
   component: (resolve) => require(['@/views/login/index'], resolve),
   hidden: true
 },
-
 {
   path: '/404',
   component: (resolve) => require(['@/views/404'], resolve),
   hidden: true
 },
-
 {
   path: '/',
   component: Home,
   hidden: true
 },
-
 {
   path: '/home',
   component: Home,
@@ -89,6 +86,13 @@ export const constantRoutes = [{
   redirect: '/Platform/projectManage/projectList/projectIndex',
   meta: { title: '项目管理', icon: '项目管理' },
   children: [{
+    path: 'bizIdSelect',
+    name: '业务线选择',
+    hidden: true,
+    component: () => import('@/views/business/bizIdSelect.vue'),
+    meta: { title: '业务线选择' }
+  },
+  {
     path: 'projectIndex',
     name: '项目',
     component: (resolve) => require(['@/views/projectManage/projectList/projectIndex'], resolve),

+ 63 - 0
src/views/business/bizIdSelect.vue

@@ -0,0 +1,63 @@
+<template>
+  <section class="business-contain">
+    <div class="bizId-select">
+      <div class="user-name">{{ username }},欢迎您!</div>
+      <div class="user-tips">请选择您的业务线</div>
+      <div class="bizId-table">
+        <div class="table-item">
+          <span class="item-name" />
+          <span class="item-button" />
+        </div>
+      </div>
+    </div>
+  </section>
+</template>
+<script>
+import { mapGetters } from 'vuex'
+import { needIdList } from '@/router/needIdList'
+import { EncryptId, desDecryptId } from '@/utils/crypto-js.js'
+import { settingGetBizList } from '@/api/projectIndex'
+let fromRoute = null
+export default {
+  data() {
+    return {
+      bizSelectList: [] // 业务线选择列表
+    }
+  },
+  computed: {
+    ...mapGetters([
+      'bizId'
+    ]),
+    username() {
+      return localStorage.getItem('realname')
+    }
+  },
+  beforeRouteEnter(to, from, next) {
+    fromRoute = from.path
+    next()
+  },
+  created() {
+    console.log('上一个路由地址', fromRoute)
+    this.settingGetBizList()
+  },
+  methods: {
+    async settingGetBizList() {
+      const res = await settingGetBizList({})
+      if (res.code === 200) this.bizSelectList = res.data || []
+    }
+  }
+}
+</script>
+<style lang="scss" scoped>
+.bizId-select{
+  height: 100vh;
+  width: 100%;
+  background-color:#F2F3F6;
+}
+.user-name {
+
+}
+.user-tips {
+
+}
+</style>

+ 27 - 12
src/views/projectManage/requirement/list/index.vue

@@ -199,6 +199,8 @@
 </template>
 
 <script>
+import { EncryptId } from '@/utils/crypto-js.js'
+import { mapGetters } from 'vuex'
 import {
   getRequirement,
   showRequirementEnum,
@@ -274,6 +276,14 @@ export default {
       data: ''
     }
   },
+  computed: {
+    ...mapGetters(['bizId'])
+  },
+  watch: {
+    bizId() {
+      this.getTableData()
+    }
+  },
   created() {
     this.$store.state.data.status = true
     this.showRequirementEnum()
@@ -285,6 +295,7 @@ export default {
   },
   methods: {
     getTableData() { // 查询
+      if (this.bizId === -1) return
       for (const key in this.searchForm) { // 接口不接受空值的处理
         if (this.searchForm[key] === '' || this.searchForm[key] === null) {
           delete this.searchForm[key]
@@ -295,16 +306,13 @@ export default {
       } else {
         this.searchForm.name = ''
       }
-      this.searchForm.bizId = Number(localStorage.getItem('bizId'))
+      this.searchForm.bizId = this.bizId
       this.loading = true
 
       this.searchForm.pageSize = this.pageSize
       this.searchForm.curIndex = this.curIndex
 
-      let data = {}
-      data = this.searchForm
-      // data.rqmtProposer = this.searchForm.rqmtProposer.join()
-      getRequirement(data).then(res => {
+      getRequirement(this.searchForm).then(res => {
         this.tableData = res.data.list
         this.total = res.data.total
         this.loading = false
@@ -315,15 +323,15 @@ export default {
       if (res.code === 200) {
         this.searchInfo = res.data
       }
-      const res1 = await projectListProject({ bizId: Number(localStorage.getItem('bizId')) })
+      const res1 = await projectListProject({ bizId: this.bizId })
       if (res1.code === 200) {
         this.AttributionItems = res1.data
       }
-      const res2 = await configShowRequireStatusEnum(localStorage.getItem('bizId'))
+      const res2 = await configShowRequireStatusEnum(this.bizId)
       if (res2.code === 200) {
         this.requiredStatus = res2.data.requirementStatus
       }
-      const res3 = await settingQueryBizRqmtOrntList(localStorage.getItem('bizId'))
+      const res3 = await settingQueryBizRqmtOrntList(this.bizId)
       if (res3.code === 200) { // 需求方向
         this.demandDirection = this.getTreeData(res3.data)
       }
@@ -382,7 +390,13 @@ export default {
       const saveObj = deepClone(this.searchForm)
       delete saveObj.curIndex
       delete saveObj.pageSize
-      const res = await filterCreateFilter({ name: this.FilterItems.name, content: JSON.stringify(saveObj), bizId: Number(localStorage.getItem('bizId')), filterType: 3, creator: localStorage.getItem('username') })
+      const res = await filterCreateFilter({
+        name: this.FilterItems.name,
+        content: JSON.stringify(saveObj),
+        bizId: this.bizId,
+        filterType: 3,
+        creator: localStorage.getItem('username')
+      })
       if (res.code === 200) {
         this.$message({ showClose: true, message: '保存成功', type: 'success' })
         this.showSaveSearch = false
@@ -392,7 +406,7 @@ export default {
     },
     async getFilterList() { // 获取过滤器列表
       const params = {
-        bizId: Number(localStorage.getItem('bizId')),
+        bizId: this.bizId,
         filterType: 3
       }
       const res = await filtergetFilterList(params)
@@ -454,11 +468,12 @@ export default {
       this.getTableData()
     },
     getToRequirementDetails(id) { // table点击跳转
+      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 }})
       }
     }
   }