lsc 1 年之前
父节点
当前提交
e0f725faad

+ 55 - 29
src/components/pages/dataBoardNew/school/courseNum/index.vue

@@ -18,6 +18,11 @@ export default {
   components: {
     highcharts: Chart,
   },
+  props: {
+    weekCourse2: {
+      type: Array,
+    },
+  },
   data() {
     return {
       chartObj: null,
@@ -32,26 +37,26 @@ export default {
           text: null
         },
         credits: {
-            enabled: false//不显示LOGO
+          enabled: false//不显示LOGO
         },
         xAxis: {
           categories: [
-            '一年级',
-            '二年级',
-            '三年级'
           ]
         },
         yAxis: [{
+          allowDecimals: false,
           min: 0,
           title: {
             text: '课程总数'
           }
-        }, {
-          title: {
-            text: '项目总数'
-          },
-          opposite: true
-        }],
+        },
+          // {
+          //   title: {
+          //     text: '项目总数'
+          //   },
+          //   opposite: true
+          // }
+        ],
         legend: {
           shadow: false
         },
@@ -68,30 +73,32 @@ export default {
         series: [{
           name: '上周课程总数',
           color: 'rgba(165,170,217,1)',
-          data: [150, 73, 20],
+          data: [],
           pointPadding: 0.3, // 通过 pointPadding 和 pointPlacement 控制柱子位置
-          pointPlacement: -0.2
+          // pointPlacement: -0.2
         }, {
           name: '本周课程总数',
           color: 'rgba(126,86,134,.9)',
-          data: [140, 90, 40],
-          pointPadding: 0.4,
-          pointPlacement: -0.2
-        }, {
-          name: '上周项目总数',
-          color: 'rgba(248,161,63,1)',
-          data: [153, 178, 195],
-          pointPadding: 0.3,
-          pointPlacement: 0.2,
-          yAxis: 1  // 指定数据列所在的 yAxis
-        }, {
-          name: '本周项目总数',
-          color: 'rgba(186,60,61,.9)',
-          data: [203, 198, 208],
+          data: [],
           pointPadding: 0.4,
-          pointPlacement: 0.2,
-          yAxis: 1
-        }]
+          // pointPlacement: -0.2
+        },
+          //  {
+          //   name: '上周项目总数',
+          //   color: 'rgba(248,161,63,1)',
+          //   data: [153, 178, 195],
+          //   pointPadding: 0.3,
+          //   pointPlacement: 0.2,
+          //   yAxis: 1  // 指定数据列所在的 yAxis
+          // }, {
+          //   name: '本周项目总数',
+          //   color: 'rgba(186,60,61,.9)',
+          //   data: [203, 198, 208],
+          //   pointPadding: 0.4,
+          //   pointPlacement: 0.2,
+          //   yAxis: 1
+          // }
+        ]
       }
     };
   },
@@ -109,10 +116,29 @@ export default {
         // this.chartObj.setOption(this.option);
       });
     },
+    setArray(array) {
+      this.option.xAxis.categories = []
+      this.option.series[0].data = []
+      this.option.series[1].data = []
+      for (var i = 0; i < array.length; i++) {
+        this.option.xAxis.categories.push(array[i].name)
+        this.option.series[0].data.push(array[i].lastCourse)
+        this.option.series[1].data.push(array[i].toCourse)
+      }
+    }
   },
   watch: {
+    weekCourse2: {
+      immediate: true,
+      deep: true,
+      handler(newValue, oldValue) {
+        this.setArray(newValue)
+        this.$forceUpdate();
+      },
+    },
   },
   mounted() {
+    this.setArray(this.weekCourse2)
     // this.setChart();
 
   },

+ 109 - 26
src/components/pages/dataBoardNew/school/index.vue

@@ -132,7 +132,7 @@
         </div>
         <div class="dataBox">
           <teacherInfo v-if="courseType == 0" style="height: calc(100%)" :courseArray="courseArray"></teacherInfo>
-          <courseNum v-if="courseType == 1" style="height: calc(100%)"></courseNum>
+          <courseNum v-if="courseType == 1" style="height: calc(100%)" :weekCourse2="weekCourse2"></courseNum>
           <div style="height: calc(100%)" v-if="courseType == 2">
             <div class="info_box" style="width: 96%;">
               <div class="info blueBG" style="width:calc(100% / 4 - 10px)">
@@ -181,7 +181,7 @@
               <span>上传课程</span>
               <div>
                 <el-progress :width="80" type="circle"
-                  :percentage="this.lightJson.upCourseTeachers ? (this.lightJson.upCourseTeachers / this.lightJson.teachers * 100).toFixed(0) : 0"
+                  :percentage="lightJson.upCourseTeachers ? parseInt((lightJson.upCourseTeachers / lightJson.teachers * 100).toFixed(0)) : 0"
                   :stroke-width="5" :format="format" color="rgb(64, 149, 229)"></el-progress>
               </div>
             </div>
@@ -189,7 +189,7 @@
               <span>上传项目</span>
               <div>
                 <el-progress :width="80" type="circle"
