Navbar.vue 10 KB

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