index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. <name-list :data="studentList"></name-list>
  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 nameList from './newClass/nameList.vue';
  36. import { mapState, createNamespacedHelpers } from 'vuex';
  37. const { mapActions: group } = createNamespacedHelpers('group');
  38. const { mapActions: student } = createNamespacedHelpers('student');
  39. export default {
  40. metaInfo: { title: '班级名单' },
  41. name: 'index',
  42. props: {},
  43. components: {
  44. NavBar, //头部导航
  45. footInfo, //底部导航
  46. // 班级分组
  47. classGroup,
  48. //班级名单
  49. nameList,
  50. },
  51. data: function() {
  52. return {
  53. title: '',
  54. isleftarrow: '',
  55. navShow: true,
  56. // 班级信息
  57. // 头部标签
  58. activeName: 'first',
  59. // 小组列表
  60. groupList: [],
  61. stuIdAndGroupId: {},
  62. //学生列表
  63. studentList: [],
  64. };
  65. },
  66. async created() {
  67. await this.toGetStudentList();
  68. // 查看班级小组
  69. await this.findGroup();
  70. },
  71. methods: {
  72. ...student({ getStudentList: 'query' }),
  73. ...group({ groupQuery: 'query' }),
  74. // 查学生
  75. async toGetStudentList() {
  76. const res = await this.getStudentList({ classid: this.user.classid });
  77. if (res) this.$set(this, `studentList`, res.data);
  78. },
  79. // 查询小组
  80. async findGroup() {
  81. let stuid = this.user.userid;
  82. let classid = this.user.classid;
  83. const res = await this.groupQuery({ classid });
  84. if (res.errcode === 0) {
  85. this.$set(this, 'groupList', res.data);
  86. // 登陆者所在组
  87. // 组id
  88. let groupId = '';
  89. // 所有有组学生id
  90. let studentIds = [];
  91. var i = this.groupList.findIndex(value => {
  92. var v = value.students.findIndex(value => {
  93. studentIds.push(value.stuid);
  94. return stuid === value.stuid;
  95. });
  96. return v != -1;
  97. });
  98. if (i != -1) {
  99. groupId = this.groupList[i].id;
  100. }
  101. // 登录者id+組id
  102. let stuIdAndGroupId = {
  103. // 登陆者id
  104. stuid: stuid,
  105. // 登陆者属于哪个组id
  106. groupId: groupId,
  107. };
  108. this.$set(this, 'stuIdAndGroupId', stuIdAndGroupId);
  109. }
  110. },
  111. },
  112. computed: {
  113. ...mapState(['user']),
  114. },
  115. mounted() {
  116. this.title = this.$route.meta.title;
  117. this.isleftarrow = this.$route.meta.isleftarrow;
  118. },
  119. watch: {
  120. $route(to, from) {
  121. this.title = to.meta.title;
  122. this.isleftarrow = to.meta.isleftarrow;
  123. },
  124. },
  125. };
  126. </script>
  127. <style lang="less" scoped>
  128. .style {
  129. width: 100%;
  130. min-height: 667px;
  131. position: relative;
  132. background-color: #f9fafc;
  133. }
  134. .top {
  135. height: 46px;
  136. overflow: hidden;
  137. }
  138. .main {
  139. min-height: 570px;
  140. }
  141. /deep/.el-tabs__header {
  142. margin: 0;
  143. }
  144. /deep/.el-tabs__nav {
  145. width: 100%;
  146. }
  147. /deep/.el-tabs__item {
  148. padding: 0;
  149. width: 50%;
  150. text-align: center;
  151. }
  152. .foot {
  153. height: 90px;
  154. overflow: hidden;
  155. }
  156. </style>