管道基础大数据平台系统开发-【前端】-新系統界面
Surpriseplus
2022-12-28 e63a6eb422d6a476e1f4d593d6514aa6916fedc1
src/components/navMenu.vue
@@ -2,45 +2,64 @@
  <div class="topMenu">
    <div class="logo"></div>
    <div class="headerTitle">
      <p class="textp1">管道基础大数据平台</p>
      <p class="textp2">Pipeline basic big data platform</p>
      <!-- <p class="textp1">管道基础大数据平台</p>
      <p class="textp2">Pipeline basic big data platform</p> -->
    </div>
    <div class="rightWrapper">
      <div class="rightMenu">
        <ul class="infinite-list menu_ul">
          <li
            @click="setMenuMove(index, item)"
            v-for="(item, index) in listMenu"
            class="infinite-list-item"
          >
            <div @click="setMenuMove(index, item)">
              <div
                class="menuImage"
                :class="changeSelectStyle == index ? item.checkClass : item.css"
              ></div>
              <div
                class="menulabel"
                :class="{ changeStyle: changeSelectStyle == index }"
              >
                {{ item.cnName }}
              </div>
            </div>
            <div
              class="menuImage"
              :class="changeSelectStyle == index ? item.checkClass : item.class"
            ></div>
            <div
              class="menulabel"
              :class="{ changeStyle: changeSelectStyle == index }"
              class="secondMenuDiv"
              v-show="item.show"
            >
              {{ item.label }}
              <div
                v-for="res in item.children"
                @click="setLiClick(res)"
                :class="{ changeLiStyle: changeliSelect == res.cnName }"
              >
                {{ res.cnName }}
              </div>
            </div>
          </li>
        </ul>
      </div>
      <div class="rightUser">
        <div @click="logOut" class="topdiv topUser">
        <div
          @click="logOut"
          class="topdiv topUser"
        >
          <div class="userImage user1"></div>
          <div class="userText">
            <span>{{ this.$store.state.uname }}</span>
            <el-link class="elLink">{{ $t('common.logout') }}</el-link>
          </div>
        </div>
        <div @click="switchLang" class="topdiv botLingo">
        <div
          @click="switchLang"
          class="topdiv botLingo"
        >
          <div class="userImage user2"></div>
          <div class="userText">Language</div>
        </div>
        <color-change></color-change>
      </div>
      <!-- -->
      <!-- <div class="menu"></div>
      <div class="userInfo">
        <img src="../assets/img/user.png" alt="" />
