Browse Source

创建小组完成未测试

nihao 5 years ago
parent
commit
e6a79cc59c

+ 3 - 1
src/layout/class/classGroup.vue

@@ -7,8 +7,9 @@
       <el-col :span="24">
         <groupList :groupList="groupList" v-on="$listeners" :stuIdAndGroupId="stuIdAndGroupId"></groupList>
       </el-col>
+
       <el-col :span="24" class="foot">
-        <noGroup></noGroup>
+        <noGroup v-if="stuIdAndGroupId.type === '班长'" :noGroupStudentNames="noGroupStudentNames"></noGroup>
       </el-col>
     </el-row>
     <el-dialog class="createGroup" title="创建小组" :visible.sync="dialogFormVisible" width="100%">
@@ -39,6 +40,7 @@ export default {
   props: {
     groupList: null,
     stuIdAndGroupId: null, //登陆者id和小组id
+    noGroupStudentNames: null, //没有小组的学生
   },
   components: {
     groupList,

+ 2 - 1
src/layout/class/classList.vue

@@ -12,7 +12,7 @@
             </span>
           </van-tab>
           <van-tab title="班级分组">
-            <classGroup :groupList="groupList" v-on="$listeners" :stuIdAndGroupId="stuIdAndGroupId"></classGroup>
+            <classGroup :groupList="groupList" v-on="$listeners" :stuIdAndGroupId="stuIdAndGroupId" :noGroupStudentNames="noGroupStudentNames"></classGroup>
           </van-tab>
         </van-tabs>
       </el-col>
@@ -33,6 +33,7 @@ export default {
     stuNameList: null, //学生看班级学生名单
     groupList: null,
     stuIdAndGroupId: null, //登陆者id和小组id
+    noGroupStudentNames: null, //没有小组的学生
   },
   components: {
     // 显示班级学生名称(带有职务)

+ 1 - 1
src/layout/class/groupList.vue

@@ -6,7 +6,7 @@
           <el-collapse-item>
             <template slot="title">
               <el-col :span="2" class="groupName">{{ index + 1 }}.</el-col>
-              <el-col :span="5" class="groupName"> {{ item.name }} </el-col>
+              <el-col :span="5" class=""> {{ item.name }} {{ item.students.length }}人</el-col>
               <el-col :span="4" class="groupName">
                 <el-button v-if="item.students.length >= 10" round plain type="danger" size="mini" disabled>已满员</el-button>
               </el-col>

+ 6 - 11
src/layout/class/noGroup.vue

@@ -1,16 +1,11 @@
 <template>
   <div id="noGroup">
     <el-row>
-      <el-col :span="24">未分组学生</el-col>
-      <el-col :span="6">顾宏伟</el-col>
-      <el-col :span="6">顾宏伟</el-col>
-      <el-col :span="6">顾宏伟</el-col>
-      <el-col :span="6">顾宏伟</el-col>
-      <el-col :span="6">顾宏伟</el-col>
-      <el-col :span="6">顾宏伟</el-col>
-      <el-col :span="6">顾宏伟</el-col>
-      <el-col :span="6">顾宏伟</el-col>
-      <el-col :span="6">顾宏伟</el-col>
+      <el-col :span="24"><el-link type="primary" :underline="false">未分组学生</el-link></el-col>
+
+      <el-col :span="6" class="list" v-for="(item, index) in noGroupStudentNames" :key="index">
+        {{ item }}
+      </el-col>
     </el-row>
   </div>
 </template>
@@ -19,7 +14,7 @@
 export default {
   name: 'noGroup',
   props: {
-    noGroupList: null,
+    noGroupStudentNames: null,
   },
   components: {},
   data: () => ({}),

+ 25 - 2
src/views/class/index.vue

@@ -21,6 +21,7 @@
             @deleteGroup="deleteGroup"
             @joinGroup="joinGroup"
             :stuIdAndGroupId="stuIdAndGroupId"
+            :noGroupStudentNames="noGroupStudentNames"
           ></classList>
         </el-col>
         <el-col :span="24" class="foot">
@@ -36,7 +37,8 @@ import NavBar from '@/layout/common/topInfo.vue';
 import footInfo from '@/layout/common/footInfo.vue';
 import classList from '@/layout/class/classList.vue';
 import { createNamespacedHelpers, mapGetters } from 'vuex';
-const { mapActions: mapQuestion } = createNamespacedHelpers('group');
+const { mapActions: mapGroup } = createNamespacedHelpers('group');
+const { mapActions: mapStudent } = createNamespacedHelpers('student');
 let site = JSON.parse(sessionStorage.getItem('site'));
 const termid = site.termid;
 const batchid = site.batchid;
@@ -94,6 +96,7 @@ export default {
     ],
     groupList: [],
     stuIdAndGroupId: '',
+    noGroupStudentNames: '',
     title: '',
     isleftarrow: '',
     transitionName: 'fade',
@@ -123,7 +126,8 @@ export default {
     outAssignShow() {
       this.assignShow = false;
     },
-    ...mapQuestion(['query', 'create', 'delete', 'insert', 'exit']),
+    ...mapGroup(['query', 'create', 'delete', 'insert', 'exit']),
+    ...mapStudent({ stuQery: 'query' }),
     // 查询小组列表
     async findList() {
       let data = {};
@@ -136,8 +140,11 @@ export default {
       // 找出登陆者在哪个组
       // 找出组id
       let groupId = '';
+      // 所有有组学生id
+      let studentIds = [];
       var i = groupList.findIndex(value => {
         var v = value.students.findIndex(value => {
+          studentIds.push(value.stuid);
           return stuid === value.stuid;
         });
         return v != -1;
@@ -153,6 +160,22 @@ export default {
       // 登陆者身份是否为班长
       stuIdAndGroupId.type = type;
       this.$set(this, 'stuIdAndGroupId', stuIdAndGroupId);
+      // 所有学生
+      let studentList = await this.stuQery(data);
+      studentList = studentList.data;
+      // 没有组的学生名字
+      let noGroupStudentNames = [];
+      // 循环所有学生id
+      for (let i = 0; i < studentList.length; i++) {
+        // 循环有组学生id
+        for (let j = 0; j < studentIds.length; j++) {
+          if (studentList[i].id != studentIds[j]) {
+            noGroupStudentNames.push(studentList[i].name);
+          }
+        }
+      }
+      // 未分组学生id(studentIds(有组学生id))(studentList所有学生)(noGroupStudentNames没有组的学生名字)
+      this.$set(this, 'noGroupStudentNames', noGroupStudentNames);
     },
     // 创建小组
     async saveGroup({ data }) {