<template>
  <div>
    <el-radio-group v-model="curTab" @input="goPage" style="margin-bottom: 20px;">
      <el-radio-button v-for="item in tabList" :key="item.id" :label="item.path">{{ item.name }}</el-radio-button>
    </el-radio-group>
    <router-view />
  </div>
</template>
<script>
export default {
  data(){
    return {
      tabList: [],
      curTab: '/permissionManagement/userList'
    }
  },
  watch: {
    '$route'() {
      this.getTabList();
    }
  },
  mounted() {
    this.getTabList();
  },
  methods: {
    getTabList(){
      this.tabList = [
        {id: '1', name: 'User List', path: '/permissionManagement/userList'},
        {id: '2', name: 'Role List', path: '/permissionManagement/roleList'},
        {id: '3', name: 'Resources Config', path: '/permissionManagement/resourceConfig'},
      ]
      this.curTab = this.tabList.filter(item => item.path === this.$route.path)[0]['path'];
    },
    goPage(tab) {
      this.$router.push(tab);
    }
  }
}
</script>
<style scoped>
</style>
