Navbar.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <template>
  2. <div class="navbar">
  3. </div>
  4. </template>
  5. <script>
  6. import { mapGetters } from 'vuex'
  7. import { Breadcrumb, Hamburger, ErrorLog, Screenfull, SizeSelect, Search } from '@/components'
  8. import { getUnReadCounter } from '@/api/system/msgApi'
  9. import { isNotNull } from '@/utils'
  10. export default {
  11. name: 'NaveBarComponent',
  12. data() {
  13. return {
  14. logo: require('@/assets/images/logo/logo3.png'),
  15. }
  16. },
  17. computed: {
  18. ...mapGetters([
  19. 'device',
  20. 'sidebar',
  21. 'avatar',
  22. 'userData',
  23. 'permission_routes',
  24. 'menuSiderTab',
  25. 'permits'
  26. ]),
  27. hideMenuBt() {
  28. return this.permission_routes.filter(item => !item.hidden).length < 1
  29. }
  30. },
  31. watch: {
  32. menuSideTab(val) {
  33. const item = this.sideMenuTabList[val]
  34. this.sideTabChange(val, item)
  35. },
  36. $route() {
  37. localStorage.setItem('sidepath', this.$route.path)
  38. }
  39. },
  40. mounted() {
  41. this.getUnReadMsg()
  42. this.initSideMenu()
  43. this.initSideTab()
  44. },
  45. methods: {
  46. getUnReadMsg() {
  47. getUnReadCounter().then((resp) => {
  48. this.unReadCount = resp.data
  49. })
  50. },
  51. initSideMenu() {
  52. const permits = JSON.parse(JSON.stringify(this.permits))
  53. let sideMenuTabList = JSON.parse(JSON.stringify(this.sideMenuTabList))
  54. sideMenuTabList = sideMenuTabList.filter(item => permits.includes(item.permit))
  55. this.sideMenuTabList = sideMenuTabList
  56. },
  57. initSideTab() {
  58. if (!this.sideMenuTabList[0]) return
  59. let id = this.sideMenuTabList[0].id
  60. if (isNotNull(localStorage.getItem('aqpt_tabId'))) {
  61. id = parseFloat(localStorage.getItem('aqpt_tabId'))
  62. }
  63. if (this.sideMenuTabList.length < 1) return
  64. this.sideTabChange(id, {
  65. path: localStorage.getItem('sidepath') || this.sideMenuTabList.filter(item => item.id === id)[0].path
  66. })
  67. },
  68. toggleSideBar() {
  69. this.$store.dispatch('app/toggleSideBar')
  70. },
  71. navToPage(path) {
  72. this.$emit('initMessage')
  73. },
  74. async logout() {
  75. localStorage.clear() // 垃圾数据清除
  76. await this.$store.dispatch('user/logout')
  77. this.$router.push(`/login?redirect=${this.$route.fullPath}`)
  78. },
  79. sideTabChange(index, item) {
  80. this.sideMenuTabIndex = index
  81. this.$router.replace({
  82. path: item.path
  83. })
  84. localStorage.setItem('aqpt_tabId', index)
  85. let permission_routes = localStorage.getItem('aqpt_permission_routes')
  86. if (permission_routes) { permission_routes = JSON.parse(permission_routes) } else {
  87. permission_routes = this.permission_routes
  88. localStorage.setItem('aqpt_permission_routes', JSON.stringify(permission_routes))
  89. }
  90. // 获取权限路由,根据groupId进行过滤
  91. const filterRoutes = permission_routes.filter((item) => {
  92. if (item.groupId) {
  93. return item.groupId.includes(index)
  94. }
  95. return item
  96. })
  97. this.$store.state.permission.routes = filterRoutes
  98. }
  99. }
  100. }
  101. </script>
  102. <style lang="scss" scoped>
  103. .navbar {
  104. height: var(--navHeight);
  105. // overflow: auto;
  106. background: unset;
  107. box-shadow: 0 1px 4px rgba(0, 21, 41, .08);
  108. border-bottom: 1px solid #457486;
  109. position: fixed;
  110. width: 100%;
  111. z-index: 999;
  112. left: 0;
  113. box-sizing: border-box;
  114. background-color: var(--menuBg, #113144);
  115. top: 0;
  116. display: flex;
  117. .sys-name{
  118. height: 100%;
  119. display: flex;
  120. align-items: center;
  121. float: left;
  122. padding-left: 10px;
  123. color: #fff;
  124. #nav-logo{
  125. display: block;
  126. height: 40px;
  127. }
  128. .breadcrumb-container {
  129. padding-top:10px;
  130. float: left;
  131. }
  132. .oc-name{
  133. font-size: 16px;
  134. line-height: 1;
  135. font-weight: 400;
  136. padding-left: 5px;
  137. margin-top: 8px;
  138. white-space:nowrap;
  139. &.authorization{
  140. font-size: 12px;
  141. margin-top: 15px;
  142. color: #a33e3e;
  143. // color: rgba(255, 255, 255, 0.7);
  144. }
  145. }
  146. .hamburger-container {
  147. padding: 7px;
  148. text-align: center;
  149. line-height: var(--navHeight);
  150. height: 100%;
  151. font-size: 16px;
  152. float: left;
  153. color: rgb(195, 229, 241) !important;
  154. cursor: pointer;
  155. transition: background .3s;
  156. -webkit-tap-highlight-color:transparent;
  157. &:hover {
  158. background: rgba(0, 0, 0, .025)
  159. }
  160. }
  161. }
  162. .errLog-container {
  163. display: inline-block;
  164. vertical-align: top;
  165. }
  166. .center.flex{
  167. flex: 1;
  168. }
  169. .right-menu {
  170. float: right;
  171. // width: calc(100% - 500px);
  172. height: 100%;
  173. line-height: var(--navHeight);
  174. display: flex;
  175. align-items: center;
  176. overflow-x: auto;
  177. overflow-y: hidden;
  178. &:focus {
  179. outline: none;
  180. }
  181. .right-menu-item {
  182. display: inline-block;
  183. padding: 0 8px;
  184. height: 100%;
  185. font-size: 18px;
  186. color: #fff;
  187. vertical-align: text-bottom;
  188. &.hover-effect {
  189. cursor: pointer;
  190. transition: background .3s;
  191. &:hover {
  192. background: rgba(0, 0, 0, .025)
  193. }
  194. }
  195. }
  196. .avatar-container {
  197. margin-right: 30px;
  198. .avatar-wrapper {
  199. margin-top: 12px;
  200. position: relative;
  201. .user-avatar {
  202. cursor: pointer;
  203. width: 40px;
  204. height: 40px;
  205. border-radius: 10px;
  206. }
  207. .el-icon-caret-bottom {
  208. cursor: pointer;
  209. position: absolute;
  210. right: -20px;
  211. top: 25px;
  212. font-size: 14px;
  213. }
  214. }
  215. }
  216. .sideMenuTab{
  217. height: 100%;
  218. display: flex;
  219. justify-content: flex-start;
  220. padding-right: 20px;
  221. .item{
  222. height: 100%;
  223. display: flex;
  224. justify-content: center;
  225. align-items: center;
  226. flex-direction: column;
  227. color: #ccc;
  228. line-height: 1;
  229. font-weight: 600;
  230. padding: 0 15px;
  231. cursor: pointer;
  232. transition: 0.2s;
  233. p{
  234. white-space:nowrap;
  235. }
  236. &.active-0{color: #1890ff;font-weight: 600;}
  237. &.active-1{color: #b97741;font-weight: 600;}
  238. &.active-2{color: #97cd38;font-weight: 600;}
  239. &.active-3 {color: #dc5a2c;font-weight: 600;}
  240. &.active-4{color: #414ab9;font-weight: 600;}
  241. &.active-5{color: #c13ac9;font-weight: 600;}
  242. &.active-6{color: #29c761;font-weight: 600;}
  243. &.active-7 {color: #c7795c;font-weight: 600;}
  244. &.active-8{color: #bd966f;font-weight: 600;}
  245. &.active-9{color: #832188;font-weight: 600;}
  246. &.active-10{color: #66db8f;font-weight: 600;}
  247. .iconfont{
  248. color: inherit;
  249. }
  250. .iconfont{
  251. font-size: 36px;
  252. &.el-icon-s-platform{
  253. font-family: "element-icons" !important;
  254. }
  255. &.icon-common_health{
  256. font-size: 28px;
  257. }
  258. }
  259. p{
  260. padding-top: 3px;
  261. margin: 2px 0px;
  262. font-size: 14px;
  263. color: #ccc;
  264. }
  265. }
  266. }
  267. }
  268. }
  269. </style>