123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587 |
- <template>
- <div class="proheader" :class="!switchTheme ? 'themeDarks' : 'themeLights'">
- <el-container>
- <el-header :class="getStyle()">
- <div class="logoSty">
- <img src="../assets/logoGuo_DB1.png" alt="" />
- </div>
- <div class="proMenu">
- <div class="proButton">
- <div
- class="buttonItem"
- v-for="(item, index) in menuData"
- :key="index"
- :class="getColor(item.showBac)"
- @click="changeRoute(item)"
- >
- <img :src="headerMenuImg" alt="" v-if="item.showBac" />
- <span>{{ item.name }}</span>
- </div>
- </div>
- <div class="proSet">
- <div class="settingStop">
- <el-switch v-model="switchTheme" @change="changSwith">
- <template #active-action>
- <!-- <span class="custom-active-action">T</span> -->
- <img :src="moon_B" alt="" v-if="!switchTheme" />
- <img :src="sun_W" alt="" v-else />
- </template>
- <template #inactive-action>
- <!-- <span class="custom-inactive-action">F</span> -->
- <img :src="moon_B" alt="" v-if="!switchTheme" />
- <img :src="sun_B" alt="" v-else />
- </template>
- </el-switch>
- <el-tooltip
- class="box-item"
- effect="light"
- content="自动填报工具"
- >
- <!-- <a href="http://10.127.7.196:9001/script/download"> -->
- <!-- <a href="http://172.16.12.101:9001/script/download"> -->
- <a :href="`${headerReportUrl}:9001/script/download`">
- <img :src="header_wendang" class="Settingitem downItem" />
- </a>
- </el-tooltip>
- <el-tooltip class="box-item" effect="light" content="系统设置" v-if="userName === 'administrators'">
- <img :src="header_shezhi" class="Settingitem" @click="openSystemSet">
- </el-tooltip>
- <el-tooltip class="box-item" effect="light" content="退出">
- <img
- :src="header_dianyuan"
- class="Settingitem rightIm"
- @click="backLogin"
- />
- </el-tooltip>
- </div>
- </div>
- </div>
- </el-header>
- </el-container>
- </div>
- </template>
- <script>
- import httpRequest from "@/utils/request.js";
- import header_wendang from "@/assets/images/headerCom/zidongtianbao.png";
- import header_shezhi from "@/assets/images/headerCom/shezhi.png";
- import header_dianyuan from "@/assets/images/headerCom/guanji.png";
- import sun_W from "@/assets/images/headerCom/sun_W.png";
- import moon_B from "@/assets/images/headerCom/moon_B.png";
- import sun_B from "@/assets/images/headerCom/sun_B.png";
- import moon_W from "@/assets/images/headerCom/moon_W.png";
- import headerMenuImg from "@/assets/images/headerCom/headerMenu.png";
- import { Sunny, Moon } from "@element-plus/icons-vue";
- import { apiGetpersonalInformation } from "@/api/api";
- import { removeToken, removeUserKey, getUserKey } from "../utils/auth";
- export default {
- name: "headerCom",
- data() {
- return {
- SunnyIcon: Sunny,
- MoonIcon: Moon,
- sun_W: sun_W,
- sun_B: sun_B,
- moon_B: moon_B,
- moon_W: moon_W,
- headerMenuImg: headerMenuImg,
- header_wendang: header_wendang,
- header_shezhi: header_shezhi,
- header_dianyuan: header_dianyuan,
- leftIndex: "1",
- currentTime: "",
- showRole: true,
- menuData: [
- {
- index: "/home",
- icon: "Menu",
- name: "首页",
- showBac: true,
- },
- {
- index: "/generatingCap/dataFilter/prepare",
- icon: "Histogram",
- name: "发电能力分析",
- },
- {
- index: "/integratedAlarm/realwarning",
- icon: "Histogram",
- name: "综合报警",
- },
- {
- index: "/intelligentReport/gkjlb?name=xinzhuang",
- icon: "PictureFilled",
- name: "智能报表",
- },
- {
- index: "/powerPrediction/index",
- icon: "TrendCharts",
- name: "功率预测",
- },
- ],
- rainW: false,
- userName: "",
- switchTheme: false,
- headerReportUrl: "",
- };
- },
- created() {
- this.headerReportUrl = this.baseReportUrl;
- console.log("userkey==>>>", this.$store.state.userKey)
- const userKey = getUserKey()
- this.$store.commit("changeUserkey", userKey);
- let menuData = []
- if (userKey === "zz") {
- menuData = [
- {
- index: "/home",
- icon: "Menu",
- name: "首页",
- showBac: true,
- },
- {
- index: "/intelligentReport/gkjlb?name=xinzhuang",
- icon: "PictureFilled",
- name: "智能报表",
- },
- {
- index: "/powerPrediction/index",
- icon: "TrendCharts",
- name: "功率预测",
- }
- ]
- } else {
- menuData = this.menuData
- }
- this.menuData = menuData
- },
- mounted() {
- let that = this;
- this.switchTheme = JSON.parse(window.sessionStorage.getItem("theme"));
- this.$store.commit("changeTheme", this.switchTheme);
- this.$emit("swichFn", this.switchTheme);
- this.getThemeClass(this.switchTheme);
- let userMes = JSON.parse(window.sessionStorage.getItem("userMessage"));
- that.userName = userMes ? userMes.role : "administrators";
- if (this.$route.query.markKey) {
- that.userName = that.$route.query.userid;
- }
- if (userMes && userMes.role === "ordinaryUser") {
- that.showRole = false;
- }
- that.showHeader(that.$route);
- },
- watch: {
- $route: {
- handler: function (route) {
- this.showHeader(route);
- },
- immediate: true,
- },
- },
- methods: {
- changSwith(bool) {
- this.getThemeClass(bool);
- this.$emit("swichFn", bool);
- window.sessionStorage.setItem("theme", JSON.stringify(bool));
- this.$store.commit("changeTheme", bool);
- },
- getThemeClass(bool) {
- if (bool) {
- document.body.classList.remove("nsfStyle");
- if (!document.body.classList.contains("blueStyle")) {
- document.body.classList.add("blueStyle");
- }
- } else {
- document.body.classList.remove("blueStyle");
- if (!document.body.classList.contains("nsfStyle")) {
- document.body.classList.add("nsfStyle");
- }
- }
- },
- openSystemSet() {
- // let url = 'http://127.0.0.1:8009/login'
- let url = "http://172.16.12.101:7095/"
- window.open(url,"target")
- },
- showHeader(route) {
- this.menuData.forEach((it) => {
- if (route.path.indexOf("powerPrediction") > -1) {
- if (it.name === "功率预测") {
- it.showBac = true;
- } else {
- it.showBac = false;
- }
- } else if (route.path.indexOf("intelligentReport") > -1) {
- if (it.name === "智能报表") {
- it.showBac = true;
- } else {
- it.showBac = false;
- }
- } else if (route.path.indexOf("generatingCap") > -1) {
- if (it.name === "发电能力分析") {
- it.showBac = true;
- } else {
- it.showBac = false;
- }
- } else if (route.path.indexOf("integratedAlarm") > -1) {
- if (it.name === "综合报警") {
- it.showBac = true;
- } else {
- it.showBac = false;
- }
- } else if (route.path === "/home") {
- if (it.name === "首页") {
- it.showBac = true;
- } else {
- it.showBac = false;
- }
- } else {
- it.showBac = false;
- }
- });
- },
- changeRoute(item) {
- window.sessionStorage.setItem("headerRoute", item.index);
- let params = {};
- if (item.index.indexOf("intelligentReport") > -1) {
- params = {
- name: "xinzhuang",
- };
- }
- this.$router.push({
- path: item.index,
- query: params,
- });
- this.$emit("headerName", item.name);
- },
- // async backLogin() {
- // let loginName = this.userName
- // if (loginName) {
- // await this.LogoutInfor(loginName)
- // }
- // },
- backLogin() {
- window.sessionStorage.clear();
- removeToken();
- removeUserKey();
- // this.getThemeClass(true);
- // this.$emit("swichFn", true);
- this.$router.push({
- path: "/login",
- });
- },
- // 插入登出信息
- LogoutInfor(name) {
- let that = this;
- let onlyData = JSON.parse(window.sessionStorage.getItem("userDatamsg"));
- let loginData = JSON.parse(window.sessionStorage.getItem("loginMsg"));
- if (onlyData) {
- let paramsLogin = onlyData ? onlyData.identifier : loginData.identific;
- let params = {
- identifier: paramsLogin,
- loginName: name,
- };
- apiGetinsertLogoutInformation(params).then((datas) => {
- if (datas) {
- let url = location.origin + "/#/login";
- window.open(url, "_self");
- location.reload();
- removeToken();
- }
- });
- } else {
- let url = location.origin + "/#/login";
- window.open(url, "_self");
- location.reload();
- removeToken();
- }
- },
- getStyle() {
- if (this.$route.path === "/weather") {
- if (this.rainW) {
- return "weatherSty";
- } else {
- return "headerSty";
- }
- }
- },
- getColor(val) {
- let strWea = "";
- if (val) {
- strWea = "changeBacksty";
- } else {
- strWea = "defaultBacksty";
- }
- return strWea;
- },
- //获取个人信息
- getUserMes(id) {
- let params = {
- userId: id,
- };
- apiGetpersonalInformation(params).then((datas) => {
- window.sessionStorage.setItem(
- "userInfo",
- JSON.stringify(datas.data.user)
- );
- });
- },
- changeDate(date) {
- var y = date.getFullYear();
- var m = date.getMonth() + 1;
- m = m < 10 ? "0" + m : m;
- var d = date.getDate();
- d = d < 10 ? "0" + d : d;
- var h = date.getHours();
- h = h < 10 ? "0" + h : h;
- var minute = date.getMinutes();
- minute = minute < 10 ? "0" + minute : minute;
- var second = date.getSeconds();
- second = second < 10 ? "0" + second : second;
- return y + "-" + m + "-" + d + " " + h + ":" + minute + ":" + second;
- },
- nowTime() {
- let that = this;
- let date = new Date();
- this.statusTimer = setInterval(function () {
- var y = date.getFullYear();
- var m = date.getMonth() + 1;
- m = m < 10 ? "0" + m : m;
- var d = date.getDate();
- d = d < 10 ? "0" + d : d;
- var h = date.getHours();
- h = h < 10 ? "0" + h : h;
- var minute = date.getMinutes();
- minute = minute < 10 ? "0" + minute : minute;
- var second = date.getSeconds();
- second = second < 10 ? "0" + second : second;
- that.currentTime =
- y + "-" + m + "-" + d + " " + h + ":" + minute + ":" + second;
- }, 1000);
- },
- handleSelect(index) {
- if (this.leftIndex === index) return;
- this.leftIndex = index;
- // this.$router.push({path: index})
- console.log(index);
- },
- },
- };
- </script>
- <style lang="less">
- .proheader {
- position: relative;
- width: 100%;
- z-index: 1000;
- height: 50px;
- .weatherSty {
- background: rgb(74, 87, 100);
- }
- .el-header {
- padding: 0 10px;
- display: flex;
- justify-content: space-between;
- // background: rgb(13, 104, 188);
- // background: rgba(96,103,105,.75);
- color: #fff;
- line-height: 50px;
- height: 50px !important;
- .logoSty {
- padding: 8px 0 0 0;
- img {
- width: 310px;
- }
- }
- .proMenu {
- .proButton {
- display: flex;
- .buttonItem {
- cursor: pointer;
- width: 130px;
- height: 52px;
- line-height: 52px;
- font-size: 14px;
- text-align: center;
- position: relative;
- img {
- position: absolute;
- left: 0;
- }
- }
- }
- .proSet {
- display: flex;
- justify-content: center;
- // width: 260px;
- .settingStop {
- display: flex;
- // width: 260px;
- align-items: center;
- justify-content: center;
- .el-switch {
- margin-left: 26px;
- width: 88px;
- height: 25px;
- .el-switch__input {
- width: 88px;
- height: 25px;
- }
- .el-switch__core {
- width: 88px;
- height: 25px;
- border-radius: 13px;
- .el-switch__action {
- width: 41px;
- height: 21px;
- border-radius: 11px;
- img {
- width: 15px;
- height: 15px;
- }
- }
- }
- }
- .el-switch--small.is-checked .el-switch__core .el-switch__action {
- width: 41px;
- height: 21px;
- border-radius: 10px;
- left: calc(100% - 41px) !important;
- }
- .Settingitem {
- color: #fff;
- margin-left: 30px;
- width: 25px;
- height: 25px;
- cursor: pointer;
- }
- .rightIm {
- margin-right: 30px;
- }
- .downItem {
- position: relative;
- top: 7px;
- }
- }
- }
- }
- }
- }
- .themeDarks {
- border-bottom: 1px solid #3a3a3a;
- .proMenu {
- display: flex;
- align-items: center;
- .proButton {
- border-right: 1px solid #3a3a3a !important;
- .buttonItem {
- border-left: 1px solid #3a3a3a !important;
- }
- .changeBacksty {
- border-bottom: 3px solid #1c99ff !important;
- color: #1c99ff !important;
- }
- .defaultBacksty {
- color: #a2a3a4 !important;
- }
- .defaultweathersty {
- background-color: #0d68bc !important;
- }
- .defaultweatherRainsty {
- background-color: #4a5764 !important;
- }
- }
- .el-switch {
- .el-switch__core {
- background: #000;
- background-image: url("@/assets/images/headerCom/sun_B.png");
- background-repeat: no-repeat;
- background-position: 58px 2px;
- background-size: 20px;
- .el-switch__action {
- background: #1c99ff;
- }
- }
- }
- }
- }
- .themeLights {
- background: linear-gradient(90deg, #1f53b1, #6962b1) !important;
- border-bottom: 1px solid #7899ff;
- .proMenu {
- display: flex;
- align-items: center;
- .proButton {
- border-right: 1px solid #7899ff !important;
- .buttonItem {
- border-left: 1px solid #7899ff !important;
- }
- .changeBacksty {
- border-bottom: 3px solid #3dc2d3 !important;
- color: #fff !important;
- }
- .defaultBacksty {
- color: #b7c6ff !important;
- }
- .defaultweathersty {
- background-color: #0d68bc !important;
- }
- .defaultweatherRainsty {
- background-color: #4a5764 !important;
- }
- }
- .el-switch {
- .el-switch__core {
- background: #1e3f9a;
- background-image: url("@/assets/images/headerCom/moon_W.png");
- background-repeat: no-repeat;
- background-position: 8px 2px;
- background-size: 20px;
- .el-switch__action {
- background: #fff;
- }
- }
- }
- }
- }
- </style>
|