Parcourir la source

新增课程数据累计时长和学生在线平均时长动态数据

zengyicheng il y a 1 an
Parent
commit
6202415b4d
1 fichiers modifiés avec 31 ajouts et 5 suppressions
  1. 31 5
      src/components/pages/dataBoard/course/index.vue

+ 31 - 5
src/components/pages/dataBoard/course/index.vue

@@ -115,11 +115,11 @@
           <div class="teafre" style="margin: 10px 0 0 0">
             <div class="teaLeft">
               <div>累计时长</div>
-              <div>15624小时</div>
+              <div>{{ allTime }}小时</div>
             </div>
             <div class="teaLeft teaRigth">
               <div>学生在线平均时长</div>
-              <div>268小时</div>
+              <div>{{ sumTime }}小时</div>
             </div>
           </div>
           <WorkTime
@@ -181,6 +181,9 @@ export default {
       themeArray: [],
       allArray: [],
       workNumList: [],
+      allTime: 0,
+      sumTime: 0,
+      studentNum: 0,
     };
   },
   mounted() {
@@ -263,13 +266,24 @@ export default {
       this.$forceUpdate();
     },
     typeChange1() {
+      var a = []
       if (this.lType == "grade") {
-        this.tedurArray = this.classList;
+        a = this.classList;
       } else if (this.lType == "subject") {
-        this.tedurArray = this.subjectList;
+        a = this.subjectList;
       } else {
-        this.tedurArray = this.themeList;
+        a = this.themeList;
       }
+      this.tedurArray = a;
+      var time = 0;
+      for(var i =0;i<a.length;i++){
+        if(a[i].time){
+          time += a[i].time;
+        }
+      }
+      this.allTime = time;
+      this.sumTime = Math.ceil(time / this.studentNum);
+      this.$forceUpdate();
     },
     getData() {
       this.isLoading = true;
@@ -295,6 +309,7 @@ export default {
           let _grade = res.data[3]; //年级
           let _subject = res.data[4]; //学科
           var _workCourse = res.data[7]; //带作业的课程
+          this.studentNum = res.data[8].length; //学生总数
           _subject.push({ name: "其他" });
           var cList = [];
           //将数据根据time里面的月份分成多个数组
@@ -452,6 +467,7 @@ export default {
           this.classList = classList;
           this.subjectList = subjectList;
           this.themeList = themeList;
+          var a = [];
           if (this.lType == "grade") {
             this.tedurArray = classList;
           } else if (this.lType == "subject") {
@@ -459,6 +475,16 @@ export default {
           } else {
             this.tedurArray = themeList;
           }
+          var time = 0;
+          a = this.tedurArray;
+          for(var i =0;i<a.length;i++){
+            if(a[i].time){
+              time += a[i].time;
+            }
+          }
+          this.allTime = time;
+          this.sumTime = Math.ceil(time / this.studentNum);
+
           this.typeCount =
             classList.length + subjectList.length + themeList.length;
           let _gradeArray = [];