-                  :percentage="this.lightJson.upSCourseTeachers ? (this.lightJson.upSCourseTeachers / this.lightJson.teachers * 100).toFixed(0) : 0"
+                  :percentage="lightJson.upSCourseTeachers ? parseInt((lightJson.upSCourseTeachers / lightJson.teachers * 100).toFixed(0)) : 0"
                   :stroke-width="5" :format="format" color="rgb(64, 149, 229)"></el-progress>
               </div>
             </div>
@@ -197,7 +197,7 @@
               <span>使用工具</span>
               <div>
                 <el-progress :width="80" type="circle"
-                  :percentage="this.lightJson.toolTeachers ? (this.lightJson.toolTeachers / this.lightJson.teachers * 100).toFixed(0) : 0"
+                  :percentage="lightJson.toolTeachers ? parseInt((lightJson.toolTeachers / lightJson.teachers * 100).toFixed(0)) : 0"
                   :stroke-width="5" :format="format" color="rgb(64, 149, 229)"></el-progress>
               </div>
             </div>
@@ -205,7 +205,7 @@
               <span>协同合作</span>
               <div>
                 <el-progress :width="80" type="circle"
-                  :percentage="this.lightJson.gCourseTeachers ? (this.lightJson.gCourseTeachers / this.lightJson.teachers * 100).toFixed(0) : 0"
+                  :percentage="lightJson.gCourseTeachers ? parseInt((lightJson.gCourseTeachers / lightJson.teachers * 100).toFixed(0)) : 0"
                   :stroke-width="5" :format="format" color="rgb(64, 149, 229)"></el-progress>
               </div>
             </div>
@@ -213,43 +213,48 @@
               <span>互动交流</span>
               <div>
                 <el-progress :width="80" type="circle"
-                  :percentage="this.lightJson.commentTeachers ? (this.lightJson.commentTeachers / this.lightJson.teachers * 100).toFixed(0) : 0"
+                  :percentage="lightJson.commentTeachers ? parseInt((lightJson.commentTeachers / lightJson.teachers * 100).toFixed(0)) : 0"
                   :stroke-width="5" :format="format" color="rgb(64, 149, 229)"></el-progress>
               </div>
             </div>
             <div class="depth">
               <span>参与课程</span>
               <div>
-                <el-progress :width="80" type="circle" :percentage="80" :stroke-width="5" :format="format"
-                  color="#106BFF"></el-progress>
+                <el-progress :width="80" type="circle"
+                  :percentage="lightJson.courseStudents ? parseInt((lightJson.courseStudents / lightJson.students * 100).toFixed(0)) : 0"
+                  :stroke-width="5" :format="format" color="#106BFF"></el-progress>
               </div>
             </div>
             <div class="depth">
               <span>参与项目</span>
               <div>
-                <el-progress :width="80" type="circle" :percentage="80" :stroke-width="5" :format="format"
-                  color="#106BFF"></el-progress>
+                <el-progress :width="80" type="circle"
+                  :percentage="lightJson.scourseStudents ? parseInt((lightJson.scourseStudents / lightJson.students * 100).toFixed(0)) : 0"
+                  :stroke-width="5" :format="format" color="#106BFF"></el-progress>
               </div>
             </div>
             <div class="depth">
               <span>使用工具</span>
               <div>
-                <el-progress :width="80" type="circle" :percentage="80" :stroke-width="5" :format="format"
-                  color="#106BFF"></el-progress>
+                <el-progress :width="80" type="circle"
+                  :percentage="lightJson.toolStudents ? parseInt((lightJson.toolStudents / lightJson.students * 100).toFixed(0)) : 0"
+                  :stroke-width="5" :format="format" color="#106BFF"></el-progress>
               </div>
             </div>
             <div class="depth">
               <span>协同合作</span>
               <div>
-                <el-progress :width="80" type="circle" :percentage="80" :stroke-width="5" :format="format"
-                  color="#106BFF"></el-progress>
+                <el-progress :width="80" type="circle"
+                  :percentage="lightJson.gsCourseStudents ? parseInt((lightJson.gsCourseStudents / lightJson.students * 100).toFixed(0)) : 0"
+                  :stroke-width="5" :format="format" color="#106BFF"></el-progress>
               </div>
             </div>
             <div class="depth">
               <span>互动交流</span>
               <div>
-                <el-progress :width="80" type="circle" :percentage="80" :stroke-width="5" :format="format"
-                  color="#106BFF"></el-progress>
+                <el-progress :width="80" type="circle"
+                  :percentage="lightJson.commentStudents ? parseInt((lightJson.commentStudents / lightJson.students * 100).toFixed(0)) : 0"
+                  :stroke-width="5" :format="format" color="#106BFF"></el-progress>
               </div>
             </div>
           </div>
@@ -377,8 +382,14 @@ export default {
         upSCourseTeachers: 0,//上传项目
         gCourseTeachers: 0,//协同课程
         toolTeachers: 0,//使用工具
-        commentTeachers: 0,//协同交流
+        commentTeachers: 0,//交流
+        courseStudents: 0,//参与课程
+        scourseStudents: 0,//参与项目
+        toolStudents: 0,//使用工具
+        gsCourseStudents: 0,//协同课程
+        commentStudents: 0,//协同交流
       },
