Kaynağa Gözat

Merge branch 'master' of http://git.cc-lotus.info/new_train/train-student

lrf402788946 4 yıl önce
ebeveyn
işleme
22be57ff1e
2 değiştirilmiş dosya ile 41 ekleme ve 16 silme
  1. 26 2
      src/views/class/index.vue
  2. 15 14
      src/views/class/newClass/classGroup.vue

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

@@ -16,7 +16,7 @@
               </el-col>
             </el-tab-pane>
             <el-tab-pane label="班级分组" name="second">
-              <classGroup :groupList="groupList"></classGroup>
+              <classGroup :groupList="groupList" :stuIdAndGroupId="stuIdAndGroupId"></classGroup>
             </el-tab-pane>
           </el-tabs>
         </el-col>
@@ -59,6 +59,7 @@ export default {
       activeName: 'first',
       // 小组列表
       groupList: [],
+      stuIdAndGroupId: {},
       //学生列表
       studentList: [],
     };
@@ -83,11 +84,34 @@ export default {
     },
     // 查询小组
     async findGroup() {
+      let stuid = this.user.userid;
       let classid = this.user.classid;
       const res = await this.groupQuery({ classid });
       if (res.errcode === 0) {
-        console.log(res.data);
         this.$set(this, 'groupList', res.data);
+        // 登陆者所在组
+        // 组id
+        let groupId = '';
+        // 所有有组学生id
+        let studentIds = [];
+        var i = this.groupList.findIndex(value => {
+          var v = value.students.findIndex(value => {
+            studentIds.push(value.stuid);
+            return stuid === value.stuid;
+          });
+          return v != -1;
+        });
+        if (i != -1) {
+          groupId = this.groupList[i].id;
+        }
+        // 登录者id+組id
+        let stuIdAndGroupId = {
+          // 登陆者id
+          stuid: stuid,
+          // 登陆者属于哪个组id
+          groupId: groupId,
+        };
+        this.$set(this, 'stuIdAndGroupId', stuIdAndGroupId);
       }
     },
   },

+ 15 - 14
src/views/class/newClass/classGroup.vue

@@ -11,8 +11,20 @@
             <el-collapse accordion>
               <el-collapse-item>
                 <template slot="title">
-                  <el-col :span="2">{{ index + 1 }}.</el-col>
+                  <el-col :span="2" style="text-align:center;">{{ index + 1 }}.</el-col>
                   <el-col :span="6"> {{ item.name }} {{ item.students.length }}人</el-col>
+                  <el-col :span="24" v-if="item.status !== '1'">
+                    <el-col :span="2">
+                      <el-button v-if="item.students.length >= 10" type="danger" size="mini" disabled>已满员</el-button>
+                    </el-col>
+                    <el-col :span="6">
+                      <el-button type="danger" size="mini">删除</el-button>
+                    </el-col>
+                    <el-col :span="6">
+                      <el-button type="success" size="mini" v-if="stuIdAndGroupId.groupId === '' && item.students.length <= 10">加入</el-button>
+                      <el-button type="danger" size="mini" v-if="stuIdAndGroupId.groupId === item.id">退出</el-button>
+                    </el-col>
+                  </el-col>
                 </template>
                 <el-col :span="8" v-for="(groupStu, groupStuIndex) in item.students" :key="groupStuIndex">
                   <el-col :span="24">
@@ -37,22 +49,11 @@ export default {
   name: 'classGroup',
   props: {
     groupList: { type: Array },
+    stuIdAndGroupId: { type: Object },
   },
   components: {},
   data: function() {
-    return {
-      // groupList: [
-      //   {
-      //     name: '1组',
-      //     students: [
-      //       {
-      //         stuname: '顾红伟',
-      //         type: '1',
-      //       },
-      //     ],
-      //   },
-      // ],
-    };
+    return {};
   },
   created() {},
   methods: {},