Navbar.vue 10.0 KB

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