@@ -54,11 +73,13 @@
</template>
<script>
import { logout } from '@/api/api';
import { logout, selectMenuRecursive } from '@/api/api';
import { removeToken, getToken } from '@/utils/auth';
import customElMenu from '../components/customElMenu.vue';
import { queryMenuTree } from '../api/api';
import { queryMenuTree, getPerms } from '../api/api';
import colorChange from '../views/maintenance/colorChange.vue';
import { containsCoordinate } from 'ol/extent';
import Vue from 'vue';
export default {
  name: 'navMenu',
  //import引入的组件需要注入到对象中才能使用
@@ -85,89 +106,103 @@
      itemdetail: {},
      formLabelWidth: '70px',
      count: 5,
      changeSelectStyle: 5,
      changeSelectStyle: null,
      changeliSelect: null,
      changeSelectdiv: false,
      listMenu: [
        {
          label: '数据质检',
          class: 'm1',
          cnName: '数据质检',
          css: 'm1',
          checkClass: 'm11',
          url: '',
        },
        {
          label: '数据交换',
          class: 'm2',
          cnName: '数据交换',
          css: 'm2',
          checkClass: 'm21',
          url: '',
        },
        {
          label: '数据管理',
          class: 'm3',
          checkClass: 'm31',
          url: '',
        },
        {
          label: '服务管理',
          class: 'm4',
          cnName: '服务管理',
          css: 'm4',
          checkClass: 'm41',
          url: '',
        },
        {
          label: '综合展示',
          class: 'm5',
          checkClass: 'm51',
          url: '',
        },
        {
          label: '运维管理',
          class: 'm6',
          checkClass: 'm61',
          url: '',
        },
      ],
      showFlag: null,
    };
  },
  created() {},
  created() { },
  mounted() {
    this.getMenuTree();
  },
  computed: {
    // 我们使用计算属性来获取到当前点击的菜单的路由路径,然后设置default-active中的值
    // 使得菜单在载入时就能对应高亮
    // activeIndex() {
    //   const route = this.$route;
    //   const { meta, path } = route;
    //   // if set path, the sidebar will highlight the path you set
    //   // 可以在路由配置文件中设置自定义的路由路径到meta.activeMenu属性中,来控制菜单自定义高亮显示
    //   if (meta.activeMenu) {
    //     return meta.activeMenu;
    //   }
    //   return path;
    // },
  },
  computed: {},
  methods: {
    //主题切换
    setThemeColors() {
      // var value;
      // if (this.themeColor) {
      //   value = '#303030';
      // } else {
      //   value = '#409EFF';
      // }
      // localStorage.setItem('theme', value);
      // this.$store.commit('setSkin', value);
    async getCookies() {
      var boolean = this.getTimeCookies();
      if (boolean != true) {
        this.$router.push('/login');
        return;
      }
      if (this.$store.state.permsEntity.length == 0) {
        const data = await getPerms();
        this.$store.state.permsEntity = data.result;
      }
      this.$store.state.uname = JSON.parse(
        localStorage.getItem('LFToken')
      ).uname;
      this.$router.push('/');
    },
    getTimeCookies() {
      var time1 = new Date(JSON.parse(localStorage.getItem('LFToken')).time);
      var time2 = new Date();
      if (time2 > time1) {
        return false;
      } else {
        return true;
      }
    },
    //主题切换
    setThemeColors() { },
    //鼠标移入菜单事件
    setMenuMove(index, item) {
      this.$router.push(item.url);
      var that = this;
      if (item.perms != null) {
        this.$router.push(item.url);
        if (this.showFlag != null) {
          this.setShowFalseDiv(false);
          this.changeliSelect = '%%';
          this.showFlag = null;
        }
      } else {
        if (this.showFlag != index) {
          this.showFlag = index;
          this.setShowFalseDiv(true);
        } else {
          let newItem = this.listMenu[index];
          newItem.show = !this.listMenu[index].show;
          Vue.set(this.listMenu, index, newItem);
        }
      }
      this.changeSelectStyle = index;
    },
    async getMenuTree() {
      //获取目录树最大ID,新建节点使用
      // queryMaxId().then((res) => {
      //   this.id = res.data;
      // });
      //
    setShowFalseDiv(bolean) {
      var index = this.showFlag;
      let newItem = this.listMenu[index];
      newItem.show = bolean;
      Vue.set(this.listMenu, index, newItem);
    },
    setLiClick(res) {
      this.setShowFalseDiv(false);
      this.changeliSelect = res.cnName;
      this.$router.push(res.url);
      this.$store.commit('currentPerms', res.perms);
    },
    async getMenuTree() {
      this.getCookies();
      const data = await queryMenuTree();
      var that = this;
      if (data.code == 200) {
@@ -183,16 +218,25 @@
        }
      }
    },
    setMenuTree(res) {
      console.log(res);
      for (var i = 0; i < res.length; i++) {
        for (var j = 0; j < this.listMenu.length; j++) {
          if (this.listMenu[j].label == res[i].cnName) {
            this.listMenu[j].url = res[i].perms;
          }
    async setMenuTree(res) {
      for (var i in res) {
        res[i].checkClass = res[i].css + '1';
        res[i].show = false; //控制显隐
        if (res[i].perms == null) {
          const result = await selectMenuRecursive({ name: res[i].cnName });
          res[i].children = result.result.filter((value) => {
            return value.pid == res[i].id;
          });
          this.listMenu.push(res[i]);
          this.changeSelectStyle = this.listMenu.length - 1;
          var strartMneu = res[i].children[0];
          this.$store.commit('currentPerms', strartMneu.perms);
          this.changeliSelect = strartMneu.cnName;
          this.$bus.$emit('currentPerms', strartMneu.perms);
        } else {
          this.listMenu.push(res[i]);
        }
      }
      console.log(this.listMenu);
    },
    treeData(source) {
      let cloneData = JSON.parse(JSON.stringify(source)); // 对源数据深度克隆
@@ -354,51 +398,51 @@
        height: 70px;
      }
      .m1 {
        background: url('../assets/img/menu/menu11.png') no-repeat;
        background: url("../assets/img/menu/menu11.png") no-repeat;
        background-size: 100% 100%;
      }
      .m2 {
        background: url('../assets/img/menu/menu21.png') no-repeat;
        background: url("../assets/img/menu/menu21.png") no-repeat;
        background-size: 100% 100%;
      }
      .m3 {
        background: url('../assets/img/menu/menu31.png') no-repeat;
        background: url("../assets/img/menu/menu31.png") no-repeat;
        background-size: 100% 100%;
      }
      .m4 {
        background: url('../assets/img/menu/menu41.png') no-repeat;
        background: url("../assets/img/menu/menu41.png") no-repeat;
        background-size: 100% 100%;
      }
      .m5 {
        background: url('../assets/img/menu/menu51.png') no-repeat;
        background: url("../assets/img/menu/menu51.png") no-repeat;
        background-size: 100% 100%;
      }
      .m6 {
        background: url('../assets/img/menu/menu61.png') no-repeat;
        background: url("../assets/img/menu/menu61.png") no-repeat;
        background-size: 100% 100%;
      }
      .m11 {
        background: url('../assets/img/menu/menu12.png') no-repeat;
        background: url("../assets/img/menu/menu12.png") no-repeat;
        background-size: 100% 100%;
      }
      .m21 {
        background: url('../assets/img/menu/menu22.png') no-repeat;
        background: url("../assets/img/menu/menu22.png") no-repeat;
        background-size: 100% 100%;
      }
      .m31 {
        background: url('../assets/img/menu/menu32.png') no-repeat;
        background: url("../assets/img/menu/menu32.png") no-repeat;
        background-size: 100% 100%;
      }
      .m41 {
        background: url('../assets/img/menu/menu42.png') no-repeat;
        background: url("../assets/img/menu/menu42.png") no-repeat;
        background-size: 100% 100%;
      }
      .m51 {
        background: url('../assets/img/menu/menu52.png') no-repeat;
        background: url("../assets/img/menu/menu52.png") no-repeat;
        background-size: 100% 100%;
      }
      .m61 {
        background: url('../assets/img/menu/menu62.png') no-repeat;
        background: url("../assets/img/menu/menu62.png") no-repeat;
        background-size: 100% 100%;
      }
    }
@@ -421,11 +465,11 @@
          margin-right: 10px;
        }
        .user1 {
          background: url('../assets/img/user.png') no-repeat;
          background: url("../assets/img/user.png") no-repeat;
          background-size: 100% 100%;
        }
        .user2 {
          background: url('../assets/img/EN.png') no-repeat;
          background: url("../assets/img/EN.png") no-repeat;
          background-size: 100% 100%;
        }
        .userText {
@@ -463,25 +507,28 @@
    margin-top: 49px;
    margin-left: 120px;
    position: absolute;
    .textp1 {
      font-size: 36px;
      font-family: Microsoft YaHei;
      font-weight: bold;
      color: #ffffff;
      background: linear-gradient(0deg, #79a8ff 0%, #ffffff 100%);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
    }
    .textp2 {
      font-size: 9px;
      font-family: Microsoft YaHei;
      font-weight: 300;
      color: #ffffff;
      display: flex;
      background: linear-gradient(0deg, #79a8ff 0%, #ffffff 100%);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
    }
    width: 323px;
    height: 70px;
    background: url("../assets/img/LOGO.png") no-repeat center;
    // .textp1 {
    //   font-size: 36px;
    //   font-family: Microsoft YaHei;
    //   font-weight: bold;
    //   color: #ffffff;
    //   background: linear-gradient(0deg, #79a8ff 0%, #ffffff 100%);
    //   -webkit-background-clip: text;
    //   -webkit-text-fill-color: transparent;
    // }
    // .textp2 {
    //   font-size: 9px;
    //   font-family: Microsoft YaHei;
    //   font-weight: 300;
    //   color: #ffffff;
    //   display: flex;
    //   background: linear-gradient(0deg, #79a8ff 0%, #ffffff 100%);
    //   -webkit-background-clip: text;
    //   -webkit-text-fill-color: transparent;
    // }
  }
  .elLink {
    margin-left: 5px;
@@ -507,5 +554,30 @@
    color: #2e95fb !important;
    background: linear-gradient(#112f57, #122344) !important;
  }
  .secondMenuDiv {
    position: absolute;
    z-index: 1024;
    margin-top: 10px;
    border: 1px solid white;
    border-radius: 5px;
    div {
      line-height: 30px;
      background: #303030;
      padding: 10px;
      font-size: 18px;
      font-family: Microsoft YaHei;
      font-weight: 400;
      color: #ffffff;
      line-height: 49px;
      width: 100px;
    }
    .changeLiStyle {
      color: #fec801;
      background: linear-gradient(180deg, #002992, #080472);
    }
  }
}
</style>