管道基础大数据平台系统开发-【前端】-新系統界面
Surpriseplus
2022-11-19 5aa3a9bdd9001e53f245efd40b0d39263caa4bfc
src/components/navMenu.vue
@@ -29,7 +29,10 @@
      <div class="rightUser">
        <div @click="logOut" class="topdiv topUser">
          <div class="userImage user1"></div>
          <div class="userText"><span>admin</span>注销</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 class="userImage user2"></div>
@@ -54,7 +57,7 @@
import { logout } from '@/api/api';
import { removeToken, getToken } from '@/utils/auth';
import customElMenu from '../components/customElMenu.vue';
import { queryMenuTree, getPerms } from '../api/api';
import { queryMenuTree } from '../api/api';
import colorChange from '../views/maintenance/colorChange.vue';
export default {
  name: 'navMenu',
@@ -88,37 +91,43 @@
          label: '数据质检',
          class: 'm1',
          checkClass: 'm11',
          url: '',
        },
        {
          label: '数据交换',
          class: 'm2',
          checkClass: 'm21',
          url: '',
        },
        {
          label: '数据管理',
          class: 'm3',
          checkClass: 'm31',
          url: '',
        },
        {
          label: '服务管理',
          class: 'm4',
          checkClass: 'm41',
          url: '',
        },
        {
          label: '综合展示',
          class: 'm5',
          checkClass: 'm51',
          url: '',
        },
        {
          label: '运维管理',
          class: 'm6',
          checkClass: 'm61',
          url: '',
        },
      ],
    };
  },
  created() {},
  mounted() {
    this.getUserPerms();
    this.getMenuTree();
  },
  computed: {
@@ -149,29 +158,41 @@
    },
    //鼠标移入菜单事件
    setMenuMove(index, item) {
      this.$router.push(item.url);
      this.changeSelectStyle = index;
    },
    getMenuTree() {
    async getMenuTree() {
      //获取目录树最大ID,新建节点使用
      // queryMaxId().then((res) => {
      //   this.id = res.data;
      // });
      // 获取目录树数据
      queryMenuTree().then((res) => {
        if (res.code == 200) {
          if (res.result.length != 0) {
            let menuLists = res.result.filter((value) => {
              return value.pid == 1;
            });
            // console.log(menuLists);
            this.menuList = menuLists;
          } else {
            alert('暂无菜单栏数据');
          }
      //
      const data = await queryMenuTree();
      var that = this;
      if (data.code == 200) {
        if (data.result.length != 0) {
          let menuLists = data.result.filter((value) => {
            return value.pid == 1;
          });
          that.menuList = menuLists;
          that.setMenuTree(menuLists);
        } else {
          console.log('接口报错');
          alert('暂无菜单栏数据');
        }
      });
      }
    },
    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;
          }
        }
      }
      console.log(this.listMenu);
    },
    treeData(source) {
      let cloneData = JSON.parse(JSON.stringify(source)); // 对源数据深度克隆
@@ -250,11 +271,6 @@
        this.$router.push(index);
      }
    },
    getUserPerms() {
      getPerms().then((res) => {
        if (res.code == 200) this.$store.commit('getPermsEntity', res.result);
      });
    },
  },
  watch: {
    $route() {
@@ -284,9 +300,9 @@
  .logo {
    width: 80px;
    height: 80px;
    margin-left: 30px;
    margin-top: 33px;
    background: url('../assets/img/图层 34.png') no-repeat 100% 100%;
    // margin-left: 30px;
    // margin-top: 33px;
    // background: url('../assets/img/图层 34.png') no-repeat 100% 100%;
  }
  // .rightWrapper {
  //   width: 70%;
@@ -414,6 +430,7 @@
        }
        .userText {
          font-size: 15px;
          width: 150px;
          font-family: Microsoft YaHei;
          font-weight: 400;
          color: #ffffff;
@@ -466,5 +483,16 @@
      -webkit-text-fill-color: transparent;
    }
  }
  .elLink {
    margin-left: 5px;
    font-size: 15px;
    margin-bottom: 4px;
  }
  /deep/.el-link.el-link--default:hover {
    color: #409eff !important;
  }
  /deep/ .el-link.el-link--default {
    color: white !important;
  }
}
</style>