Navbar.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  1. <template>
  2. <div class="navbar">
  3. <!-- <div class="left-title">重卡换电智能站控系统</div>
  4. <div class="stationNo">No.{{ stationNo || '—' }}</div> -->
  5. <img src="./assets/logo_title.png" class="logo">
  6. <div class="left-menu">
  7. <div v-for="(item, index) in PermissionList" :key="index">
  8. <router-link :to="item.path">
  9. <span>{{ item.children[0].meta.title }}</span>
  10. </router-link>
  11. </div>
  12. </div>
  13. <div class="date-time">
  14. <div class="warn" @mouseover="getWarnList" @mouseout="LostWarn" @click="goToAlarm">
  15. <div class="is-warn">
  16. <el-badge :value="warnNum" class="item">
  17. <img src="./assets/warn.png">
  18. </el-badge>
  19. </div>
  20. <div>当前告警</div>
  21. </div>
  22. <div class="link">
  23. <div class="is-warn">
  24. <img :src='isLink ? require("./assets/link.png") : require("./assets/close.png")'>
  25. </div>
  26. <div>{{ isLink ? '已连接' : '断开' }}</div>
  27. </div>
  28. <div class="safedays">安全运营 {{ days }} 天</div>
  29. <div class="time-value">
  30. {{ dateTime.hours }}:{{ dateTime.minutes }}:{{ dateTime.seconds }}
  31. </div>
  32. <div class="date-value">
  33. <div class="week-value">{{ dateTime.weeks }}</div>
  34. <div class="day-value">
  35. {{ dateTime.year }}-{{ dateTime.month }}-{{ dateTime.day }}
  36. </div>
  37. </div>
  38. </div>
  39. <!-- <div class="dobusiness">
  40. <el-dropdown trigger="click" @command="HandleBusiness(isBusiness)">
  41. <span class="el-dropdown-link">
  42. {{isBusiness?'营业中':'未营业'}}<i class="el-icon-arrow-down el-icon--right"></i>
  43. </span>
  44. <el-dropdown-menu slot="dropdown">
  45. <el-dropdown-item>{{isBusiness?'未营业':'营业中'}}</el-dropdown-item>
  46. </el-dropdown-menu>
  47. </el-dropdown>
  48. </div> -->
  49. <!-- <div class="cutApart"></div> -->
  50. <div class="right-menu">
  51. <el-dropdown class="avatar-container right-menu-item hover-effect" trigger="click">
  52. <div class="avatar-wrapper">
  53. <span class="el-dropdown">{{ name }}<i class="el-icon-arrow-down el-icon--right"></i></span>
  54. </div>
  55. <el-dropdown-menu slot="dropdown">
  56. <router-link to="/permission/role" v-if="$store.getters.roles.includes('admin')">
  57. <el-dropdown-item>账号管理</el-dropdown-item>
  58. </router-link>
  59. <router-link to="/permission/updatepwd">
  60. <el-dropdown-item>修改密码</el-dropdown-item>
  61. </router-link>
  62. <el-dropdown-item divided @click.native="logout">
  63. <span style="display: block">安全退出</span>
  64. </el-dropdown-item>
  65. </el-dropdown-menu>
  66. </el-dropdown>
  67. </div>
  68. <div class="setFile"><router-link to="/control-config/setFile"><img src="./assets/set.png" width="26"
  69. height="26"></router-link></div>
  70. </div>
  71. </template>
  72. <script>
  73. import { mapGetters } from "vuex";
  74. import { getStateList, setBusiness, cloudState, getStationCode } from "@/api/statistics";
  75. export default {
  76. components: {},
  77. props: ['warnNum'],
  78. data() {
  79. return {
  80. PermissionList: [],
  81. dateTime: {
  82. year: "",
  83. month: "",
  84. day: "",
  85. weeks: "",
  86. hours: "",
  87. minutes: "",
  88. seconds: "",
  89. },
  90. days: 0,
  91. isLink: undefined,
  92. isBusiness: true,
  93. stationNo: null,
  94. };
  95. },
  96. computed: {
  97. ...mapGetters(["name", "permission_routes"]),
  98. },
  99. mounted() {
  100. setInterval(() => {
  101. this.timer()
  102. }, 1000);
  103. setInterval(() => {
  104. this.getCloudState()
  105. }, 2000);
  106. this.menuList()
  107. this.getSafeDay()
  108. this.getStationCode()
  109. },
  110. methods: {
  111. goToAlarm() {
  112. // this.$router.push({path:"/permission/now-alarm"})
  113. },
  114. //获取换电站编号
  115. getStationCode() {
  116. getStationCode().then(res => {
  117. this.stationNo = res.data
  118. })
  119. },
  120. //修改营业状态
  121. HandleBusiness(flag) {
  122. this.$confirm('确认修改营业状态?', '确认操作', {
  123. confirmButtonText: '确认',
  124. cancelButtonText: '取消',
  125. type: 'warning'
  126. })
  127. .then(async () => {
  128. const data = await setBusiness(flag)
  129. this.$message({
  130. type: 'success',
  131. message: '操作成功!'
  132. })
  133. // this.getUserlist()
  134. console.log(data);
  135. this.isBusiness = this.isBusiness ? 0 : 1
  136. })
  137. .catch(err => { console.error(err) })
  138. },
  139. getCloudState() {
  140. cloudState().then(res => {
  141. this.isLink = res.data
  142. })
  143. },
  144. //安全运行天数
  145. getSafeDay() {
  146. getStateList(1).then(res => {
  147. this.days = res.data.content
  148. })
  149. // getStateList(2).then(res => {
  150. // this.isBusiness=res.data.content==1?1:0
  151. // })
  152. },
  153. getWarnList() {
  154. this.$emit('ShowWarn');
  155. },
  156. LostWarn() {
  157. this.$emit('CloseWarn');
  158. },
  159. //菜单路由
  160. menuList() {
  161. // this.PermissionList = this.permission_routes.slice(5, 11);
  162. this.PermissionList = this.permission_routes.slice(5, 11);
  163. console.log(this.PermissionList, '999999');
  164. },
  165. //当前时间
  166. timer() {
  167. let vWeek = [
  168. "星期天",
  169. "星期一",
  170. "星期二",
  171. "星期三",
  172. "星期四",
  173. "星期五",
  174. "星期六",
  175. ];
  176. let date = new Date();
  177. this.dateTime.year = date.getFullYear();
  178. this.dateTime.month = this.lenFormat(date.getMonth() + 1);
  179. this.dateTime.day = this.lenFormat(date.getDate());
  180. this.dateTime.hours = this.lenFormat(date.getHours());
  181. this.dateTime.minutes = this.lenFormat(date.getMinutes());
  182. this.dateTime.seconds = this.lenFormat(date.getSeconds());
  183. this.dateTime.weeks = vWeek[date.getDay()];
  184. // console.log(date.getMonth() + 1)
  185. },
  186. lenFormat(i) {
  187. let s = "" + i;
  188. return s.length === 1 ? "0" + s : s;
  189. },
  190. //退出登录
  191. async logout() {
  192. await this.$store.dispatch("user/logout");
  193. this.$router.push(`/login?redirect=${this.$route.fullPath}`);
  194. },
  195. },
  196. };
  197. </script>
  198. <style lang="scss" scoped>
  199. .el-submenu__icon-arrow {
  200. right: -18px;
  201. top: 30%;
  202. font-size: 16px;
  203. font-weight: bold;
  204. transform: rotate(180deg);
  205. }
  206. .navbar {
  207. height: 54px;
  208. overflow: hidden;
  209. position: relative;
  210. display: flex;
  211. flex-direction: row;
  212. color: white;
  213. padding-top: 10px;
  214. // margin-top: 20px;
  215. justify-content: space-between;
  216. // border-bottom: 1px solid #2f343e;
  217. background-color: #1E1F25;
  218. width: calc(100% - 40px);
  219. margin-left: 20px;
  220. padding-left: 15px;
  221. .logo{
  222. width: 447px;
  223. height: 34px;
  224. margin-right: 80px;
  225. }
  226. .stationNo {
  227. padding: 0px 15px;
  228. height: 32px;
  229. background: #1C263A;
  230. border: 1px solid #26334C;
  231. font-size: 16px;
  232. font-weight: 500;
  233. color: rgba(153, 174, 197, 0.65);
  234. text-shadow: 0px 0px 4px rgba(39, 69, 201, 0.5);
  235. line-height: 32px;
  236. text-align: center;
  237. margin-right: 32px;
  238. }
  239. .left-title {
  240. font-size: 26px;
  241. text-align: center;
  242. font-weight: bold;
  243. line-height: 30px;
  244. padding-left: 20px;
  245. margin-right: 10px;
  246. }
  247. .left-menu {
  248. flex: 1;
  249. height: 100%;
  250. line-height: 36px;
  251. display: flex;
  252. flex-direction: row;
  253. justify-content: flex-start;
  254. color: #757B8C;
  255. .iconacive {
  256. display: none;
  257. }
  258. div {
  259. margin-right: 35px;
  260. height: 39px;
  261. }
  262. @media screen and (max-width: 1024px) {
  263. div {
  264. margin-right: 22px;
  265. }
  266. .date-time .warn {
  267. font-size: 12px;
  268. }
  269. .safedays {
  270. font-size: 12px;
  271. }
  272. }
  273. .routerlink {
  274. position: relative;
  275. }
  276. .router-link-active {
  277. color: #fff;
  278. position: relative;
  279. // text-shadow: 0px 0px 8px rgba(34, 123, 255, 0.8);
  280. .iconacive {
  281. display: inline;
  282. }
  283. svg:first-child {
  284. display: none;
  285. }
  286. .el-submenu__icon-arrow {
  287. right: -20px !important;
  288. position: absolute;
  289. transform: rotate(360deg);
  290. color: #91fdb9;
  291. }
  292. .el-icon-arrow-down:before {
  293. content: "";
  294. }
  295. }
  296. span {
  297. font-size: 20px;
  298. font-weight: 600;
  299. padding-left: 6px;
  300. }
  301. .router-link-active::after {
  302. content: "";
  303. display: inline-block;
  304. width: 100%;
  305. height: 2px;
  306. background: #246CF9;
  307. position: absolute;
  308. bottom: -16px;
  309. left: 3px;
  310. z-index: 0;
  311. }
  312. }
  313. .safedays {
  314. font-size: 18px;
  315. font-weight: 600;
  316. line-height: 40px;
  317. text-align: right;
  318. padding-right: 15px;
  319. }
  320. .date-time {
  321. color: white;
  322. display: flex;
  323. flex-direction: row;
  324. align-items: center;
  325. justify-content: flex-end;
  326. padding-right: 5px;
  327. .warn {
  328. width: 92px;
  329. display: flex;
  330. font-size: 16px;
  331. justify-content: space-between;
  332. align-items: center;
  333. justify-items: center;
  334. padding-right: 24px;
  335. box-sizing: content-box;
  336. line-height: 24px;
  337. cursor: pointer;
  338. height: 39px;
  339. img {
  340. width: 20px;
  341. height: 20px;
  342. }
  343. }
  344. .link {
  345. width: 86px;
  346. display: flex;
  347. align-items: center;
  348. justify-items: center;
  349. font-size: 16px;
  350. line-height: 24px;
  351. height: 39px;
  352. margin-top: 3px;
  353. justify-content: flex-start;
  354. img {
  355. margin-right: 3px;
  356. vertical-align: middle;
  357. width: 20px;
  358. height: 20px;
  359. }
  360. }
  361. .date-value {
  362. width: 80px;
  363. white-space: nowrap;
  364. }
  365. .day-value {
  366. font-size: 14px;
  367. line-height: 22px;
  368. font-family: "微软雅黑";
  369. }
  370. @media screen and (max-width: 1152px) {
  371. .date-value {
  372. width: 112px;
  373. }
  374. .warn {
  375. width: 110px;
  376. }
  377. .time-value {
  378. width: 98px !important;
  379. }
  380. }
  381. @media screen and (max-width: 1440px) {
  382. .date-value {
  383. padding-bottom: 8px;
  384. }
  385. }
  386. // @media screen and (min-width: 1281px) and (max-width: 1366px) {
  387. // .date-value{
  388. // width: 96px;
  389. // }
  390. // }
  391. // @media screen and (min-width: 1400px) and (max-width: 1600px) {
  392. // .date-value{
  393. // width: 92px;
  394. // }
  395. // }
  396. .time-value {
  397. font-size: 18px;
  398. width: 82px;
  399. text-align: left;
  400. box-sizing: border-box;
  401. font-weight: bold;
  402. }
  403. .week-value {
  404. font-size: 14px;
  405. }
  406. }
  407. .right-menu {
  408. height: 100%;
  409. line-height: 34px;
  410. .el-dropdown {
  411. font-size: 16px;
  412. font-weight: 400;
  413. color: #FFFFFF;
  414. text-shadow: 0px 0px 11px rgba(34, 123, 255, 0.8);
  415. .el-icon-arrow-down:before {
  416. bottom: -4px;
  417. }
  418. }
  419. &:focus {
  420. outline: none;
  421. }
  422. .right-menu-item {
  423. display: inline-block;
  424. padding: 0 8px;
  425. height: 100%;
  426. font-size: 18px;
  427. color: #5a5e66;
  428. vertical-align: text-bottom;
  429. &.hover-effect {
  430. cursor: pointer;
  431. transition: background 0.3s;
  432. &:hover {
  433. background: rgba(0, 0, 0, 0.025);
  434. }
  435. }
  436. }
  437. }
  438. .dobusiness {
  439. margin: 0 5px;
  440. .el-dropdown {
  441. font-size: 18px;
  442. text-shadow: 0px 0px 11px rgba(34, 123, 255, 0.8);
  443. font-weight: 400;
  444. color: #9D9FA4;
  445. line-height: 38px;
  446. cursor: pointer;
  447. }
  448. }
  449. .setFile {
  450. padding-right: 20px;
  451. padding-top: 4px;
  452. width: 26px;
  453. height: 26px;
  454. box-sizing: content-box;
  455. img {
  456. width: 26px;
  457. height: 26px;
  458. }
  459. }
  460. .cutApart {
  461. width: 1px;
  462. height: 32px;
  463. background: #54616D;
  464. opacity: 1;
  465. margin: 0 5px;
  466. }
  467. }</style>