index.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. <el-tabs v-model="activeName">
  10. <el-tab-pane label="班级名单" name="first">
  11. <el-col :span="24">
  12. <el-button type="primary" size="mini">查看平时成绩</el-button>
  13. </el-col>
  14. <el-col :span="24">
  15. 班级名单
  16. </el-col>
  17. </el-tab-pane>
  18. <el-tab-pane label="班级分组" name="second">
  19. <classGroup :groupList="groupList" :stuIdAndGroupId="stuIdAndGroupId"></classGroup>
  20. </el-tab-pane>
  21. </el-tabs>
  22. </el-col>
  23. <el-col :span="24" class="foot">
  24. <footInfo></footInfo>
  25. </el-col>
  26. </el-col>
  27. </el-row>
  28. </div>
  29. </template>
  30. <script>
  31. import NavBar from '@/layout/common/topInfo.vue';
  32. import footInfo from '@/layout/common/footInfo.vue';
  33. // 班级分组
  34. import classGroup from './newClass/classGroup.vue';
  35. import { mapState, createNamespacedHelpers } from 'vuex';
  36. const { mapActions: group } = createNamespacedHelpers('group');
  37. export default {
  38. metaInfo: { title: '班级名单' },
  39. name: 'index',
  40. props: {},
  41. components: {
  42. NavBar, //头部导航
  43. footInfo, //底部导航
  44. // 班级分组
  45. classGroup,
  46. },
  47. data: function() {
  48. return {
  49. title: '',
  50. isleftarrow: '',
  51. navShow: true,
  52. // 班级信息
  53. // 头部标签
  54. activeName: 'second',
  55. // 小组列表
  56. groupList: [],
  57. stuIdAndGroupId: {},
  58. };
  59. },
  60. async created() {
  61. // 查看班级小组
  62. await this.findGroup();
  63. },
  64. methods: {
  65. ...group({ groupQuery: 'query' }),
  66. // 查询小组
  67. async findGroup() {
  68. let stuid = this.user.userid;
  69. let classid = this.user.classid;
  70. const res = await this.groupQuery({ classid });
  71. if (res.errcode === 0) {
  72. this.$set(this, 'groupList', res.data);
  73. // 登陆者所在组
  74. // 组id
  75. let groupId = '';
  76. // 所有有组学生id
  77. let studentIds = [];
  78. var i = this.groupList.findIndex(value => {
  79. var v = value.students.findIndex(value => {
  80. studentIds.push(value.stuid);
  81. return stuid === value.stuid;
  82. });
  83. return v != -1;
  84. });
  85. if (i != -1) {
  86. groupId = this.groupList[i].id;
  87. }
  88. // 登录者id+組id
  89. let stuIdAndGroupId = {
  90. // 登陆者id
  91. stuid: stuid,
  92. // 登陆者属于哪个组id
  93. groupId: groupId,
  94. };
  95. this.$set(this, 'stuIdAndGroupId', stuIdAndGroupId);
  96. }
  97. },
  98. },
  99. computed: {
  100. ...mapState(['user']),
  101. },
  102. mounted() {
  103. this.title = this.$route.meta.title;
  104. this.isleftarrow = this.$route.meta.isleftarrow;
  105. },
  106. watch: {
  107. $route(to, from) {
  108. this.title = to.meta.title;
  109. this.isleftarrow = to.meta.isleftarrow;
  110. },
  111. },
  112. };
  113. </script>
  114. <style lang="less" scoped>
  115. .style {
  116. width: 100%;
  117. min-height: 667px;
  118. position: relative;
  119. background-color: #f9fafc;
  120. }
  121. .top {
  122. height: 46px;
  123. overflow: hidden;
  124. }
  125. .main {
  126. min-height: 570px;
  127. }
  128. /deep/.el-tabs__header {
  129. margin: 0;
  130. }
  131. /deep/.el-tabs__nav {
  132. width: 100%;
  133. }
  134. /deep/.el-tabs__item {
  135. padding: 0;
  136. width: 50%;
  137. text-align: center;
  138. }
  139. .foot {
  140. height: 90px;
  141. overflow: hidden;
  142. }
  143. </style>