Navbar.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  1. <template>
  2. <div class="navbar">
  3. <div class="nav-header">
  4. <!-- <span class="nav-heander-name">重载铁路线路环境机车远程监视系统</span> -->
  5. <span class="nav-heander-name">{{ projectName }}</span>
  6. <img class="titleImg" src="@/assets/表头背景.png" />
  7. <img class="logo" src="@/assets/机车LOGO.png" />
  8. <div
  9. class="right-menu"
  10. style="display: flex; align-items: center; line-height: 1em"
  11. >
  12. <el-popover
  13. v-model="allMessageShow"
  14. placement="bottom-end"
  15. width="500"
  16. trigger="click"
  17. ref="popoveraite"
  18. popper-class="home-el-popover"
  19. style="cursor: pointer"
  20. >
  21. <!-- <img src="../../assets/tishi.png" alt=""> -->
  22. <div class="msgAlarmMessage">
  23. <!-- <div
  24. class="msgAlarmMessage-head"
  25. :class="{ 'no-home': isHome == false }"
  26. >
  27. <div>
  28. 共{{ $store.state.app.warningSocket.list.length }}条消息
  29. </div>
  30. <div class="message" @click="toMessageAll">全部消息</div>
  31. </div> -->
  32. <div class="msgAlarmMessage-list">
  33. <div
  34. class="msgAlarmMessage-head"
  35. :class="{ 'no-home': isHome == false }"
  36. >
  37. <div>
  38. 共{{ $store.state.app.warningSocket.list.length }}条消息
  39. </div>
  40. <div class="message" @click="toMessageAll">更多消息</div>
  41. </div>
  42. <div
  43. v-for="item in $store.state.app.warningSocket.list"
  44. @click="linkClick(item)"
  45. class="msgAlarmMessage-item"
  46. >
  47. <div class="item-title">
  48. <div class="item-text1">【报警】</div>
  49. <div class="item-text2">{{ item.railwayName }}</div>
  50. <!-- <div class="item-text3">{{ item.releasedTime }}</div> -->
  51. </div>
  52. <div class="item-content">
  53. <span>{{ item.alarmTime }}</span>
  54. <span style="display: inline-block; margin-left: 5px"
  55. >,里程位置{{ item.alarmMile }},</span
  56. >
  57. <span>{{ item.lineDir == 1 ? "上行" : "下行" }},</span>
  58. <span style="display: inline-block; margin-left: 5px">{{
  59. item.alarmType == 1 ? "泥石流" : ""
  60. }}</span>
  61. <!-- {{ item.alarmType === 1 ? "泥石流" : "" }} -->
  62. <!-- {{ item.lineDirStr }} 里程位置 里程范围
  63. {{ item.beginMile }}-{{ item.endMile }} -->
  64. </div>
  65. </div>
  66. </div>
  67. </div>
  68. <el-badge
  69. slot="reference"
  70. :value="$store.state.app.warningSocket.list.length==0?'':$store.state.app.warningSocket.list.length"
  71. class="item"
  72. >
  73. <img
  74. :src="
  75. !isHome
  76. ? require('../../assets/xiaoxi-1.png')
  77. : require('../../assets/xiaoxi-1.png')
  78. "
  79. alt=""
  80. />
  81. </el-badge>
  82. </el-popover>
  83. <div
  84. style="
  85. width: 1px;
  86. height: 60%;
  87. background-color: none;
  88. margin-left: 0px;
  89. margin-right: 20px;
  90. "
  91. />
  92. <el-dropdown class="avatar-container" trigger="click">
  93. <div class="avatar-wrapper">
  94. <img
  95. :src="
  96. !isHome
  97. ? require('../../assets/btn_cards1.png')
  98. : require('../../assets/btn_cards1.png')
  99. "
  100. class="user-avatar"
  101. />
  102. <div :style="{ color: isHome == true ? '#fff' : '#fff' }">
  103. {{ name }}
  104. </div>
  105. <i style="color: #fff" class="el-icon-caret-bottom" />
  106. </div>
  107. <el-dropdown-menu slot="dropdown" class="user-dropdown">
  108. <!-- <router-link to="/">
  109. <el-dropdown-item>
  110. Home
  111. </el-dropdown-item>
  112. </router-link> -->
  113. <el-dropdown-item divided @click.native="logout">
  114. <span style="display: block">退出登陆</span>
  115. </el-dropdown-item>
  116. <el-dropdown-item>
  117. <span style="display: block" @click="personalCenter()"
  118. >个人中心</span
  119. >
  120. </el-dropdown-item>
  121. <el-dropdown-item>
  122. <span style="display: block" @click="updatePwd">修改密码</span>
  123. </el-dropdown-item>
  124. </el-dropdown-menu>
  125. </el-dropdown>
  126. <updatePwd
  127. v-if="updatePwdData.dialogVisible"
  128. :updatePwdData="updatePwdData"
  129. @updatePwdBtn="updatePwdBtn"
  130. >
  131. </updatePwd>
  132. </div>
  133. </div>
  134. <hamburger
  135. :is-active="sidebar.opened"
  136. class="hamburger-container"
  137. @toggleClick="toggleSideBar"
  138. />
  139. </div>
  140. </template>
  141. <script>
  142. import { mapGetters } from "vuex";
  143. import Breadcrumb from "@/components/Breadcrumb";
  144. import Hamburger from "@/components/Hamburger";
  145. import store from "@/store";
  146. import { msgAlarmWebAlarm, readById } from "@/api/alarmList";
  147. import updatePwd from "./updatePwd.vue";
  148. import { updatepwd } from "@/api/sysManage";
  149. import { projectName } from '@/api/user'
  150. export default {
  151. components: {
  152. Breadcrumb,
  153. Hamburger,
  154. updatePwd,
  155. },
  156. computed: {
  157. ...mapGetters(["sidebar", "avatar", "name"]),
  158. isHome() {
  159. return this.$route.path == "/dashboard";
  160. },
  161. },
  162. created() {
  163. projectName().then(res => {
  164. this.projectName = res
  165. })
  166. },
  167. data() {
  168. return {
  169. updatePwdData: {
  170. dialogVisible: false,
  171. },
  172. allMessageShow: false,
  173. qrCodeData: {
  174. dialogVisible: true,
  175. },
  176. projectName:'',
  177. };
  178. },
  179. mounted() {
  180. msgAlarmWebAlarm().then((res) => {
  181. if(res.code==200){
  182. let data = res.data.webAlarm;
  183. if (data.length > 0) {
  184. data.forEach((element) => {
  185. this.$store.commit("app/warningSocketAdd", element);
  186. });
  187. }
  188. }else{
  189. }
  190. });
  191. },
  192. methods: {
  193. updatePwdBtn(payload) {
  194. updatepwd(payload).then((res) => {
  195. if (res.code == 200) {
  196. this.$message({
  197. type: "success",
  198. message: "修改成功!",
  199. });
  200. this.updatePwdData.dialogVisible = false;
  201. } else {
  202. this.$message({
  203. type: "error",
  204. message: res.msg,
  205. });
  206. }
  207. });
  208. },
  209. linkClick(item) {
  210. readById({
  211. pushId: item.pushId,
  212. }).then((res) => {
  213. if (res.code == "200") {
  214. for (
  215. var i = 0;
  216. i < this.$store.state.app.warningSocket.list.length;
  217. i++
  218. ) {
  219. if (item.id === this.$store.state.app.warningSocket.list[i].id) {
  220. this.$store.state.app.warningSocket.list.splice(i, 1);
  221. }
  222. }
  223. }
  224. });
  225. this.$router.push({ path: "/alarmDetail?id=" + item.id });
  226. },
  227. updatePwd() {
  228. this.updatePwdData.dialogVisible = true;
  229. },
  230. showQrcode() {
  231. this.qrCodeData.dialogVisible = true;
  232. },
  233. toggleSideBar() {
  234. this.$store.dispatch("app/toggleSideBar");
  235. },
  236. async logout() {
  237. // await this.$store.dispatch('user/logout')
  238. // this.$router.push(`/login?redirect=${this.$route.fullPath}`)
  239. store.dispatch("user/resetToken").then(() => {
  240. location.reload();
  241. });
  242. },
  243. homeClearScreenClick() {
  244. this.$store.commit("app/homeClearScreenClick");
  245. },
  246. // 去全部消息
  247. toMessageAll() {
  248. this.allMessageShow = false;
  249. this.$router.push("/message/list");
  250. },
  251. //跳转个人中心
  252. personalCenter() {
  253. this.$router.push("/personalCenter/list");
  254. },
  255. },
  256. };
  257. </script>
  258. <style lang="scss" scoped>
  259. .nav-header {
  260. position: relative;
  261. width: 100%;
  262. height: 50px;
  263. position: fixed;
  264. top: 0px;
  265. left: 0;
  266. background-color: #2250c8;
  267. /* background: linear-gradient(187deg, #0b244f 0%, #05448c 100%); */
  268. color: #fff;
  269. line-height: 50px;
  270. padding-left: 15px;
  271. .nav-heander-name {
  272. position: absolute;
  273. z-index: 60;
  274. text-indent: 60px;
  275. font-size: 20px;
  276. letter-spacing: 4px;
  277. font-weight: 800;
  278. }
  279. .titleImg {
  280. display: block;
  281. position: absolute;
  282. left: -183px;
  283. top: -24px;
  284. z-index: 50;
  285. }
  286. .logo {
  287. position: absolute;
  288. z-index: 50;
  289. }
  290. }
  291. .nav-headers {
  292. width: 100%;
  293. height: 50px;
  294. position: fixed;
  295. top: 15px;
  296. left: 0;
  297. background-color: #2250c8;
  298. /* background: linear-gradient(187deg, #0b244f 0%, #05448c 100%); */
  299. color: #fff;
  300. line-height: 50px;
  301. padding-left: 56px;
  302. }
  303. .el-badge__content {
  304. background-color: #ff0000;
  305. }
  306. .home-el-popover {
  307. background: transparent !important;
  308. border: none;
  309. padding: 0;
  310. box-shadow: none;
  311. }
  312. </style>
  313. <style lang="scss" scoped>
  314. .navbar {
  315. height: 0px;
  316. overflow: hidden;
  317. position: relative;
  318. // background: #fff;
  319. box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
  320. .hamburger-container {
  321. display: none;
  322. line-height: 46px;
  323. height: 100%;
  324. float: left;
  325. cursor: pointer;
  326. transition: background 0.3s;
  327. -webkit-tap-highlight-color: transparent;
  328. &:hover {
  329. background: rgba(0, 0, 0, 0.025);
  330. }
  331. }
  332. .breadcrumb-container {
  333. float: left;
  334. }
  335. .right-menu {
  336. float: right;
  337. height: 100%;
  338. line-height: 50px;
  339. .qrCode {
  340. cursor: pointer;
  341. margin-left: 10px;
  342. border-radius: 3px;
  343. font-size: 16px;
  344. background: -webkit-linear-gradient(top, #0251af, #00c7fb);
  345. line-height: 25px;
  346. height: 25px;
  347. width: 70px;
  348. text-align: center;
  349. }
  350. &:focus {
  351. outline: none;
  352. }
  353. .cls {
  354. width: 74px;
  355. height: 24px;
  356. // border: 1px solid #000000;
  357. border-image: linear-gradient(
  358. 151deg,
  359. rgba(0, 105, 237, 0.6),
  360. rgba(0, 199, 251, 0.6)
  361. )
  362. 3 3;
  363. border-radius: 3px;
  364. color: #fff;
  365. display: flex;
  366. justify-content: center;
  367. align-items: center;
  368. margin-left: 10px;
  369. background: -webkit-linear-gradient(top, #0251af, #00c7fb);
  370. cursor: pointer;
  371. }
  372. &:focus {
  373. outline: none;
  374. }
  375. .right-menu-item {
  376. display: inline-block;
  377. padding: 0 8px;
  378. height: 100%;
  379. font-size: 18px;
  380. color: #5a5e66;
  381. vertical-align: text-bottom;
  382. &.hover-effect {
  383. cursor: pointer;
  384. transition: background 0.3s;
  385. &:hover {
  386. background: rgba(0, 0, 0, 0.025);
  387. }
  388. }
  389. }
  390. .avatar-container {
  391. margin-right: 30px;
  392. .avatar-wrapper {
  393. position: relative;
  394. display: flex;
  395. align-items: center;
  396. .user-avatar {
  397. cursor: pointer;
  398. width: 28.5px;
  399. height: 28.5px;
  400. border-radius: 50%;
  401. margin-right: 5px;
  402. }
  403. .el-icon-caret-bottom {
  404. margin-left: 5px;
  405. cursor: pointer;
  406. font-size: 12px;
  407. color: #0556db;
  408. }
  409. }
  410. }
  411. }
  412. }
  413. .msgAlarmMessage {
  414. box-shadow: none;
  415. margin-top: 5px;
  416. .message {
  417. cursor: pointer;
  418. color: #4d85f4;
  419. }
  420. // .message:hover {
  421. // background: #4d85f4;
  422. // }
  423. // .message:active {
  424. // background: #144ebf;
  425. // }
  426. .msgAlarmMessage-head {
  427. display: flex;
  428. justify-content: space-between;
  429. padding-bottom: 8px;
  430. margin-top: 5px;
  431. border-bottom: 1px solid #f2f2f2;
  432. color: #333333;
  433. font-size: 12px;
  434. // width: 100%;
  435. // color: #fff;
  436. &.no-home {
  437. color: #000;
  438. }
  439. }
  440. .msgAlarmMessage-list {
  441. display: flex;
  442. flex-direction: column;
  443. font-size: 14px;
  444. max-height: 412px;
  445. overflow-y: auto;
  446. background-color: #fff;
  447. padding: 24px;
  448. margin-top: 5px;
  449. border-radius: 2px;
  450. // box-shadow: 0px 2px 4px 0px rgba(221, 217, 217, 1);
  451. .msgAlarmMessage-item {
  452. padding-bottom: 8px;
  453. margin-top: 5px;
  454. border-bottom: 1px solid rgba(242, 242, 242, 1);
  455. cursor: pointer;
  456. // border: 1px solid rgba(242,242,242,1);
  457. .item-title {
  458. display: flex;
  459. align-items: center;
  460. .item-text1 {
  461. flex-shrink: 0;
  462. color: red;
  463. // margin-right: 10px;
  464. }
  465. .item-text2 {
  466. flex: 1;
  467. color: #000000;
  468. font-size: 14px;
  469. }
  470. .item-text3 {
  471. flex-shrink: 0;
  472. }
  473. }
  474. .item-content {
  475. // padding: 5px 20px;
  476. // width: 520px;
  477. height: 33px;
  478. line-height: 33px;
  479. padding-left: 12px;
  480. background: #f5f5f5;
  481. margin-top: 5px;
  482. border-radius: 5px;
  483. color: #565656;
  484. font-size: 12px;
  485. }
  486. }
  487. }
  488. }
  489. </style>