<template>
  <div class="body">
    <div class="top">
      <div class="title">CocoClass后台管理</div>
      <div class="person">
        <div class="person_name">{{ userinfo ? userinfo.username : "" }}</div>
        <el-button type="text" @click="handleLogout" style="margin-left: 20px">退出</el-button>
      </div>
    </div>
    <div class="container">
      <div class="left">
        <ul>
          <template v-if="allowedIds.indexOf(userinfo.userid) == -1">
              <router-link class="menu_left" to="/user-list">
                <i class="el-icon-s-custom"></i>账号列表
              </router-link>
              <router-link class="menu_left" to="/user-examine">
                <i class="el-icon-edit"></i>账号审核
              </router-link>
              <router-link class="menu_left" to="/organ-list">
                <i class="el-icon-office-building"></i>组织列表
              </router-link>
              <router-link class="menu_left" to="/school-list">
                <i class="el-icon-school"></i>学校列表
              </router-link>
              <!-- <router-link class="menu_left" to="/version-add">
                <i class="el-icon-office-building"></i>版本更新
              </router-link> -->
              <router-link class="menu_left" to="/desktopTool-list" v-show="userinfo.userid != '0abcb118-9110-11eb-80ad-005056b86db5'">
                <i class="el-icon-s-grid"></i>工具列表
              </router-link>
              <router-link class="menu_left" to="/suffix-list" v-show="userinfo.userid != '0abcb118-9110-11eb-80ad-005056b86db5'">
                <i class="el-icon-s-grid"></i>后缀管理
              </router-link>
          </template>
          
           <router-link class="menu_left" to="/instupdata">
						<i class="el-icon-s-grid"></i>ai6说明文件
					</router-link>
        </ul>
      </div>
      <div class="table-container">
        <router-view></router-view>
      </div>
    </div>
  </div>
</template>

<script>
import { mapGetters, mapActions } from 'vuex';
import { loginOut } from '@/api/user';

export default {
  name: "HomeView",
  computed: {
    ...mapGetters(['userinfo']),
  },
  data(){
    return {
      allowedIds: [
            // "0abcb118-9110-11eb-80ad-005056b86db5", //牛倩楠
            // "b7ccc834-aae5-11ea-a8d4-52540005ab01", //徐嘉伟
            // "a77e9404-efec-11e9-96f9-028edca3b798", //徐嘉伟
            // "0e8d50c3-50b5-2f1c-9f1a-bd346a0bf817", //tony
            // "5943e08c-b7d4-11ed-8d51-005056b86db5", //cs1111
						// "6c56ec0e-2c74-11ef-bee5-005056b86db5", //qgt
            // "3efa8590-1719-11ef-ade9-005056b86db5", //赵尚纯
            "d248c21c-50fc-11ed-8c78-005056b86db5", //李毓竹
            "d248c8cf-50fc-11ed-8c78-005056b86db5", //程鹏
            "d248cbe2-50fc-11ed-8c78-005056b86db5", //兰薇
            "b7bd1863-2f87-11ef-bf55-005056b86db5", //黄丽惠
            "bfbe1913-2f87-11ef-bf55-005056b86db5",//彭晓彬
            "c52be2c7-9819-11ef-9b30-005056b86db5", //陈惠雯
          ]
    }
  },
  methods: {
    ...mapActions({
      logout: 'user/logout'
    }),
    async handleLogout() {
      this.$confirm('确定退出吗', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(async () => {
        loginOut()
          .then(async () => {
            this.$message({
              message: '退出成功',
              type: 'success'
            });
            await this.logout();
            this.$router.push('/login');
          })
          .catch(err => {
            console.error(err);
          });
      }).catch(() => {
        // 取消操作
      });
    }
  },
  mounted() {
    if (this.allowedIds.indexOf(this.userinfo.userid) != -1) {
      console.log('ai6');
      this.$router.push('/instupdata')
    }
  },
};
</script>

<style scoped>
.body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}
.top {
  width: 100%;
  height: 50px;
  background-color: #ffffff;
  display: flex;
  align-items: center;
  padding: 0 20px;
  box-sizing: border-box;
}
.top > .title {
  font-weight: bold;
  font-size: 20px;
  line-height: 40px;
}
.person {
  margin-left: auto;
  display: flex;
  align-items: center;
}
.person > .person_name {
  font-size: 15px;
  color: black;
  font-weight: 400;
}
.container {
  display: flex;
  width: 100%;
  height: calc(100% - 50px);
  overflow: hidden;
}
.table-container {
  width: calc(100% - 180px);
  overflow: hidden;
  height: 100%;
}
.left {
  width: 180px;
  height: 100%;
  background-color: #ffffff;
  display: flex;
  flex-direction: column;
  border: 5px;
  align-items: center;
}
.left ul {
  width: 100%;
  background-color: #ffffff;
}
.menu_left {
  width: 100%;
  height: 50px;
  text-decoration: none;
  color: rgb(154, 154, 154);
  background-color: #ffffff;
  line-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.menu_left > i {
  margin-right: 10px;
}
.router-link-active {
  background-color: #3d67bc;
  color: rgb(255, 255, 255);
}
.router-link-exact-active {
  background-color: #3d67bc;
  color: rgb(255, 255, 255);
}
</style>