index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <div id="index">
  3. <el-row>
  4. <el-col :span="24" class="style">
  5. <el-col :span="24" class="top">
  6. <NavBar v-show="navShow" :title="title" :isleftarrow="isleftarrow"> </NavBar>
  7. </el-col>
  8. <el-col :span="24" class="main">
  9. <span v-if="display">
  10. <el-col :span="24" class="list" v-for="(item, index) in planList" :key="index" @click.native="toClass(item.id)">
  11. <p>计划年份:{{ item.year }}</p>
  12. <p>计划标题:{{ item.title }}</p>
  13. </el-col>
  14. </span>
  15. <span v-else>
  16. <el-col :span="24" class="list" v-for="(item, index) in classList" :key="index" @click.native="classBtn(item.id)">
  17. <p>班级时间:{{ item.startdate }}~{{ item.enddate }}</p>
  18. <p>第{{ item.term }}期-第{{ item.batch }}批</p>
  19. <p>
  20. 班级名称:{{ item.name }}<span style="margin-left:20px;">班级人数:{{ item.number }}</span>
  21. </p>
  22. </el-col>
  23. </span>
  24. </el-col>
  25. </el-col>
  26. </el-row>
  27. </div>
  28. </template>
  29. <script>
  30. import NavBar from '@/layout/common/topInfo.vue';
  31. import { mapState, createNamespacedHelpers, mapGetters } from 'vuex';
  32. const { mapActions: lesson } = createNamespacedHelpers('lesson');
  33. const { mapActions: trainplan } = createNamespacedHelpers('trainplan');
  34. const { mapActions: classes } = createNamespacedHelpers('classes');
  35. export default {
  36. name: 'index',
  37. props: {},
  38. components: {
  39. NavBar,
  40. },
  41. data: function() {
  42. return {
  43. title: '',
  44. isleftarrow: '',
  45. navShow: true,
  46. display: true,
  47. // 计划列表
  48. planList: [],
  49. // 计划id
  50. planId: '',
  51. classList: [],
  52. };
  53. },
  54. created() {
  55. this.search();
  56. },
  57. methods: {
  58. ...lesson({ lessionInfo: 'fetch', lessionlist: 'query' }),
  59. ...trainplan(['query']),
  60. ...classes({ classQuery: 'query' }),
  61. async search() {
  62. const planList = await this.query();
  63. this.$set(this, `planList`, planList.data);
  64. },
  65. async toClass(planid) {
  66. // index:计划id
  67. this.display = false;
  68. this.$set(this, `planId`, planid);
  69. const classList = await this.classQuery({ planid: planid, headteacherid: this.user.userid });
  70. this.$set(this, `classList`, classList.data);
  71. },
  72. classBtn(index) {
  73. // index:班级id
  74. sessionStorage.setItem('classid', index);
  75. this.$router.push({ path: '/home/index', query: { id: index } });
  76. },
  77. },
  78. computed: {
  79. ...mapState(['user']),
  80. },
  81. mounted() {
  82. this.title = this.$route.meta.title;
  83. this.isleftarrow = this.$route.meta.isleftarrow;
  84. },
  85. watch: {
  86. $route(to, from) {
  87. this.title = to.meta.title;
  88. this.isleftarrow = to.meta.isleftarrow;
  89. },
  90. },
  91. };
  92. </script>
  93. <style lang="less" scoped>
  94. .style {
  95. width: 100%;
  96. min-height: 667px;
  97. position: relative;
  98. background-color: #f9fafc;
  99. }
  100. .top {
  101. height: 46px;
  102. overflow: hidden;
  103. }
  104. .main {
  105. min-height: 570px;
  106. }
  107. .list {
  108. background: #fff;
  109. margin: 10px;
  110. width: 94%;
  111. padding: 10px;
  112. border-radius: 20px;
  113. }
  114. </style>