交通管理局公文项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

411 lines
12 KiB

1 year ago
1 year ago
  1. <template>
  2. <div class="navbar">
  3. <logo v-if="showLogo" :collapse="isCollapse" />
  4. <div class="right-menu">
  5. <!-- 主题切换 -->
  6. <el-dropdown trigger="click">
  7. <div class="message-icon cart-main" style="cursor: pointer;">
  8. <span class="iconfont icon-zhuti" />
  9. </div>
  10. <el-dropdown-menu slot="dropdown" class="message-dropdown">
  11. <el-dropdown-item @click.native="changetheme('light')">
  12. 浅色主题
  13. <i class="el-icon-check" :style="{display: themeValue === 'light'?'':'none'}" />
  14. </el-dropdown-item>
  15. <el-dropdown-item @click.native="changetheme('dark')">
  16. 深色主题
  17. <i class="el-icon-check" :style="{display: themeValue === 'dark'?'':'none'}" />
  18. </el-dropdown-item>
  19. </el-dropdown-menu>
  20. </el-dropdown>
  21. <!-- 借阅车 -->
  22. <router-link :to="{ path: '/user/cart'}">
  23. <!-- 借阅车 -小红点数量 -->
  24. <div class="message-icon cart-main">
  25. <span class="iconfont icon-jieyueche-ding" />
  26. <i v-if="cartCount.length > 0" class="message-num">{{ cartCount.length }}</i>
  27. </div>
  28. </router-link>
  29. <!-- 消息中心 -->
  30. <el-dropdown ref="messageDrop" class="message-center right-menu-item hover-effect" trigger="click">
  31. <!-- 消息中心 -小红点数量 -->
  32. <div class="message-icon" style="margin: 0 15px;">
  33. <span class="iconfont icon-xiaoxi" />
  34. <i v-if="messageAll.length > 0" class="message-num">{{ messageAll.length }}</i>
  35. </div>
  36. <el-dropdown-menu slot="dropdown" class="message-dropdown" style="width: 420px; padding: 17px 0 0 0;">
  37. <div style="display: flex; justify-content: space-between; padding: 0 20px; height: 40px; line-height: 40px; color: #A6ADB6; font-size: 14px; border-bottom: 1px solid #E6E8ED;">
  38. <h3 style="font-size: 16px; color: #0C0E1E;">消息</h3>
  39. <span style="cursor: pointer;" @click="handleAllRead">全部标记为已读</span>
  40. </div>
  41. <div style="max-height: 450px; overflow: hidden; padding: 10px 0; overflow-y: scroll;">
  42. <el-dropdown-item v-if="messageAll.length===0" class="message-list-item">
  43. <div style="text-align:center">暂无最新消息</div>
  44. </el-dropdown-item>
  45. <!-- 消息中心 - 列表 -->
  46. <el-dropdown-item v-for="(item,index) in messageAll" :key="index" class="message-list-item" style="padding: 0 14px;">
  47. <div class="messsage-item" @click="toMessage(item)">
  48. <span :class="setIconClass(item)" />
  49. <div class="message-top-cont">
  50. <h4>{{ setNoticeTitle(item) }}</h4>
  51. <p>{{ item.noticeContext }}</p>
  52. <span>{{ item.createTime | parseTime }}</span>
  53. </div>
  54. </div>
  55. </el-dropdown-item>
  56. <div v-if="messageAll.length!==0" class="all-message-btn" @click="toAllMessage">查看全部<i class="iconfont icon-chakan" /></div>
  57. </div>
  58. </el-dropdown-menu>
  59. </el-dropdown>
  60. <el-dropdown class="avatar-container right-menu-item hover-effect" trigger="click">
  61. <div class="avatar-wrapper">
  62. <div class="user-img-cover">
  63. <img :src="user.avatarName ? baseApi + '/avatar/' + user.avatarName : Avatar" class="user-avatar" :onerror="defaultImg">
  64. </div>
  65. <div class="user-name">{{ user.username }}</div>
  66. <i class="el-icon-caret-bottom" />
  67. </div>
  68. <el-dropdown-menu slot="dropdown">
  69. <router-link :to="{ path: '/user/center', query: { activeIndex: 0 }}">
  70. <el-dropdown-item>
  71. 个人中心
  72. </el-dropdown-item>
  73. </router-link>
  74. <router-link :to="{ path: '/user/center', query: { activeIndex: 1 }}">
  75. <el-dropdown-item>
  76. 我的消息
  77. </el-dropdown-item>
  78. </router-link>
  79. <span style="display:block;" @click="open">
  80. <el-dropdown-item>
  81. 退出登录
  82. </el-dropdown-item>
  83. </span>
  84. </el-dropdown-menu>
  85. </el-dropdown>
  86. </div>
  87. </div>
  88. </template>
  89. <script>
  90. import { mapGetters } from 'vuex'
  91. import Logo from '@/layout/components/Sidebar/Logo'
  92. import Avatar from '@/assets/images/avatar.png'
  93. import { FetchReadedAll } from '@/api/system/new'
  94. import store from '@/store'
  95. export default {
  96. inject: ['reload'],
  97. components: {
  98. Logo
  99. },
  100. data() {
  101. return {
  102. Avatar: Avatar,
  103. defaultImg: 'this.src="' + require('@/assets/images/avatar.png') + '"',
  104. themeValue: localStorage.getItem('themeValue') ? localStorage.getItem('themeValue') : 'light'
  105. }
  106. },
  107. computed: {
  108. ...mapGetters([
  109. 'sidebar',
  110. 'device',
  111. 'user',
  112. 'baseApi',
  113. 'cartCount',
  114. 'messageAll'
  115. ]),
  116. show: {
  117. get() {
  118. return this.$store.state.settings.showSettings
  119. },
  120. set(val) {
  121. this.$store.dispatch('settings/changeSetting', {
  122. key: 'showSettings',
  123. value: val
  124. })
  125. }
  126. },
  127. showLogo() {
  128. return this.$store.state.settings.sidebarLogo
  129. },
  130. isCollapse() {
  131. return !this.sidebar.opened
  132. }
  133. },
  134. created() {
  135. // store.dispatch('initborrowCar').then(() => {})
  136. store.dispatch('initMySystemNotice').then(() => { })
  137. if (!localStorage.getItem('themeValue')) {
  138. this.changetheme('light')
  139. } else {
  140. this.changetheme(localStorage.getItem('themeValue'))
  141. }
  142. },
  143. methods: {
  144. setIconClass(item) {
  145. if (item.noticeType === 1) {
  146. return 'message-type-title type-title1'
  147. } else if (item.noticeType === 2) {
  148. return 'message-type-title type-title2'
  149. } else if (item.noticeType === 3) {
  150. return 'message-type-title type-title3'
  151. } else if (item.noticeType === 4) {
  152. if (item.noticeContext.includes('到期')) {
  153. return 'message-type-title type-title5'
  154. } else if (item.noticeContext.includes('逾期')) {
  155. return 'message-type-title type-title4'
  156. }
  157. }
  158. },
  159. setNoticeTitle(item) {
  160. switch (item.noticeType) {
  161. case 1 :
  162. return '系统通知'
  163. case 2 :
  164. return '有流程达到'
  165. case 3:
  166. return '流程完成提醒'
  167. case 4:
  168. if (item.noticeContext.includes('到期')) {
  169. return '赋权到期提醒'
  170. } else if (item.noticeContext.includes('逾期')) {
  171. return '赋权逾期提醒'
  172. }
  173. return '赋权提醒'
  174. }
  175. },
  176. // 全部已读
  177. async handleAllRead() {
  178. if (this.messageAll.length === 0) {
  179. this.$message({ message: '暂无需要处理得未读消息', type: 'error', offset: 8 })
  180. } else {
  181. const params = {
  182. 'newsType': null
  183. }
  184. FetchReadedAll(params).then(res => {
  185. if (res) {
  186. store.dispatch('initMySystemNotice').then(() => {})
  187. if (this.$route.path.includes('user/center') || this.$route.path.includes('system/notifyManage')) {
  188. this.reload()
  189. }
  190. }
  191. })
  192. }
  193. },
  194. toggleSideBar() {
  195. this.$store.dispatch('app/toggleSideBar')
  196. },
  197. toMessage(item) {
  198. this.$router.push({ path: '/user/center', query: { activeIndex: 1, noticeType: item.noticeType }})
  199. this.reload()
  200. },
  201. toAllMessage() {
  202. this.$router.push({ path: '/user/center', query: { activeIndex: 1, noticeType: 1 }})
  203. this.reload()
  204. this.$refs.messageDrop.hide()
  205. },
  206. open() {
  207. this.$confirm('确定注销并退出系统吗?', '提示', {
  208. confirmButtonText: '确定',
  209. cancelButtonText: '取消',
  210. type: 'warning'
  211. }).then(() => {
  212. this.logout()
  213. })
  214. },
  215. logout() {
  216. this.$store.dispatch('LogOut').then(() => {
  217. location.reload()
  218. localStorage.clear()
  219. })
  220. },
  221. handleClose(done) {
  222. done()
  223. },
  224. changetheme(theme) {
  225. this.themeValue = theme
  226. window.document.documentElement.setAttribute('data-theme', theme)
  227. localStorage.setItem('themeValue', theme)
  228. }
  229. }
  230. }
  231. </script>
  232. <style lang="scss" scoped>
  233. @import "~@/assets/styles/mixin.scss";
  234. @import "~@/assets/styles/variables.scss";
  235. .navbar {
  236. display: flex;
  237. justify-content: space-between;
  238. width: 100%;
  239. height: $headerHeight;
  240. overflow: hidden;
  241. position: relative;
  242. @include shadow-set;
  243. .errLog-container {
  244. display: inline-block;
  245. vertical-align: top;
  246. }
  247. .right-menu {
  248. display: flex;
  249. line-height: 64px;
  250. &:focus {
  251. outline: none;
  252. }
  253. .right-menu-item {
  254. display: inline-block;
  255. height: 100%;
  256. font-size: 18px;
  257. color: #5a5e66;
  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. .message-center{
  268. margin-right: 40px;
  269. }
  270. .message-icon{
  271. position: relative;
  272. .icon-xiaoxi{
  273. font-size: 20px;
  274. @include icon_color;
  275. }
  276. .message-num{
  277. position: absolute;
  278. top: 12px;
  279. right: -8px;
  280. display: block;
  281. width: 20px;
  282. height: 20px;
  283. font-size: 14px;
  284. text-align: center;
  285. line-height: 20px;
  286. border-radius: 50%;
  287. background-color: #F91832;
  288. color: #fff;
  289. }
  290. }
  291. .avatar-container {
  292. margin-right: 40px;
  293. .avatar-wrapper {
  294. display: flex;
  295. flex-direction: row;
  296. justify-content: space-between;
  297. align-items: center;
  298. @include icon_color;
  299. .user-img-cover{
  300. width: 24px;
  301. height: 24px;
  302. }
  303. .user-avatar {
  304. display: block;
  305. width: 100%;
  306. height: 100%;
  307. border-radius: 50%;
  308. // border: 1px solid red;
  309. cursor: pointer;
  310. }
  311. .user-name{
  312. margin: 0 37px 0 8px;
  313. flex: 1;
  314. font-size: 14px;
  315. }
  316. .el-icon-caret-bottom {
  317. cursor: pointer;
  318. font-size: 14px;
  319. }
  320. }
  321. }
  322. }
  323. }
  324. .cart-main{
  325. cursor: pointer;
  326. span{
  327. display: block;
  328. padding: 0 15px;
  329. }
  330. & :hover{
  331. background-color: rgba(249,249,249,1);
  332. }
  333. & .message-num{
  334. right: 6px !important;
  335. }
  336. }
  337. .icon-jieyueche-ding{
  338. font-size: 20px;
  339. @include icon_color;
  340. }
  341. .icon-zhuti{
  342. font-size: 22px;
  343. @include icon_color;
  344. }
  345. ::v-deep .el-dropdown-menu__item.is-active {
  346. color: #409EFF;
  347. background-color: red;
  348. }
  349. .message-type-title{
  350. width: 32px;
  351. height: auto;
  352. margin-right: 12px;
  353. margin-bottom: 0;
  354. &.type-title1{
  355. background-size: 33px 33px;
  356. }
  357. &.type-title2{
  358. background-size: 33px 33px;
  359. }
  360. &.type-title3{
  361. background-size: 33px 33px;
  362. }
  363. &.type-title4{
  364. background-size: 33px 33px;
  365. }
  366. &.type-title5{
  367. background-size: 33px 33px;
  368. }
  369. }
  370. .message-top-cont{
  371. position: relative;
  372. color: #A6ADB6;
  373. flex: 1;
  374. font-size: 12px;
  375. & h4{
  376. color: #545B65;
  377. font-size: 14px;
  378. }
  379. & span{
  380. position: absolute;
  381. right: 0;
  382. top: 0;
  383. }
  384. }
  385. .all-message-btn{
  386. font-size: 14px;
  387. color: #545B65;
  388. text-align: center;
  389. height: 40px;
  390. line-height: 40px;
  391. border-top: 1px solid #E6E8ED;
  392. margin-top: 12px;
  393. cursor: pointer;
  394. i{
  395. font-size: 12px;
  396. padding-left: 10px;
  397. color: #888D94;
  398. }
  399. }
  400. </style>