index.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <template>
  2. <main class="main-container">
  3. <keep-alive>
  4. <component :is="currentTabComponent" />
  5. </keep-alive>
  6. </main>
  7. </template>
  8. <script>
  9. import TaskList from './TaskList.vue';
  10. import TemplateList from './TemplateList.vue';
  11. import CurriculaListStudent from './curricula_list/student.vue';
  12. import CurriculaListTeacher from './curricula_list/teacher.vue';
  13. export default {
  14. components: {
  15. TaskList,
  16. TemplateList,
  17. CurriculaListStudent,
  18. CurriculaListTeacher
  19. },
  20. provide() {
  21. return {
  22. changeTab: this.changeTab
  23. };
  24. },
  25. data() {
  26. const state = this.$store.state;
  27. let popedom_code_list = state.user.popedom_code_list;
  28. let isStudent = state.user.user_type === 'STUDENT';
  29. function curTab() {
  30. return isStudent || popedom_code_list.includes(2000001) ? 'TaskList' : 'TemplateList';
  31. }
  32. let currentTab = this.$route.query.tab || curTab();
  33. return {
  34. currentTab
  35. };
  36. },
  37. computed: {
  38. currentTabComponent() {
  39. if (['TemplateList', 'TaskList'].includes(this.currentTab)) return this.currentTab;
  40. return `${this.currentTab}${this.$store.state.user.user_type === 'TEACHER' ? 'Teacher' : 'Student'}`;
  41. }
  42. },
  43. methods: {
  44. changeTab(tab) {
  45. this.currentTab = tab;
  46. }
  47. }
  48. };
  49. </script>
  50. <style lang="scss" scoped>
  51. @import '~@/styles/mixin';
  52. .main-container {
  53. @include container;
  54. }
  55. </style>