<template>
  <div class="fwgl_container">
    <side-nav-bar :nav-list="navList"></side-nav-bar>
    <div class="main_container">
      <router-view
        :key="'type_' + $route.params && $route.params.type"
      ></router-view>
    </div>
  </div>
</template>

<script>
import sideNavBar from "@/components/side-nav-bar";

export default {
  components: {
    sideNavBar,
  },
  data: () => ({
    navList: [],
    userLevel: 0,
  }),
  computed: {},
  methods: {},
  mounted() {
    this.navList = [
      // 普通用户
      {
        level: 0,
        name: "注册发布的服务",
        path: "/fwgl/list/0/注册发布的服务",
      },
      {
        level: 0,
        name: "申请的服务",
        path: "/fwgl/list/1/申请的服务",
      },
      {
        level: 0,
        name: "审批的服务",
        path: "/fwgl/list/2/审批的服务",
      },
      {
        level: 0,
        name: "云资源服务",
        path: "/fwgl/list/3/云资源服务",
      },
      // 组织管理员
      {
        level: 1,
        name: "组织服务管理",
        path: "/fwgl/list/4/组织服务管理",
      },
      {
        level: 1,
        name: "服务审批管理",
        path: "/fwgl/list/5/服务审批管理",
      },
      {
        level: 1,
        name: "云资源管理",
        path: "/fwgl/list/6/云资源管理",
      },
      // 超级管理员
      {
        level: 2,
        name: "平台服务管理",
        path: "/fwgl/list/7/平台服务管理",
      },
      {
        level: 2,
        name: "服务审批管理",
        path: "/fwgl/list/8/服务审批管理",
      },
      {
        level: 2,
        name: "云资源管理",
        path: "/fwgl/list/9/云资源管理",
      },
    ].filter((nav) => nav.level === this.userLevel);

    this.$router.push(this.navList[0].path);
  },
  /* updated() {
    if (this.$route.params && this.$route.params.type === undefined) {
      this.$router.push(this.navList[0].path);
    }
  }, */
};
</script>

<style scoped>
.fwgl_container {
  height: calc(100vh - 84px);
  display: flex;
  justify-content: flex-start;
  align-items: stretch;
}
.side_nav_bar {
  width: 180px;
  flex-shrink: 0;
}
.main_container {
  width: calc(100% - 180px);
  flex-grow: 1;
  flex-shrink: 1;
  background-color: #f6f7fb;
}
</style>
