Navbar.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  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':''"
  33. >
  34. <a v-if="tab.href" :href="tab.href" target="_blank" class="item-cont">
  35. <img :src="tab.icon" class="icon">
  36. <p>{{ tab.name }}</p>
  37. </a>
  38. <div v-else class="item-cont" @click="sideTabChange(tab.id,tab)">
  39. <img :src="tab.icon" class="icon">
  40. <p>{{ tab.name }}</p>
  41. </div>
  42. </div>
  43. </div>
  44. <div class="right-menu-item" @click="navToPage('/message')">
  45. <el-badge :is-dot="false" class="nav-icon">
  46. <i class="el-icon-message-solid" />
  47. </el-badge>
  48. </div>
  49. <el-dropdown class="avatar-container right-menu-item hover-effect" trigger="click">
  50. <div class="avatar-wrapper">
  51. <el-avatar v-if="userData" :src="userData.userAvatar" />
  52. <i class="el-icon-caret-bottom" />
  53. </div>
  54. <el-dropdown-menu slot="dropdown">
  55. <router-link to="/profile/index">
  56. <el-dropdown-item>
  57. 个人中心
  58. </el-dropdown-item>
  59. </router-link>
  60. <el-dropdown-item divided @click.native="logout">
  61. <span style="display:block;">退出登录</span>
  62. </el-dropdown-item>
  63. </el-dropdown-menu>
  64. </el-dropdown>
  65. </div>
  66. </div>
  67. </template>
  68. <script>
  69. import { mapGetters } from 'vuex'
  70. import Breadcrumb from '@/components/Breadcrumb'
  71. import Hamburger from '@/components/Hamburger'
  72. import ErrorLog from '@/components/ErrorLog'
  73. import Screenfull from '@/components/Screenfull'
  74. import SizeSelect from '@/components/SizeSelect'
  75. import Search from '@/components/HeaderSearch'
  76. import { getUnReadCounter } from '@/api/system/msgApi'
  77. import { isNotNull } from '@/utils'
  78. export default {
  79. name: 'Navbar',
  80. components: {
  81. Breadcrumb,
  82. Hamburger,
  83. ErrorLog,
  84. Screenfull,
  85. SizeSelect,
  86. Search
  87. },
  88. data() {
  89. return {
  90. logo: require('@/assets/images/logo/lylc_hos.png'),
  91. sideMenuTabIndex: 0,
  92. sideMenus: [],
  93. sideMenuTabList: [
  94. { name: '数据总览', icon: require('./nav/icon.png'), path: '/', permit: 'hos_overview', id: 0 },
  95. { name: '平安医院', icon: require('./nav/icon-1.png'), path: '/hos/safe/overview', permit: 'hos_safe', id: 1, href: '../aqpt' },
  96. { name: '质量医院', icon: require('./nav/icon-2.png'), path: '/hos/quality/overview', permit: 'hos_quality', id: 2, href: '../qhpt' },
  97. { name: '满意医院', icon: require('./nav/icon-3.png'), path: '/hos/satisfy/overview', permit: 'hos_satisfy', id: 3, href: '../csat' },
  98. { name: '智慧医院', icon: require('./nav/icon-4.png'), path: '/hos/smart/overview', permit: 'hos_smart', id: 4, href: '../shpt' },
  99. { name: '健康医院', icon: require('./nav/icon-5.png'), path: '/hos/health/overview', permit: 'hos_health', id: 5, href: '../hhpt' },
  100. { name: '节约型医院', icon: require('./nav/icon-6.png'), path: '/hos/economic/overview', permit: 'hos_economic', id: 6, href: '../ehpt' },
  101. { name: '系统管理', icon: require('./nav/icon-7.png'), path: '/hos/profile', permit: 'hos_economic', id: 7 }
  102. ]
  103. }
  104. },
  105. computed: {
  106. ...mapGetters([
  107. 'device',
  108. 'sidebar',
  109. 'avatar',
  110. 'userData',
  111. 'permission_routes',
  112. 'menuSiderTab',
  113. 'permits'
  114. ])
  115. },
  116. watch: {
  117. menuSiderTab(val) {
  118. const item = this.sideMenuTabList[val]
  119. this.sideTabChange(val, item)
  120. }
  121. },
  122. mounted() {
  123. this.getUnReadMsg()
  124. this.initSideMenu()
  125. this.initSideTab()
  126. },
  127. methods: {
  128. getUnReadMsg() {
  129. getUnReadCounter().then((resp) => {
  130. this.unReadCount = resp.data
  131. })
  132. },
  133. initSideMenu() {
  134. const permits = JSON.parse(JSON.stringify(this.permits))
  135. let sideMenuTabList = JSON.parse(JSON.stringify(this.sideMenuTabList))
  136. sideMenuTabList = sideMenuTabList.filter(item => permits.includes(item.permit))
  137. this.sideMenus = sideMenuTabList
  138. },
  139. initSideTab() {
  140. let index = 0
  141. if (isNotNull(localStorage.getItem('tabIndex'))) {
  142. index = parseFloat(localStorage.getItem('tabIndex'))
  143. }
  144. this.sideTabChange(index, {
  145. path: this.$route.fullPath
  146. })
  147. },
  148. toggleSideBar() {
  149. this.$store.dispatch('app/toggleSideBar')
  150. },
  151. navToPage(path) {
  152. this.$emit('initMessage')
  153. },
  154. async logout() {
  155. // localStorage.clear('permission_routes') // 垃圾数据清除
  156. // localStorage.clear('tabIndex')
  157. localStorage.clear()
  158. await this.$store.dispatch('user/logout')
  159. this.$router.push(`/login?redirect=${this.$route.fullPath}`)
  160. },
  161. sideTabChange(index, item) {
  162. this.sideMenuTabIndex = index
  163. this.$router.replace({
  164. path: item.path
  165. })
  166. localStorage.setItem('tabIndex', index)
  167. var permission_routes = localStorage.getItem('permission_routes')
  168. if (permission_routes) { permission_routes = JSON.parse(permission_routes) } else {
  169. permission_routes = this.permission_routes
  170. localStorage.setItem('permission_routes', JSON.stringify(permission_routes))
  171. }
  172. // 获取权限路由,根据groupId进行过滤
  173. const filterRoutes = permission_routes.filter((item) => {
  174. if (item.groupId) {
  175. return item.groupId.includes(index)
  176. }
  177. return item
  178. })
  179. this.$store.state.permission.routes = filterRoutes
  180. }
  181. }
  182. }
  183. </script>
  184. <style lang="scss" scoped>
  185. .navbar {
  186. height: var(--navHeight);
  187. overflow: hidden;
  188. background: unset;
  189. box-shadow: 0 1px 4px rgba(0, 21, 41, .08);
  190. border-bottom: 1px solid #0f3a4a;
  191. position: fixed;
  192. width: 100%;
  193. z-index: 999;
  194. left: 0;
  195. box-sizing: border-box;
  196. background-color: inherit;
  197. top: 0;
  198. display: flex;
  199. justify-content: space-between;
  200. align-items: center;
  201. .hos-name{
  202. height: 100%;
  203. display: flex;
  204. align-items: center;
  205. float: left;
  206. padding-left: 10px;
  207. color: #fff;
  208. // flex: 1;
  209. img{
  210. display: block;
  211. width: auto;
  212. height: 26px;
  213. }
  214. .tag{
  215. font-size: 16px;
  216. line-height: 1;
  217. font-weight: 300;
  218. padding-left: 5px;
  219. margin-top: 7px;
  220. &.authorization{
  221. font-size: 12px;
  222. margin-top: 20px;
  223. color: #a33e3e;
  224. // color: rgba(255, 255, 255, 0.7);
  225. }
  226. }
  227. }
  228. .hamburger-container {
  229. padding: 6px 6px;
  230. margin-left: 5px;
  231. line-height: var(--navHeight);
  232. height: 100%;
  233. font-size: 14px;
  234. float: left;
  235. color: rgb(219, 204, 204) !important;
  236. cursor: pointer;
  237. transition: background .3s;
  238. -webkit-tap-highlight-color:transparent;
  239. &:hover {
  240. background: rgba(0, 0, 0, .025)
  241. }
  242. }
  243. .breadcrumb-container {
  244. float: left;
  245. }
  246. .errLog-container {
  247. display: inline-block;
  248. vertical-align: top;
  249. }
  250. .right-menu {
  251. // float: right;
  252. height: 100%;
  253. line-height: var(--navHeight);
  254. display: flex;
  255. justify-content: flex-end;
  256. align-items: center;
  257. flex: 1;
  258. &:focus {
  259. outline: none;
  260. }
  261. .right-menu-item {
  262. display: inline-block;
  263. padding: 0 8px;
  264. height: 100%;
  265. font-size: 18px;
  266. color: #fff;
  267. vertical-align: text-bottom;
  268. &.hover-effect {
  269. cursor: pointer;
  270. transition: background .3s;
  271. &:hover {
  272. background: rgba(0, 0, 0, .025)
  273. }
  274. }
  275. }
  276. .avatar-container {
  277. margin-right: 30px;
  278. .avatar-wrapper {
  279. margin-top: 12px;
  280. position: relative;
  281. .user-avatar {
  282. cursor: pointer;
  283. width: 40px;
  284. height: 40px;
  285. border-radius: 10px;
  286. }
  287. .el-icon-caret-bottom {
  288. cursor: pointer;
  289. position: absolute;
  290. right: -20px;
  291. top: 25px;
  292. font-size: 12px;
  293. }
  294. }
  295. }
  296. .sideMenuTab{
  297. overflow-x: auto;
  298. height: 100%;
  299. display: flex;
  300. justify-content: flex-start;
  301. align-items: center;
  302. padding-right: 50px;
  303. .item{
  304. display: flex;
  305. justify-content: center;
  306. align-items: center;
  307. color: rgba(255, 255, 255, 0.7);
  308. cursor: pointer;
  309. transition: 0.2s;
  310. flex-shrink: 0;
  311. height: 40px;
  312. line-height: 40px;
  313. border-radius: 20px;
  314. margin-right: 5px;
  315. .item-cont{
  316. display: block;
  317. height: 100%;
  318. padding: 0 14px 0 8px;
  319. border-radius: 20px;
  320. display: flex;
  321. justify-content: center;
  322. align-items: center;
  323. }
  324. &.active{
  325. background: rgba(24, 144, 255, 0.9);
  326. p{
  327. font-weight: 700;
  328. color: #fff;
  329. }
  330. }
  331. .icon{
  332. display: block;
  333. width: 24px;
  334. height: 24px;
  335. }
  336. .iconfont{
  337. font-size: 30px;
  338. &.el-icon-s-platform{
  339. font-family: "element-icons" !important;
  340. }
  341. &.icon-common_health{
  342. font-size: 28px;
  343. }
  344. }
  345. p{
  346. padding: 0;
  347. font-size: 14px;
  348. color: rgba(255, 255, 255, 0.7);
  349. }
  350. }
  351. }
  352. }
  353. }
  354. </style>