Navbar.vue 10 KB

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