commonHeaders.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  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="系统设置">
  47. <img :src="header_shezhi" class="Settingitem">
  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 } 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. rainW: false,
  95. userName: "",
  96. switchTheme: false,
  97. headerReportUrl: "",
  98. };
  99. },
  100. created() {
  101. this.headerReportUrl = this.baseReportUrl;
  102. this.menuData = [
  103. {
  104. index: "/home",
  105. icon: "Menu",
  106. name: "首页",
  107. showBac: true,
  108. },
  109. {
  110. index: "/generatingCap/dataFilter/prepare",
  111. icon: "Histogram",
  112. name: "发电能力分析",
  113. },
  114. {
  115. index: "/integratedAlarm/realwarning",
  116. icon: "Histogram",
  117. name: "综合报警",
  118. },
  119. {
  120. index: "/intelligentReport/gkjlb?name=xinzhuang",
  121. icon: "PictureFilled",
  122. name: "智能报表",
  123. },
  124. {
  125. index: "/powerPrediction/index",
  126. icon: "TrendCharts",
  127. name: "功率预测",
  128. },
  129. ];
  130. },
  131. mounted() {
  132. let that = this;
  133. this.switchTheme = JSON.parse(window.sessionStorage.getItem("theme"));
  134. this.$store.commit("changeTheme", this.switchTheme);
  135. this.$emit("swichFn", this.switchTheme);
  136. this.getThemeClass(this.switchTheme);
  137. let userMes = JSON.parse(window.sessionStorage.getItem("userMessage"));
  138. that.userName = userMes ? userMes.role : "administrator";
  139. if (this.$route.query.markKey) {
  140. that.userName = that.$route.query.userid;
  141. }
  142. if (userMes && userMes.role === "ordinaryUser") {
  143. that.showRole = false;
  144. }
  145. that.showHeader(that.$route);
  146. },
  147. watch: {
  148. $route: {
  149. handler: function (route) {
  150. this.showHeader(route);
  151. },
  152. immediate: true,
  153. },
  154. },
  155. methods: {
  156. changSwith(bool) {
  157. this.getThemeClass(bool);
  158. this.$emit("swichFn", bool);
  159. window.sessionStorage.setItem("theme", JSON.stringify(bool));
  160. this.$store.commit("changeTheme", bool);
  161. },
  162. getThemeClass(bool) {
  163. if (bool) {
  164. document.body.classList.remove("nsfStyle");
  165. if (!document.body.classList.contains("blueStyle")) {
  166. document.body.classList.add("blueStyle");
  167. }
  168. } else {
  169. document.body.classList.remove("blueStyle");
  170. if (!document.body.classList.contains("nsfStyle")) {
  171. document.body.classList.add("nsfStyle");
  172. }
  173. }
  174. },
  175. showHeader(route) {
  176. this.menuData.forEach((it) => {
  177. if (route.path.indexOf("powerPrediction") > -1) {
  178. if (it.name === "功率预测") {
  179. it.showBac = true;
  180. } else {
  181. it.showBac = false;
  182. }
  183. } else if (route.path.indexOf("intelligentReport") > -1) {
  184. if (it.name === "智能报表") {
  185. it.showBac = true;
  186. } else {
  187. it.showBac = false;
  188. }
  189. } else if (route.path.indexOf("generatingCap") > -1) {
  190. if (it.name === "发电能力分析") {
  191. it.showBac = true;
  192. } else {
  193. it.showBac = false;
  194. }
  195. } else if (route.path.indexOf("integratedAlarm") > -1) {
  196. if (it.name === "综合报警") {
  197. it.showBac = true;
  198. } else {
  199. it.showBac = false;
  200. }
  201. } else if (route.path === "/home") {
  202. if (it.name === "首页") {
  203. it.showBac = true;
  204. } else {
  205. it.showBac = false;
  206. }
  207. } else {
  208. it.showBac = false;
  209. }
  210. });
  211. },
  212. changeRoute(item) {
  213. window.sessionStorage.setItem("headerRoute", item.index);
  214. let params = {};
  215. if (item.index.indexOf("intelligentReport") > -1) {
  216. params = {
  217. name: "xinzhuang",
  218. };
  219. }
  220. this.$router.push({
  221. path: item.index,
  222. query: params,
  223. });
  224. this.$emit("headerName", item.name);
  225. },
  226. // async backLogin() {
  227. // let loginName = this.userName
  228. // if (loginName) {
  229. // await this.LogoutInfor(loginName)
  230. // }
  231. // },
  232. backLogin() {
  233. window.sessionStorage.clear();
  234. this.$router.push({
  235. path: "/login",
  236. });
  237. },
  238. // 插入登出信息
  239. LogoutInfor(name) {
  240. let that = this;
  241. let onlyData = JSON.parse(window.sessionStorage.getItem("userDatamsg"));
  242. let loginData = JSON.parse(window.sessionStorage.getItem("loginMsg"));
  243. if (onlyData) {
  244. let paramsLogin = onlyData ? onlyData.identifier : loginData.identific;
  245. let params = {
  246. identifier: paramsLogin,
  247. loginName: name,
  248. };
  249. apiGetinsertLogoutInformation(params).then((datas) => {
  250. if (datas) {
  251. let url = location.origin + "/#/login";
  252. window.open(url, "_self");
  253. location.reload();
  254. removeToken();
  255. }
  256. });
  257. } else {
  258. let url = location.origin + "/#/login";
  259. window.open(url, "_self");
  260. location.reload();
  261. removeToken();
  262. }
  263. },
  264. getStyle() {
  265. if (this.$route.path === "/weather") {
  266. if (this.rainW) {
  267. return "weatherSty";
  268. } else {
  269. return "headerSty";
  270. }
  271. }
  272. },
  273. getColor(val) {
  274. let strWea = "";
  275. if (val) {
  276. strWea = "changeBacksty";
  277. } else {
  278. strWea = "defaultBacksty";
  279. }
  280. return strWea;
  281. },
  282. //获取个人信息
  283. getUserMes(id) {
  284. let params = {
  285. userId: id,
  286. };
  287. apiGetpersonalInformation(params).then((datas) => {
  288. window.sessionStorage.setItem(
  289. "userInfo",
  290. JSON.stringify(datas.data.user)
  291. );
  292. });
  293. },
  294. changeDate(date) {
  295. var y = date.getFullYear();
  296. var m = date.getMonth() + 1;
  297. m = m < 10 ? "0" + m : m;
  298. var d = date.getDate();
  299. d = d < 10 ? "0" + d : d;
  300. var h = date.getHours();
  301. h = h < 10 ? "0" + h : h;
  302. var minute = date.getMinutes();
  303. minute = minute < 10 ? "0" + minute : minute;
  304. var second = date.getSeconds();
  305. second = second < 10 ? "0" + second : second;
  306. return y + "-" + m + "-" + d + " " + h + ":" + minute + ":" + second;
  307. },
  308. nowTime() {
  309. let that = this;
  310. let date = new Date();
  311. this.statusTimer = setInterval(function () {
  312. var y = date.getFullYear();
  313. var m = date.getMonth() + 1;
  314. m = m < 10 ? "0" + m : m;
  315. var d = date.getDate();
  316. d = d < 10 ? "0" + d : d;
  317. var h = date.getHours();
  318. h = h < 10 ? "0" + h : h;
  319. var minute = date.getMinutes();
  320. minute = minute < 10 ? "0" + minute : minute;
  321. var second = date.getSeconds();
  322. second = second < 10 ? "0" + second : second;
  323. that.currentTime =
  324. y + "-" + m + "-" + d + " " + h + ":" + minute + ":" + second;
  325. }, 1000);
  326. },
  327. handleSelect(index) {
  328. if (this.leftIndex === index) return;
  329. this.leftIndex = index;
  330. // this.$router.push({path: index})
  331. console.log(index);
  332. },
  333. },
  334. };
  335. </script>
  336. <style lang="less">
  337. .proheader {
  338. position: relative;
  339. width: 100%;
  340. z-index: 1000;
  341. height: 50px;
  342. .weatherSty {
  343. background: rgb(74, 87, 100);
  344. }
  345. .el-header {
  346. padding: 0 10px;
  347. display: flex;
  348. justify-content: space-between;
  349. // background: rgb(13, 104, 188);
  350. // background: rgba(96,103,105,.75);
  351. color: #fff;
  352. line-height: 50px;
  353. height: 50px !important;
  354. .logoSty {
  355. padding: 8px 0 0 0;
  356. img {
  357. width: 310px;
  358. }
  359. }
  360. .proMenu {
  361. .proButton {
  362. display: flex;
  363. .buttonItem {
  364. cursor: pointer;
  365. width: 130px;
  366. height: 52px;
  367. line-height: 52px;
  368. font-size: 14px;
  369. text-align: center;
  370. position: relative;
  371. img {
  372. position: absolute;
  373. left: 0;
  374. }
  375. }
  376. }
  377. .proSet {
  378. display: flex;
  379. justify-content: center;
  380. // width: 260px;
  381. .settingStop {
  382. display: flex;
  383. // width: 260px;
  384. align-items: center;
  385. justify-content: center;
  386. .el-switch {
  387. margin-left: 26px;
  388. width: 88px;
  389. height: 25px;
  390. .el-switch__input {
  391. width: 88px;
  392. height: 25px;
  393. }
  394. .el-switch__core {
  395. width: 88px;
  396. height: 25px;
  397. border-radius: 13px;
  398. .el-switch__action {
  399. width: 41px;
  400. height: 21px;
  401. border-radius: 11px;
  402. img {
  403. width: 15px;
  404. height: 15px;
  405. }
  406. }
  407. }
  408. }
  409. .el-switch--small.is-checked .el-switch__core .el-switch__action {
  410. width: 41px;
  411. height: 21px;
  412. border-radius: 10px;
  413. left: calc(100% - 41px) !important;
  414. }
  415. .Settingitem {
  416. color: #fff;
  417. margin-left: 30px;
  418. width: 25px;
  419. height: 25px;
  420. cursor: pointer;
  421. }
  422. .rightIm {
  423. margin-right: 30px;
  424. }
  425. .downItem {
  426. position: relative;
  427. top: 7px;
  428. }
  429. }
  430. }
  431. }
  432. }
  433. }
  434. .themeDarks {
  435. border-bottom: 1px solid #3a3a3a;
  436. .proMenu {
  437. display: flex;
  438. align-items: center;
  439. .proButton {
  440. border-right: 1px solid #3a3a3a !important;
  441. .buttonItem {
  442. border-left: 1px solid #3a3a3a !important;
  443. }
  444. .changeBacksty {
  445. border-bottom: 3px solid #1c99ff !important;
  446. color: #1c99ff !important;
  447. }
  448. .defaultBacksty {
  449. color: #a2a3a4 !important;
  450. }
  451. .defaultweathersty {
  452. background-color: #0d68bc !important;
  453. }
  454. .defaultweatherRainsty {
  455. background-color: #4a5764 !important;
  456. }
  457. }
  458. .el-switch {
  459. .el-switch__core {
  460. background: #000;
  461. background-image: url("@/assets/images/headerCom/sun_B.png");
  462. background-repeat: no-repeat;
  463. background-position: 58px 2px;
  464. background-size: 20px;
  465. .el-switch__action {
  466. background: #1c99ff;
  467. }
  468. }
  469. }
  470. }
  471. }
  472. .themeLights {
  473. background: linear-gradient(90deg, #1f53b1, #6962b1) !important;
  474. border-bottom: 1px solid #7899ff;
  475. .proMenu {
  476. display: flex;
  477. align-items: center;
  478. .proButton {
  479. border-right: 1px solid #7899ff !important;
  480. .buttonItem {
  481. border-left: 1px solid #7899ff !important;
  482. }
  483. .changeBacksty {
  484. border-bottom: 3px solid #3dc2d3 !important;
  485. color: #fff !important;
  486. }
  487. .defaultBacksty {
  488. color: #b7c6ff !important;
  489. }
  490. .defaultweathersty {
  491. background-color: #0d68bc !important;
  492. }
  493. .defaultweatherRainsty {
  494. background-color: #4a5764 !important;
  495. }
  496. }
  497. .el-switch {
  498. .el-switch__core {
  499. background: #1e3f9a;
  500. background-image: url("@/assets/images/headerCom/moon_W.png");
  501. background-repeat: no-repeat;
  502. background-position: 8px 2px;
  503. background-size: 20px;
  504. .el-switch__action {
  505. background: #fff;
  506. }
  507. }
  508. }
  509. }
  510. }
  511. </style>