Selaa lähdekoodia

修改未分组学生bug

nihao 5 vuotta sitten
vanhempi
commit
468b3c0624
1 muutettua tiedostoa jossa 12 lisäystä ja 8 poistoa
  1. 12 8
      src/views/class/index.vue

+ 12 - 8
src/views/class/index.vue

@@ -73,10 +73,10 @@ export default {
     isleftarrow: '',
     navShow: true,
   }),
-  created() {
-    this.searchInfo();
-    this.searchstu();
-    this.findGroup();
+  async created() {
+    await this.searchInfo();
+    await this.searchstu();
+    await this.findGroup();
   },
   computed: {
     ...mapState(['user']),
@@ -149,10 +149,14 @@ export default {
       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);
+        if (studentIds.length === 0) {
+          noGroupStudentNames.push(studentList[i].name);
+        } else {
+          // 循环有组学生id
+          for (let j = 0; j < studentIds.length; j++) {
+            if (studentList[i].id != studentIds[j]) {
+              noGroupStudentNames.push(studentList[i].name);
+            }
           }
         }
       }