Navbar.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. <template>
  2. <div class="navbar">
  3. <div class="sys-name">
  4. <span>运矿管理系统</span>
  5. <hamburger v-if="!hideMenuBt" id="hamburger-container" :is-active="sidebar.opened" class="hamburger-container" @toggleClick="toggleSideBar" />
  6. </div>
  7. <!-- 隐藏标签 -->
  8. <breadcrumb v-if="0" id="breadcrumb-container" class="breadcrumb-container" />
  9. <div class="right-menu">
  10. <template v-if="device!=='mobile'">
  11. <search v-if="false" id="header-search" class="right-menu-item" />
  12. <error-log class="errLog-container right-menu-item hover-effect" />
  13. <screenfull v-if="false" id="screenfull" class="right-menu-item hover-effect" />
  14. <el-tooltip v-if="false" content="Global Size" effect="dark" placement="bottom">
  15. <size-select id="size-select" class="right-menu-item hover-effect" />
  16. </el-tooltip>
  17. </template>
  18. <div class="sideMenuTab">
  19. <div
  20. v-for="(tab,index) in sideMenuTabList"
  21. :key="'sideMenuTab'+index"
  22. class="item"
  23. :class="sideMenuTabIndex===tab.id?'active-'+sideMenuTabIndex:''"
  24. @click="sideTabChange(tab.id,tab)"
  25. >
  26. <template v-if="sideMenuTabIndex===tab.id">
  27. <img :src="tab.iconSelectEd" :alt="tab.name">
  28. </template>
  29. <template v-else>
  30. <img :src="tab.icon" :alt="tab.name">
  31. </template>
  32. <p>{{ tab.name }}</p>
  33. </div>
  34. </div>
  35. <!-- <div class="right-menu-item" @click="navToPage('/message')">
  36. <el-badge :is-dot="false" class="nav-icon">
  37. <img class="icon" src="@/assets/images/Navbar/notice.png" alt="">
  38. <span class="name">预警信息</span>
  39. </el-badge>
  40. </div> -->
  41. <el-dropdown class="avatar-container right-menu-item hover-effect" trigger="click">
  42. <div class="avatar-wrapper">
  43. <img class="icon" src="@/assets/images/Navbar/user.png" alt="">
  44. <span class="name">{{ userData&&userData.userName||'--' }}</span>
  45. <i class="el-icon-caret-bottom" />
  46. </div>
  47. <el-dropdown-menu slot="dropdown">
  48. <router-link to="/profile/index">
  49. <el-dropdown-item>
  50. 个人中心
  51. </el-dropdown-item>
  52. </router-link>
  53. <el-dropdown-item divided @click.native="logout">
  54. <span style="display:block;">退出登录</span>
  55. </el-dropdown-item>
  56. </el-dropdown-menu>
  57. </el-dropdown>
  58. </div>
  59. </div>
  60. </template>
  61. <script>
  62. import { mapGetters } from 'vuex'
  63. import { Breadcrumb, Hamburger, ErrorLog, Screenfull, SizeSelect, Search } from '@/components'
  64. import { getUnReadCounter } from '@/api/system/msgApi'
  65. export default {
  66. name: 'NaveBarComponent',
  67. components: {
  68. Breadcrumb,
  69. Hamburger,
  70. ErrorLog,
  71. Screenfull,
  72. SizeSelect,
  73. Search
  74. },
  75. data() {
  76. return {
  77. logo: require('@/assets/images/logo/logo.png'),
  78. sideMenuTabIndex: 1,
  79. sideMenuTabList: [
  80. { name: '系统管理', icon: require('@/assets/images/Navbar/sys.png'), iconSelectEd: require('@/assets/images/Navbar/sys_selected.png'), path: '/aqpt/setting/camera', permit: 'aqpt_system', id: 1 },
  81. { name: '大屏', icon: require('@/assets/images/Navbar/bigscreen.png'), iconSelectEd: require('@/assets/images/Navbar/bigscreen_selected.png'), path: '/bigScreen/index', permit: 'aqpt_panorama', id: 2 }
  82. ]
  83. }
  84. },
  85. computed: {
  86. ...mapGetters([
  87. 'device',
  88. 'sidebar',
  89. 'avatar',
  90. 'userData',
  91. 'permission_routes',
  92. 'menuSiderTab',
  93. 'permits'
  94. ]),
  95. hideMenuBt() {
  96. return this.permission_routes.filter(item => !item.hidden).length < 1
  97. }
  98. },
  99. watch: {
  100. menuSideTab(val) {
  101. const item = this.sideMenuTabList[val]
  102. this.sideTabChange(val, item)
  103. }
  104. },
  105. mounted() {
  106. this.getUnReadMsg()
  107. this.initSideMenu()
  108. this.initsideTab()
  109. },
  110. methods: {
  111. getUnReadMsg() {
  112. getUnReadCounter().then((resp) => {
  113. this.unReadCount = resp.data
  114. })
  115. },
  116. initSideMenu() {
  117. const permits = JSON.parse(JSON.stringify(this.permits))
  118. let sideMenuTabList = JSON.parse(JSON.stringify(this.sideMenuTabList))
  119. sideMenuTabList = sideMenuTabList.filter(item => permits.includes(item.permit))
  120. this.sideMenuTabList = sideMenuTabList
  121. },
  122. initsideTab() {
  123. this.sideTabChange(1, this.sideMenuTabList[0])
  124. },
  125. toggleSideBar() {
  126. this.$store.dispatch('app/toggleSideBar')
  127. },
  128. navToPage(path) {
  129. this.$emit('initMessage')
  130. },
  131. async logout() {
  132. localStorage.clear() // 垃圾数据清除
  133. await this.$store.dispatch('user/logout')
  134. this.$router.push(`/login?redirect=${this.$route.fullPath}`)
  135. },
  136. sideTabChange(index, item) {
  137. // const token = getToken()
  138. // if (item.href) {
  139. // const bigscreen = process.env.NODE_ENV === 'development' ? 'http://192.168.3.16:1890/#/' : 'http://113.141.93.143:1689/#/'
  140. // window.open(`${bigscreen}?token=${token}`)
  141. // return
  142. // }
  143. this.sideMenuTabIndex = index
  144. this.$router.push({
  145. path: item.path
  146. })
  147. localStorage.setItem('tabIndex', index)
  148. var permission_routes = localStorage.getItem('permission_routes')
  149. if (permission_routes) { permission_routes = JSON.parse(permission_routes) } else {
  150. permission_routes = this.permission_routes
  151. localStorage.setItem('permission_routes', JSON.stringify(permission_routes))
  152. }
  153. // 获取权限路由,根据groupId进行过滤
  154. const filterRoutes = permission_routes.filter((item) => {
  155. if (item.groupId) {
  156. return item.groupId.includes(index)
  157. }
  158. return item
  159. })
  160. this.$store.state.permission.routes = filterRoutes
  161. },
  162. isNotNull(value) {
  163. if (value !== undefined && value !== 'undefined' && value !== null && value !== '') return true
  164. return false
  165. }
  166. }
  167. }
  168. </script>
  169. <style lang="scss" scoped>
  170. .navbar {
  171. height: var(--navHeight);
  172. overflow: hidden;
  173. background: unset;
  174. box-shadow: 0 1px 4px rgba(0, 21, 41, .08);
  175. border-bottom: 1px solid #457486;
  176. position: fixed;
  177. width: 100%;
  178. z-index: 999;
  179. left: 0;
  180. box-sizing: border-box;
  181. background-color: var(--menuBg, #113144);
  182. top: 0;
  183. .sys-name{
  184. height: 100%;
  185. display: flex;
  186. align-items: center;
  187. float: left;
  188. padding-left: 10px;
  189. color: #fff;
  190. flex: 1;
  191. #nav-logo{
  192. display: block;
  193. width: 200px;
  194. height: 32px;
  195. }
  196. .tag{
  197. font-size: 18px;
  198. line-height: 18px;
  199. font-weight: 300;
  200. padding-left: 10px;
  201. margin-top: 10px;
  202. }
  203. }
  204. .hamburger-container {
  205. padding: 3px 6px;
  206. margin-left: 10px;
  207. line-height: var(--navHeight);
  208. height: 100%;
  209. font-size: 16px;
  210. float: left;
  211. color: rgb(219, 204, 204) !important;
  212. cursor: pointer;
  213. transition: background .3s;
  214. -webkit-tap-highlight-color:transparent;
  215. &:hover {
  216. background: rgba(0, 0, 0, .025)
  217. }
  218. }
  219. .breadcrumb-container {
  220. float: left;
  221. }
  222. .errLog-container {
  223. display: inline-block;
  224. vertical-align: top;
  225. }
  226. .right-menu {
  227. float: right;
  228. height: 100%;
  229. line-height: var(--navHeight);
  230. display: flex;
  231. justify-content: flex-start;
  232. align-items: center;
  233. &:focus {
  234. outline: none;
  235. }
  236. .right-menu-item {
  237. display: inline-block;
  238. height: 100%;
  239. font-size: 18px;
  240. color: #fff;
  241. vertical-align: text-bottom;
  242. &.hover-effect {
  243. cursor: pointer;
  244. transition: background .3s;
  245. &:hover {
  246. background: rgba(0, 0, 0, .025)
  247. }
  248. }
  249. }
  250. .avatar-container {
  251. margin-right: 30px;
  252. .avatar-wrapper {
  253. position: relative;
  254. .user-avatar {
  255. cursor: pointer;
  256. width: 40px;
  257. height: 40px;
  258. border-radius: 10px;
  259. }
  260. .el-icon-caret-bottom {
  261. cursor: pointer;
  262. position: absolute;
  263. right: -20px;
  264. top: 25px;
  265. font-size: 14px;
  266. }
  267. }
  268. }
  269. .sideMenuTab{
  270. height: 100%;
  271. display: flex;
  272. justify-content: flex-start;
  273. padding-right: 20px;
  274. .item{
  275. height: 100%;
  276. display: flex;
  277. justify-content: center;
  278. align-items: center;
  279. flex-direction: column;
  280. color: #fff;
  281. line-height: 1;
  282. padding: 0 15px;
  283. cursor: pointer;
  284. transition: 0.2s;
  285. &.active-0{color: #1890ff;font-weight: 600;}
  286. &.active-1{color: #b97741;font-weight: 600;}
  287. &.active-2{color: #97cd38;font-weight: 600;}
  288. &.active-3 {color: #dc5a2c;font-weight: 600;}
  289. &.active-4{color: #414ab9;font-weight: 600;}
  290. &.active-5{color: #c13ac9;font-weight: 600;}
  291. &.active-6{color: #29c761;font-weight: 600;}
  292. &.active-7 {color: #c7795c;font-weight: 600;}
  293. &.active-8{color: #bd966f;font-weight: 600;}
  294. &.active-9{color: #832188;font-weight: 600;}
  295. &.active-10{color: #66db8f;font-weight: 600;}
  296. img{
  297. display: block;
  298. width: 28px;
  299. }
  300. .iconfont{
  301. color: inherit;
  302. }
  303. .iconfont{
  304. font-size: 36px;
  305. &.el-icon-s-platform{
  306. font-family: "element-icons" !important;
  307. }
  308. &.icon-common_health{
  309. font-size: 28px;
  310. }
  311. }
  312. p{
  313. padding-top: 3px;
  314. margin: 2px 0px;
  315. font-size: 14px;
  316. color: #fff;
  317. }
  318. &[class*="active-"]{
  319. p{
  320. color: #1890FF;
  321. }
  322. }
  323. }
  324. }
  325. }
  326. .nav-icon,.avatar-wrapper{
  327. display: flex;
  328. align-items: center;
  329. .iocn{
  330. display: block;
  331. width: 24px;
  332. }
  333. .name{
  334. color:rgba(255, 255, 255, 0.76);
  335. font-size:14px;
  336. margin-left:5px;
  337. }
  338. }
  339. }
  340. </style>