+      weekCourse2: []
     };
   },
   mounted() {
@@ -659,15 +670,7 @@ export default {
           this.themeArray = _themeArray
           this.allArray = [..._gradeArray, ..._subjectArray, ..._themeArray]
           this.typeChange();
-          //     lightJson: {
-          //   teachers: 0,
-          //   students: 0,
-          //   upCourseTeachers: 0,//上传课程
-          //   upSCourseTeachers: 0,//上传项目
-          //   gCourseTeachers: 0,//协同课程
-          //   toolUsers: 0,//使用工具
-          //   commentTeachers: 0,//协同交流
-          // },
+
           this.lightJson.teachers = res.data[14][0].count; //教师总数
           this.lightJson.students = res.data[15][0].count; //学生总数
           this.lightJson.upCourseTeachers = res.data[16][0].count; //上传课程老师数量
@@ -675,6 +678,86 @@ export default {
           this.lightJson.toolTeachers = res.data[18][0].count; //使用工具老师数量
           this.lightJson.gCourseTeachers = res.data[19][0].count; //协同课程老师数量
           this.lightJson.commentTeachers = res.data[20][0].count; //协同交流老师数量
+          this.lightJson.courseStudents = res.data[21][0].count; //参与课程学生数量
+          this.lightJson.scourseStudents = res.data[22][0].count; //参与项目学生数量
+          this.lightJson.toolStudents = res.data[23][0].count; //使用工具数量
+          this.lightJson.gsCourseStudents = res.data[24][0].count; //获取协同项目数量
+          this.lightJson.commentStudents = res.data[25][0].count; //互动交流学生数量
+
+          var today = new Date();
+          var lastDayOfWeek = new Date(today.setDate(today.getDate() - today.getDay() + 7));;//本周周日
+
+          let weekArray = {
+            lastWeek: [],//上周
+            toWeek: [] //本周
+          }
+          for (var i = 0; i < 14; i++) {
+            let time = JSON.parse(JSON.stringify(lastDayOfWeek))
+            let time2 = new Date(time)
+            var a = new Date(time2.setDate(time2.getDate() - i));
+            if (i > 6) {
+              weekArray.lastWeek.push(a.getFullYear() + '-' + (a.getMonth() + 1) + '-' + a.getDate());
+            } else {
+              weekArray.toWeek.push(a.getFullYear() + '-' + (a.getMonth() + 1) + '-' + a.getDate());
+            }
+          }
+          console.log(weekArray);
+          let weekCourse = [];
+          let weekCourse2 = [];
+          let lastWeekCouseCount = 0
+          let toWeekCouseCount = 0
+          for (var z = 0; z < _course.length; z++) {
+            let _date = new Date(weekArray.lastWeek[weekArray.lastWeek.length - 1])
+            console.log(_date)
+            if (new Date(_course[z].create_at) > _date && _course[z].pid == '34628934-d02f-11ec-8c78-005056b86db5') {
+              weekCourse.push(_course[z])
+              var a = new Date(_course[z].create_at)
+              var string = a.getFullYear() + '-' + (a.getMonth() + 1) + '-' + a.getDate()
+              if (weekArray.lastWeek.indexOf(string) != -1) {
+                lastWeekCouseCount++
+              } else {
+                toWeekCouseCount++
+              }
+            }
+          }
+
+          let lastCourseidWeek = []
+          let toCourseidWeek = []
+          for (var i = 0; i < _grade.length; i++) {
+            weekCourse2.push({
+              name: _grade[i].name,
+              id: _grade[i].id,
+              lastCourse: 0,
+              toCourse: 0,
+            })
+            for (var z = 0; z < weekCourse.length; z++) {
+              if (weekCourse[z].typeid == _grade[i].id) {
+                var a = new Date(weekCourse[z].create_at)
+                var string = a.getFullYear() + '-' + (a.getMonth() + 1) + '-' + a.getDate()
+                if (weekArray.lastWeek.indexOf(string) != -1) {
+                  weekCourse2[i].lastCourse++
+                  if (lastCourseidWeek.indexOf(weekCourse[z].courseid) === -1) {
+                    lastCourseidWeek.push(weekCourse[z].courseid)
+                  }
+                } else {
+                  weekCourse2[i].toCourse++
+                  if (toCourseidWeek.indexOf(weekCourse[z].courseid) === -1) {
+                    toCourseidWeek.push(weekCourse[z].courseid)
+                  }
+                }
+
+              }
+            }
+          }
+          weekCourse2.push({
+            name: '其他',
+            id: '',
+            lastCourse: (lastWeekCouseCount - lastCourseidWeek.length) > 0 ? (lastWeekCouseCount - lastCourseidWeek.length) : 0,
+            toCourse: (toWeekCouseCount - toCourseidWeek.length) > 0 ? (toWeekCouseCount - toCourseidWeek.length) : 0,
+          })
+
+          console.log(weekCourse2);
+          this.weekCourse2 = weekCourse2
           this.$forceUpdate();
         })
         .catch((err) => {