Navbar.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <template>
  2. <div class="navbar">
  3. <div class="left-menu">
  4. <hamburger :is-active="sidebar.opened" class="hamburger-container" @toggleClick="toggleSideBar" />
  5. <!-- <h3>设备管理系统</h3> -->
  6. </div>
  7. <div class="right-menu">
  8. <!-- <search id="header-search" class="right-menu-item" />-->
  9. <!--<screenfull id="screenfull" class="right-menu-item hover-effect" /> -->
  10. <el-dropdown id="news" class="avatar-container" trigger="click">
  11. <span class="right-menu-news">
  12. <svg-icon class="right-menu-news-icon" :icon-class="'icon-news'" />
  13. <i class="right-menu-news-right">{{ sumAmount }}</i>
  14. </span>
  15. <el-dropdown-menu slot="dropdown" class="user-dropdown">
  16. <div class="newsTitle" style="padding-left: 10px">
  17. 消息通知
  18. </div>
  19. <el-dropdown-item v-for="(item,index) in meslist" :key="index" divided>
  20. <span style="display:block;" @click="clickList(item)"><span style="margin-right:30px;">{{ item.remark }}</span><span style="float:right;">{{ item.mesTime }}</span></span>
  21. </el-dropdown-item>
  22. <router-link to="/console/News">
  23. <el-dropdown-item style="text-align:center;margin-top:10px;">
  24. 查看全部
  25. </el-dropdown-item>
  26. </router-link>
  27. </el-dropdown-menu>
  28. </el-dropdown>
  29. <el-dropdown class="avatar-container" trigger="click">
  30. <div class="avatar-wrapper">
  31. <img src="@/assets/cow.jpg" class="user-avatar">
  32. <span style="font-size:12px;">欢迎您,{{ employename }}</span>
  33. <i class="el-icon-caret-bottom" />
  34. </div>
  35. <el-dropdown-menu slot="dropdown" class="user-dropdown">
  36. <router-link to="/">
  37. <el-dropdown-item>
  38. 主页
  39. </el-dropdown-item>
  40. </router-link>
  41. <el-dropdown-item divided>
  42. <span style="display:block;" @click="logout">注销</span>
  43. </el-dropdown-item>
  44. <router-link to="/console/Changpwd">
  45. <el-dropdown-item>
  46. 修改密码
  47. </el-dropdown-item>
  48. </router-link>
  49. </el-dropdown-menu>
  50. </el-dropdown>
  51. </div>
  52. </div>
  53. </template>
  54. <script>
  55. // import { GetDataByName } from '@/api/common'
  56. import { mapGetters } from 'vuex'
  57. import Hamburger from '@/components/Hamburger'
  58. // import Screenfull from '@/components/Screenfull'
  59. // import Search from '@/components/HeaderSearch'
  60. // import path from 'path'
  61. // import Cookies from 'js-cookie'
  62. export default {
  63. components: {
  64. Hamburger
  65. // Screenfull,
  66. // Search
  67. },
  68. data() {
  69. return {
  70. sumAmount: '',
  71. meslist: ''
  72. }
  73. },
  74. computed: {
  75. ...mapGetters([
  76. 'sidebar',
  77. 'avatar',
  78. 'employename',
  79. 'employeid',
  80. 'pastureid',
  81. 'departmentid',
  82. 'sumamount'
  83. ])
  84. },
  85. created() {
  86. window.setInterval(() => {
  87. setTimeout(() => {
  88. this.sumAmount = JSON.parse(sessionStorage.sumamount)
  89. this.meslist = JSON.parse(sessionStorage.meslist)
  90. }, 0)
  91. }, 100)
  92. },
  93. methods: {
  94. toggleSideBar() {
  95. this.$store.dispatch('app/toggleSideBar')
  96. },
  97. async logout() {
  98. await this.$store.dispatch('user/logout')
  99. this.$store.dispatch('tagsView/delAllViews').then(({ visitedViews }) => {
  100. console.log("注销了")
  101. })
  102. // this.$router.push(`/login?redirect=${this.$route.fullPath}`) //跳转到登陆前页面
  103. },
  104. // 点击消息列表跳转
  105. clickList(val) {
  106. var regex1 = /\【(.+?)\】/g
  107. var value = (val.remark).match(regex1)[0]
  108. var routerName = value.substring(1, value.length - 1)
  109. if (routerName === '合同审核') {
  110. var regex2 = /\:(.*)/
  111. var value2 = (val.repairCode).match(regex2)[1]
  112. var contractCode = value2.substring(0, 12)
  113. this.$router.push({ path: '/customs/ContractManagement', query: { contractCode: contractCode }})
  114. // this.$router.push('/customs/ContractManagement')
  115. } else if (routerName === '申购审核') {
  116. this.$router.push('/customs/Subscribe')
  117. } else if (routerName === '采购配单') {
  118. this.$router.push('/customs/Purchase')
  119. } else if (routerName === '领用审核') {
  120. this.$router.push('/customs/Receive')
  121. } else if (routerName === '退货审核') {
  122. this.$router.push('/customs/Returngoods')
  123. } else if (routerName === '设备审核') {
  124. this.$router.push({ path: '/asset/Basics', query: { tabName: 'second' }})
  125. } else if (routerName === '设备保养' || routerName === '保养审核') {
  126. this.$router.push('/maintenance/Maintain')
  127. } else if (routerName === '维修接单' || routerName === '维修派单' || routerName === '维修审核') {
  128. this.$router.push('/maintenance/Repair')
  129. } else if (routerName === '备件审核') {
  130. this.$router.push({ path: '/customs/Basic', query: { tabName: 'second' }})
  131. } else if (routerName === '配单审核') {
  132. this.$router.push({ path: '/customs/Purchase', query: { activeName: 'fouth' }})
  133. }
  134. }
  135. }
  136. }
  137. </script>
  138. <style lang="scss" scoped>
  139. .navbar {
  140. height: 50px;
  141. overflow: hidden;
  142. position: relative;
  143. background: #fff;
  144. box-shadow: 0 1px 4px rgba(0,21,41,.08);
  145. .hamburger-container {
  146. line-height: 46px;
  147. height: 100%;
  148. float: left;
  149. cursor: pointer;
  150. transition: background .3s;
  151. -webkit-tap-highlight-color:transparent;
  152. &:hover {
  153. background: rgba(0, 0, 0, .025)
  154. }
  155. }
  156. h3{
  157. margin-top: 13px;
  158. }
  159. .breadcrumb-container {
  160. float: left;
  161. }
  162. .right-menu {
  163. float: right;
  164. height: 100%;
  165. line-height: 50px;
  166. &:focus {
  167. outline: none;
  168. }
  169. .right-menu-item {
  170. display: inline-block;
  171. padding: 0 8px;
  172. height: 100%;
  173. font-size: 18px;
  174. color: #5a5e66;
  175. vertical-align: text-bottom;
  176. &.hover-effect {
  177. cursor: pointer;
  178. transition: background .3s;
  179. &:hover {
  180. background: rgba(0, 0, 0, .025)
  181. }
  182. }
  183. }
  184. .avatar-container {
  185. margin-right: 30px;
  186. .avatar-wrapper {
  187. margin-top: 5px;
  188. position: relative;
  189. .user-avatar {
  190. cursor: pointer;
  191. width: 40px;
  192. height: 40px;
  193. border-radius: 10px;
  194. }
  195. .el-icon-caret-bottom {
  196. cursor: pointer;
  197. position: absolute;
  198. right: -20px;
  199. top: 25px;
  200. font-size: 12px;
  201. }
  202. }
  203. }
  204. .right-menu-news{
  205. margin-right:25px;
  206. position:relative;
  207. .right-menu-news-icon{
  208. display:block;
  209. float:left;
  210. width:25px;
  211. height:40px;
  212. }
  213. .right-menu-news-right{
  214. display:block;
  215. width:20px;
  216. height:20px;
  217. float:left;
  218. border-radius: 10px;
  219. background:red;
  220. font-style:normal;
  221. position:absolute;
  222. right:-12px;
  223. bottom:25px;
  224. font-weight: 300;
  225. font-size:12px ;
  226. line-height: 20px;
  227. text-align:center;
  228. color:#fff;
  229. }
  230. }
  231. }
  232. }
  233. </style>
  234. <style lang="scss" >
  235. .user-dropdown{
  236. top: 40px!important;
  237. }
  238. </style>