소스 검색

日常开发

linxuxiang 6 달 전
부모
커밋
fc25f8379d
1개의 변경된 파일29개의 추가작업 그리고 43개의 파일을 삭제
  1. 29 43
      src/views/train/run.vue

+ 29 - 43
src/views/train/run.vue

@@ -4,7 +4,7 @@
     <Transition :enter-active-class="proxy?.animate.dialog.enter" :leave-active-class="proxy?.animate.dialog.leave">
       <div class="time" v-show="[42].includes(examState)">{{
         countdownNumFormat
-        }}</div>
+      }}</div>
     </Transition>
     <div class="main">
       <template v-if="isLongRun">
@@ -759,69 +759,55 @@ const close = (data: any) => {
 };
 
 /**
- * 将测试列表分页
+ * 长跑分页并按圈数排序
 */
 const testListArr: any = computed(() => {
-  let list: any = [];
-  let num = 8;
-  let myLength = Math.ceil(faceStudentList.value.length / num);
-  for (let i = 0; i < myLength; i++) {
-    list[i] = [];
-    for (let j = 0; j < faceStudentList.value.length; j++) {
-      if (j >= i * num && j < (i + 1) * num) {
-        list[i].push(faceStudentList.value[j])
-      }
-    }
-  }
-  console.log("111", list)
-  return list;
-});
-
-/**
-* 长跑名单
-*/
-const faceStudentListLongRun: any = computed(() => {
-  if (isLongRun.value) {
-    return false;
-  }
-  console.log("嘻嘻嘻0", faceStudentList.value)
+  // 按圈数分组排序
   let list = faceStudentList.value.filter((item: any) => {
     return item.student_id;
   });
-  //按圈数分组排序
-  let arr: any = [];
+  let myArr: any = [];
   JSON.parse(JSON.stringify(list)).forEach((item: any, index: number) => {
     let myIndex = 0;
     if (item.times != undefined) {
       myIndex = item.times.length;
     }
-    if (arr[myIndex] == undefined) {
-      arr[myIndex] = [];
+    if (myArr[myIndex] == undefined) {
+      myArr[myIndex] = [];
     }
-    arr[myIndex].push(item);
-    if (arr[myIndex]) {
-      arr[myIndex].sort((a: any, b: any) => {
+    myArr[myIndex].push(item);
+    if (myArr[myIndex]) {
+      myArr[myIndex].sort((a: any, b: any) => {
         let val1 = a.timeTotal;
         let val2 = b.timeTotal;
         return val1 - val2;
       });
     }
   })
-  console.log("嘻嘻嘻", arr);
-  if (arr.length) {
-    console.log("嘻嘻嘻1")
-    let myList = [];
-    for (let i = arr.length - 1; i >= 0; --i) {
-      if (arr.hasOwnProperty(i)) {
-        myList.push(...arr[i]);
+  let myList = [];
+  if (myArr.length) {
+    for (let i = myArr.length - 1; i >= 0; --i) {
+      if (myArr.hasOwnProperty(i)) {
+        myList.push(...myArr[i]);
       }
     }
-    console.log("嘻嘻嘻3", list)
-    return myList;
   } else {
-    console.log("嘻嘻嘻2", list)
-    return list;
+    myList = list;
+  }
+  // 分页
+  let myFaceStudentList = myList;
+  let arrList: any = [];
+  let num = 8;
+  let myLength = Math.ceil(myFaceStudentList.length / num);
+  for (let i = 0; i < myLength; i++) {
+    arrList[i] = [];
+    for (let j = 0; j < myFaceStudentList.length; j++) {
+      if (j >= i * num && j < (i + 1) * num) {
+        arrList[i].push(myFaceStudentList[j])
+      }
+    }
   }
+  return arrList;
 });
 
 onBeforeMount(() => {