commonHeaders.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  1. <template>
  2. <div class="proheader" :class="!switchTheme ? 'themeDarks' : 'themeLights'">
  3. <el-container>
  4. <el-header :class="getStyle()">
  5. <div class="logoSty">
  6. <img src="../assets/logoGuo_DB1.png" alt="" />
  7. </div>
  8. <div class="proMenu">
  9. <div class="proButton">
  10. <div
  11. class="buttonItem"
  12. v-for="(item, index) in menuData"
  13. :key="index"
  14. :class="getColor(item.showBac)"
  15. @click="changeRoute(item)"
  16. >
  17. <img :src="headerMenuImg" alt="" v-if="item.showBac" />
  18. <span>{{ item.name }}</span>
  19. </div>
  20. </div>
  21. <div class="proSet">
  22. <div class="settingStop">
  23. <el-switch v-model="switchTheme" @change="changSwith">
  24. <template #active-action>
  25. <!-- <span class="custom-active-action">T</span> -->
  26. <img :src="moon_B" alt="" v-if="!switchTheme" />
  27. <img :src="sun_W" alt="" v-else />
  28. </template>
  29. <template #inactive-action>
  30. <!-- <span class="custom-inactive-action">F</span> -->
  31. <img :src="moon_B" alt="" v-if="!switchTheme" />
  32. <img :src="sun_B" alt="" v-else />
  33. </template>
  34. </el-switch>
  35. <el-tooltip
  36. class="box-item"
  37. effect="light"
  38. content="自动填报工具"
  39. >
  40. <!-- <a href="http://10.127.7.196:9001/script/download"> -->
  41. <!-- <a href="http://172.16.12.101:9001/script/download"> -->
  42. <a :href="`${headerReportUrl}:9001/script/download`">
  43. <img :src="header_wendang" class="Settingitem downItem" />
  44. </a>
  45. </el-tooltip>
  46. <el-tooltip class="box-item" effect="light" content="系统设置" v-if="userName === 'administrators'">
  47. <img :src="header_shezhi" class="Settingitem" @click="openSystemSet">
  48. </el-tooltip>
  49. <el-tooltip class="box-item" effect="light" content="退出">
  50. <img
  51. :src="header_dianyuan"
  52. class="Settingitem rightIm"
  53. @click="backLogin"
  54. />
  55. </el-tooltip>
  56. </div>
  57. </div>
  58. </div>
  59. </el-header>
  60. </el-container>
  61. </div>
  62. </template>
  63. <script>
  64. import httpRequest from "@/utils/request.js";
  65. import header_wendang from "@/assets/images/headerCom/zidongtianbao.png";
  66. import header_shezhi from "@/assets/images/headerCom/shezhi.png";
  67. import header_dianyuan from "@/assets/images/headerCom/guanji.png";
  68. import sun_W from "@/assets/images/headerCom/sun_W.png";
  69. import moon_B from "@/assets/images/headerCom/moon_B.png";
  70. import sun_B from "@/assets/images/headerCom/sun_B.png";
  71. import moon_W from "@/assets/images/headerCom/moon_W.png";
  72. import headerMenuImg from "@/assets/images/headerCom/headerMenu.png";
  73. import { Sunny, Moon } from "@element-plus/icons-vue";
  74. import { apiGetpersonalInformation } from "@/api/api";
  75. import { removeToken, removeUserKey, getUserKey } from "../utils/auth";
  76. export default {
  77. name: "headerCom",
  78. data() {
  79. return {
  80. SunnyIcon: Sunny,
  81. MoonIcon: Moon,
  82. sun_W: sun_W,
  83. sun_B: sun_B,
  84. moon_B: moon_B,
  85. moon_W: moon_W,
  86. headerMenuImg: headerMenuImg,
  87. header_wendang: header_wendang,
  88. header_shezhi: header_shezhi,
  89. header_dianyuan: header_dianyuan,
  90. leftIndex: "1",
  91. currentTime: "",
  92. showRole: true,
  93. menuData: [
  94. {
  95. index: "/home",
  96. icon: "Menu",
  97. name: "首页",
  98. showBac: true,
  99. },
  100. {
  101. index: "/generatingCap/dataFilter/prepare",
  102. icon: "Histogram",
  103. name: "发电能力分析",
  104. },
  105. {
  106. index: "/integratedAlarm/realwarning",
  107. icon: "Histogram",
  108. name: "综合报警",
  109. },
  110. {
  111. index: "/intelligentReport/gkjlb?name=xinzhuang",
  112. icon: "PictureFilled",
  113. name: "智能报表",
  114. },
  115. {
  116. index: "/powerPrediction/index",
  117. icon: "TrendCharts",
  118. name: "功率预测",
  119. },
  120. ],
  121. rainW: false,
  122. userName: "",
  123. switchTheme: false,
  124. headerReportUrl: "",
  125. };
  126. },
  127. created() {
  128. this.headerReportUrl = this.baseReportUrl;
  129. console.log("userkey==>>>", this.$store.state.userKey)
  130. const userKey = getUserKey()
  131. this.$store.commit("changeUserkey", userKey);
  132. let menuData = []
  133. if (userKey === "zz") {
  134. menuData = [
  135. {
  136. index: "/home",
  137. icon: "Menu",
  138. name: "首页",
  139. showBac: true,
  140. },
  141. {
  142. index: "/intelligentReport/gkjlb?name=xinzhuang",
  143. icon: "PictureFilled",
  144. name: "智能报表",
  145. },
  146. {
  147. index: "/powerPrediction/index",
  148. icon: "TrendCharts",
  149. name: "功率预测",
  150. }
  151. ]
  152. } else {
  153. menuData = this.menuData
  154. }
  155. this.menuData = menuData
  156. },
  157. mounted() {
  158. let that = this;
  159. this.switchTheme = JSON.parse(window.sessionStorage.getItem("theme"));
  160. this.$store.commit("changeTheme", this.switchTheme);
  161. this.$emit("swichFn", this.switchTheme);
  162. this.getThemeClass(this.switchTheme);
  163. let userMes = JSON.parse(window.sessionStorage.getItem("userMessage"));
  164. that.userName = userMes ? userMes.role : "administrators";
  165. if (this.$route.query.markKey) {
  166. that.userName = that.$route.query.userid;
  167. }
  168. if (userMes && userMes.role === "ordinaryUser") {
  169. that.showRole = false;
  170. }
  171. that.showHeader(that.$route);
  172. },
  173. watch: {
  174. $route: {
  175. handler: function (route) {
  176. this.showHeader(route);
  177. },
  178. immediate: true,
  179. },
  180. },
  181. methods: {
  182. changSwith(bool) {
  183. this.getThemeClass(bool);
  184. this.$emit("swichFn", bool);
  185. window.sessionStorage.setItem("theme", JSON.stringify(bool));
  186. this.$store.commit("changeTheme", bool);
  187. },
  188. getThemeClass(bool) {
  189. if (bool) {
  190. document.body.classList.remove("nsfStyle");
  191. if (!document.body.classList.contains("blueStyle")) {
  192. document.body.classList.add("blueStyle");
  193. }
  194. } else {
  195. document.body.classList.remove("blueStyle");
  196. if (!document.body.classList.contains("nsfStyle")) {
  197. document.body.classList.add("nsfStyle");
  198. }
  199. }
  200. },
  201. openSystemSet() {
  202. // let url = 'http://127.0.0.1:8009/login'
  203. let url = "http://172.16.12.101:7095/"
  204. window.open(url,"target")
  205. },
  206. showHeader(route) {
  207. this.menuData.forEach((it) => {
  208. if (route.path.indexOf("powerPrediction") > -1) {
  209. if (it.name === "功率预测") {
  210. it.showBac = true;
  211. } else {
  212. it.showBac = false;
  213. }
  214. } else if (route.path.indexOf("intelligentReport") > -1) {
  215. if (it.name === "智能报表") {
  216. it.showBac = true;
  217. } else {
  218. it.showBac = false;
  219. }
  220. } else if (route.path.indexOf("generatingCap") > -1) {
  221. if (it.name === "发电能力分析") {
  222. it.showBac = true;
  223. } else {
  224. it.showBac = false;
  225. }
  226. } else if (route.path.indexOf("integratedAlarm") > -1) {
  227. if (it.name === "综合报警") {
  228. it.showBac = true;
  229. } else {
  230. it.showBac = false;
  231. }
  232. } else if (route.path === "/home") {
  233. if (it.name === "首页") {
  234. it.showBac = true;
  235. } else {
  236. it.showBac = false;
  237. }
  238. } else {
  239. it.showBac = false;
  240. }
  241. });
  242. },
  243. changeRoute(item) {
  244. window.sessionStorage.setItem("headerRoute", item.index);
  245. let params = {};
  246. if (item.index.indexOf("intelligentReport") > -1) {
  247. params = {
  248. name: "xinzhuang",
  249. };
  250. }
  251. this.$router.push({
  252. path: item.index,
  253. query: params,
  254. });
  255. this.$emit("headerName", item.name);
  256. },
  257. // async backLogin() {
  258. // let loginName = this.userName
  259. // if (loginName) {
  260. // await this.LogoutInfor(loginName)
  261. // }
  262. // },
  263. backLogin() {
  264. window.sessionStorage.clear();
  265. removeToken();
  266. removeUserKey();
  267. // this.getThemeClass(true);
  268. // this.$emit("swichFn", true);
  269. this.$router.push({
  270. path: "/login",
  271. });
  272. },
  273. // 插入登出信息
  274. LogoutInfor(name) {
  275. let that = this;
  276. let onlyData = JSON.parse(window.sessionStorage.getItem("userDatamsg"));
  277. let loginData = JSON.parse(window.sessionStorage.getItem("loginMsg"));
  278. if (onlyData) {
  279. let paramsLogin = onlyData ? onlyData.identifier : loginData.identific;
  280. let params = {
  281. identifier: paramsLogin,
  282. loginName: name,
  283. };
  284. apiGetinsertLogoutInformation(params).then((datas) => {
  285. if (datas) {
  286. let url = location.origin + "/#/login";
  287. window.open(url, "_self");
  288. location.reload();
  289. removeToken();
  290. }
  291. });
  292. } else {
  293. let url = location.origin + "/#/login";
  294. window.open(url, "_self");
  295. location.reload();
  296. removeToken();
  297. }
  298. },
  299. getStyle() {
  300. if (this.$route.path === "/weather") {
  301. if (this.rainW) {
  302. return "weatherSty";
  303. } else {
  304. return "headerSty";
  305. }
  306. }
  307. },
  308. getColor(val) {
  309. let strWea = "";
  310. if (val) {
  311. strWea = "changeBacksty";
  312. } else {
  313. strWea = "defaultBacksty";
  314. }
  315. return strWea;
  316. },
  317. //获取个人信息
  318. getUserMes(id) {
  319. let params = {
  320. userId: id,
  321. };
  322. apiGetpersonalInformation(params).then((datas) => {
  323. window.sessionStorage.setItem(
  324. "userInfo",
  325. JSON.stringify(datas.data.user)
  326. );
  327. });
  328. },
  329. changeDate(date) {
  330. var y = date.getFullYear();
  331. var m = date.getMonth() + 1;
  332. m = m < 10 ? "0" + m : m;
  333. var d = date.getDate();
  334. d = d < 10 ? "0" + d : d;
  335. var h = date.getHours();
  336. h = h < 10 ? "0" + h : h;
  337. var minute = date.getMinutes();
  338. minute = minute < 10 ? "0" + minute : minute;
  339. var second = date.getSeconds();
  340. second = second < 10 ? "0" + second : second;
  341. return y + "-" + m + "-" + d + " " + h + ":" + minute + ":" + second;
  342. },
  343. nowTime() {
  344. let that = this;
  345. let date = new Date();
  346. this.statusTimer = setInterval(function () {
  347. var y = date.getFullYear();
  348. var m = date.getMonth() + 1;
  349. m = m < 10 ? "0" + m : m;
  350. var d = date.getDate();
  351. d = d < 10 ? "0" + d : d;
  352. var h = date.getHours();
  353. h = h < 10 ? "0" + h : h;
  354. var minute = date.getMinutes();
  355. minute = minute < 10 ? "0" + minute : minute;
  356. var second = date.getSeconds();
  357. second = second < 10 ? "0" + second : second;
  358. that.currentTime =
  359. y + "-" + m + "-" + d + " " + h + ":" + minute + ":" + second;
  360. }, 1000);
  361. },
  362. handleSelect(index) {
  363. if (this.leftIndex === index) return;
  364. this.leftIndex = index;
  365. // this.$router.push({path: index})
  366. console.log(index);
  367. },
  368. },
  369. };
  370. </script>
  371. <style lang="less">
  372. .proheader {
  373. position: relative;
  374. width: 100%;
  375. z-index: 1000;
  376. height: 50px;
  377. .weatherSty {
  378. background: rgb(74, 87, 100);
  379. }
  380. .el-header {
  381. padding: 0 10px;
  382. display: flex;
  383. justify-content: space-between;
  384. // background: rgb(13, 104, 188);
  385. // background: rgba(96,103,105,.75);
  386. color: #fff;
  387. line-height: 50px;
  388. height: 50px !important;
  389. .logoSty {
  390. padding: 8px 0 0 0;
  391. img {
  392. width: 310px;
  393. }
  394. }
  395. .proMenu {
  396. .proButton {
  397. display: flex;
  398. .buttonItem {
  399. cursor: pointer;
  400. width: 130px;
  401. height: 52px;
  402. line-height: 52px;
  403. font-size: 14px;
  404. text-align: center;
  405. position: relative;
  406. img {
  407. position: absolute;
  408. left: 0;
  409. }
  410. }
  411. }
  412. .proSet {
  413. display: flex;
  414. justify-content: center;
  415. // width: 260px;
  416. .settingStop {
  417. display: flex;
  418. // width: 260px;
  419. align-items: center;
  420. justify-content: center;
  421. .el-switch {
  422. margin-left: 26px;
  423. width: 88px;
  424. height: 25px;
  425. .el-switch__input {
  426. width: 88px;
  427. height: 25px;
  428. }
  429. .el-switch__core {
  430. width: 88px;
  431. height: 25px;
  432. border-radius: 13px;
  433. .el-switch__action {
  434. width: 41px;
  435. height: 21px;
  436. border-radius: 11px;
  437. img {
  438. width: 15px;
  439. height: 15px;
  440. }
  441. }
  442. }
  443. }
  444. .el-switch--small.is-checked .el-switch__core .el-switch__action {
  445. width: 41px;
  446. height: 21px;
  447. border-radius: 10px;
  448. left: calc(100% - 41px) !important;
  449. }
  450. .Settingitem {
  451. color: #fff;
  452. margin-left: 30px;
  453. width: 25px;
  454. height: 25px;
  455. cursor: pointer;
  456. }
  457. .rightIm {
  458. margin-right: 30px;
  459. }
  460. .downItem {
  461. position: relative;
  462. top: 7px;
  463. }
  464. }
  465. }
  466. }
  467. }
  468. }
  469. .themeDarks {
  470. border-bottom: 1px solid #3a3a3a;
  471. .proMenu {
  472. display: flex;
  473. align-items: center;
  474. .proButton {
  475. border-right: 1px solid #3a3a3a !important;
  476. .buttonItem {
  477. border-left: 1px solid #3a3a3a !important;
  478. }
  479. .changeBacksty {
  480. border-bottom: 3px solid #1c99ff !important;
  481. color: #1c99ff !important;
  482. }
  483. .defaultBacksty {
  484. color: #a2a3a4 !important;
  485. }
  486. .defaultweathersty {
  487. background-color: #0d68bc !important;
  488. }
  489. .defaultweatherRainsty {
  490. background-color: #4a5764 !important;
  491. }
  492. }
  493. .el-switch {
  494. .el-switch__core {
  495. background: #000;
  496. background-image: url("@/assets/images/headerCom/sun_B.png");
  497. background-repeat: no-repeat;
  498. background-position: 58px 2px;
  499. background-size: 20px;
  500. .el-switch__action {
  501. background: #1c99ff;
  502. }
  503. }
  504. }
  505. }
  506. }
  507. .themeLights {
  508. background: linear-gradient(90deg, #1f53b1, #6962b1) !important;
  509. border-bottom: 1px solid #7899ff;
  510. .proMenu {
  511. display: flex;
  512. align-items: center;
  513. .proButton {
  514. border-right: 1px solid #7899ff !important;
  515. .buttonItem {
  516. border-left: 1px solid #7899ff !important;
  517. }
  518. .changeBacksty {
  519. border-bottom: 3px solid #3dc2d3 !important;
  520. color: #fff !important;
  521. }
  522. .defaultBacksty {
  523. color: #b7c6ff !important;
  524. }
  525. .defaultweathersty {
  526. background-color: #0d68bc !important;
  527. }
  528. .defaultweatherRainsty {
  529. background-color: #4a5764 !important;
  530. }
  531. }
  532. .el-switch {
  533. .el-switch__core {
  534. background: #1e3f9a;
  535. background-image: url("@/assets/images/headerCom/moon_W.png");
  536. background-repeat: no-repeat;
  537. background-position: 8px 2px;
  538. background-size: 20px;
  539. .el-switch__action {
  540. background: #fff;
  541. }
  542. }
  543. }
  544. }
  545. }
  546. </style>