123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269 |
- <template>
- <div class="navbar">
- <div class="bizIdSet">
- <!-- <hamburger :is-active="sidebar.opened" class="hamburger-container" @toggleClick="toggleSideBar" /> -->
- <!-- <breadcrumb class="breadcrumb-container" /> -->
- <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;">
- <el-avatar style="vertical-align: middle; background: #FFF;" size="small"><img :src="options.phoneUrl"></el-avatar>
- <el-dropdown placement="bottom" trigger="click" @visible-change="visibleChange">
- <span class="el-dropdown-link avatar-container" style="color: #FFFFFF; cursor: pointer;" @click="show2 = !show2">
- {{ username }}
- <i class="el-icon-arrow-right" :class="{rotateNone:show2,rotate:!show2}" />
- </span>
- <el-dropdown-menu slot="dropdown">
- <el-dropdown-item @click.native="Logout">退出</el-dropdown-item>
- </el-dropdown-menu>
- </el-dropdown>
- </div>
- </div>
- </div>
- </template>
- <script>
- import { mapGetters } from 'vuex'
- import { needIdList } from '@/router/needIdList'
- import { EncryptId, desDecryptId, analysisBizId_id } from '@/utils/crypto-js.js'
- // import Breadcrumb from '@/components/Breadcrumb' // 面包屑
- // import Hamburger from '@/components/Hamburger' // 导航开关
- import { logoutUrl } from '@/apiConfig/requestIP.js'
- import { memberGetLoginInMemberInfoByLdap, settingGetBizList, settingUserGetBiz } from '@/api/projectIndex'
- export default {
- // components: {
- // Breadcrumb
- // Hamburger
- // },
- data() {
- return {
- show2: false,
- options: {},
- value: '',
- arr_data: [],
- sumTypeArray: [],
- formulaArea: '', // 公式的文本框
- typeObj: {},
- showBizId: false
- }
- },
- computed: {
- ...mapGetters([
- 'sidebar',
- 'avatar',
- 'status',
- 'bizId'
- ]),
- username() {
- return localStorage.getItem('realname')
- },
- sumType() {
- const nowBiz = this.sumTypeArray.find(item => item.code === this.bizId)
- if (nowBiz) return nowBiz.name
- return ''
- }
- },
- watch: {
- $route: {
- async handler(to, from) {
- // 如果是业务线选择页面,不作处理
- if (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)
- 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()
- },
- immediate: true
- }
- },
- created() {
- this.getLoginMember()
- },
- methods: {
- handlerBizId() { // 只处理bizId
- const bizId = Number(desDecryptId(this.$route.query.bizId))
- const isExistBizId = this.sumTypeArray.find(item => bizId === item.code)// 业务线id是否存在
- if (isExistBizId) {
- this.$store.dispatch('data/setBizId', bizId)
- } else {
- this.settingUserGetBiz()
- }
- console.log('mainbizId', this.bizId)
- },
- handlerIdAndBizId() { // 处理bizId和id
- const arr = analysisBizId_id(this.$route.query.bizId_id)
- const isExistBizId = this.sumTypeArray.find(item => Number(arr[0]) === item.code)// 业务线id是否存在
- if (isExistBizId) {
- this.$store.dispatch('data/setBizId', Number(arr[0]))
- } else {
- this.settingUserGetBiz()
- }
- console.log('mainbizId', this.bizId)
- },
- 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.$store.dispatch('data/setBizId', nowBiz.code)
- localStorage.setItem('bizId', nowBiz.code)
- const existBizId_id = needIdList.find(item => item === this.$route.name)
- // 如果不是在需要bizId_id的详情页,就去给路由添加bizId
- existBizId_id
- ? ''
- : this.$router.replace({
- path: this.$route.path,
- query: { ...this.$route.query, bizId: EncryptId(nowBiz.code) }
- })
- } else {
- this.$router.push({ name: '业务线选择' })
- }
- },
- async remoteMethod(query) {
- if (query !== '') {
- const res = await settingGetBizList({ bizName: query })
- this.sumTypeArray = res.data
- } else {
- this.get_bizArr()
- }
- },
- changeBizId(type) { // 更改业务线
- this.$router.push({ name: '业务线选择' })
- },
- async getLoginMember() { // 获取登录人员信息
- const res = await memberGetLoginInMemberInfoByLdap()
- this.options = res.data
- localStorage.setItem('UserAvatar', this.options.phoneUrl)
- },
- visibleChange(e) {
- if (!e) {
- this.show2 = false
- }
- },
- Logout() {
- location.href = logoutUrl
- }
- }
- }
- </script>
- <style lang="stylus">
- .bizIdSet .el-button--primary.is-disabled, .el-button--primary.is-disabled:active, .el-button--primary.is-disabled:focus, .el-button--primary.is-disabled:hover {
- color: #FFF;
- background-color: #409EFF;
- border-color: #409EFF;
- }
- </style>
- <style lang="scss" scoped>
- .navbar .rotateNone {
- transform: rotate(270deg);
- }
- .navbar img {
- margin: 0 auto;
- }
- .navbar .rotate {
- transform: rotate(90deg);
- }
- .navbar {
- display: flex;
- align-items: center;
- justify-content: space-between;
- height: 55px;
- overflow: hidden;
- position: relative;
- background: #409EFF;
- box-shadow: 0 1px 4px rgba(0,21,41,.08);
- .hamburger-container {
- line-height: 46px;
- height: 100%;
- float: left;
- cursor: pointer;
- transition: background .3s;
- -webkit-tap-highlight-color:transparent;
- &:hover {
- background: rgba(0, 0, 0, .025)
- }
- }
- .breadcrumb-container {
- float: left;
- /deep/ .el-breadcrumb__separator {
- color:white !important
- }
- }
- .right-menu {
- &:focus {
- outline: none;
- }
- .right-menu-item {
- // display: inline-block;
- padding: 0 8px;
- height: 100%;
- font-size: 18px;
- color: #c0c8d8;
- vertical-align: text-bottom;
- &.hover-effect {
- cursor: pointer;
- transition: background .3s;
- &:hover {
- background: rgba(0, 0, 0, .025)
- }
- }
- }
- .avatar-container {
- margin-right: 30px;
- .avatar-wrapper {
- position: relative;
- .user-avatar {
- cursor: pointer;
- width: 40px;
- height: 40px;
- border-radius: 10px;
- }
- .el-icon-caret-bottom {
- cursor: pointer;
- position: absolute;
- right: -20px;
- top: 25px;
- font-size: 12px;
- }
- }
- }
- }
- }
- </style>
|