<template>
  <div class="fwgl_container">
    <side-nav-bar
      :nav-list="navList"
      :title-path="navList[0] && navList[0].path"
    ></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: [],
  }),
  watch: {
    "$route.fullPath"(path) {
      this.initNavList();
    },
  },
  methods: {
    initNavList() {
      let level = parseInt(this.$route.params.level);

      // 普通用户
      if (level == 0) {
        this.navList = [
          {
            name: "注册发布的服务",
            path: `/fwgl/list/${level}/0`,
          },
          {
            name: "申请的服务",
            path: `/fwgl/list/${level}/1`,
          },
          {
            name: "审批的服务",
            path: `/fwgl/list/${level}/2`,
          },
          {
            name: "云资源服务",
            path: `/fwgl/list/${level}/3`,
          },
        ];
      }
      // 组织管理员
      else if (level == 1) {
        this.navList = [
          {
            name: "组织服务管理",
            path: `/fwgl/list/${level}/0`,
          },
          {
            name: "服务审批管理",
            path: `/fwgl/list/${level}/1`,
          },
          {
            name: "云资源管理",
            path: `/fwgl/list/${level}/2`,
          },
        ];
      }
      // 超级管理员
      else if (level == 2) {
        this.navList = [
          {
            name: "平台服务管理",
            path: `/fwgl/list/${level}/0`,
          },
          {
            name: "服务审批管理",
            path: `/fwgl/list/${level}/1`,
          },
          {
            name: "云资源管理",
            path: `/fwgl/list/${level}/2`,
          },
        ];
      }
    },
  },
  mounted() {
    this.initNavList();
  },
};
</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;
  overflow: auto;
}
</style>
