zengyicheng 1 vuosi sitten
vanhempi
commit
f6c0f15b47
1 muutettua tiedostoa jossa 70 lisäystä ja 16 poistoa
  1. 70 16
      src/components/pages/kindStudentEva/panel/index.vue

+ 70 - 16
src/components/pages/kindStudentEva/panel/index.vue

@@ -11,17 +11,17 @@
         <div>学习记录</div>
       </div>
     </div>
-    <div class="i_body_panel">
+    <div class="i_body_panel" v-for="(item,index) in typeList" :key="index">
       <div class="i_icon"><span></span></div>
       <div class="i_detail">
         <div>
-          <span>{{ count1 }}</span
+          <span>{{ item.value }}</span
           ><span>个</span>
         </div>
-        <div>健康记录</div>
+        <div>{{ item.name }}记录</div>
       </div>
     </div>
-    <div class="i_body_panel">
+    <!-- <div class="i_body_panel">
       <div class="i_icon"><span></span></div>
       <div class="i_detail">
         <div>
@@ -60,7 +60,7 @@
         </div>
         <div>艺术记录</div>
       </div>
-    </div>
+    </div> -->
   </div>
 </template>
 
@@ -82,27 +82,81 @@ export default {
       test: [],
       work: [],
       count: 0,
-      count1: 0,
-      count2: 0,
-      count3: 0,
-      count4: 0,
-      count5: 0,
+      // count1: 0,
+      // count2: 0,
+      // count3: 0,
+      // count4: 0,
+      // count5: 0,
+      typeList: [],
     };
   },
   methods: {
     getData() {
       let params = {
         uid: this.userid,
+        oid: this.oid,
       };
       this.ajax
         .get(this.$store.state.api + "selectSRecordY", params)
         .then((res) => {
-          this.count = res.data[0][0].count; //总学习记录
-          this.count1 = res.data[1][0].count; //健康学习记录
-          this.count2 = res.data[2][0].count; //语言学习记录
-          this.count3 = res.data[3][0].count; //社会学习记录
-          this.count4 = res.data[4][0].count; //科学学习记录
-          this.count5 = res.data[5][0].count; //艺术学习记录
+          this.count = res.data[0].length; //总学习记录数量
+          var data = res.data[0]; //总学习记录
+          var type = res.data[1]; //分类
+          var tOid = res.data[2]; //学校分类
+          if (tOid.length > 0) {
+            for (var i = 0; i < tOid.length; i++) {
+              type.push(tOid[i]);
+            }
+          }
+          var typeList = [];
+          var ridList = "";
+          for (var i = 0; i < data.length; i++) {
+            if (typeList.length == 0) {
+              ridList = data[i].rid;
+              var a = data[i].type.split(",");
+              if (a.length > 1) {
+                for (var j = 0; j < a.length; j++) {
+                  typeList.push(a[j]);
+                }
+              } else {
+                typeList.push(a[j]);
+              }
+            } else {
+              if (ridList.indexOf(data[i].rid) == -1) {
+                ridList += "," + data[i].rid;
+                var a = data[i].type.split(",");
+                if (a.length > 1) {
+                  for (var j = 0; j < a.length; j++) {
+                    typeList.push(a[j]);
+                  }
+                } else {
+                  typeList.push(a[j]);
+                }
+              }
+            }
+          }
+          var ftype = [];
+          for (var i = 0; i < type.length; i++) {
+            for (var j = 0; j < typeList.length; j++) {
+              if (typeList[j] == type[i].id) {
+                ftype.push(type[i].pid);
+              }
+            }
+          }
+          var type1 = type.filter(item => item.pid === '0');;
+          var ftypeList = type1.map((item) => {
+            return {
+              id: item.id,
+              name: item.name,
+              value: ftype.filter((id) => id === item.id).length,
+            };
+          });
+          this.typeList = ftypeList;
+          // this.count1 = res.data[1][0].count; //健康学习记录
+          // this.count2 = res.data[2][0].count; //语言学习记录
+          // this.count3 = res.data[3][0].count; //社会学习记录
+          // this.count4 = res.data[4][0].count; //科学学习记录
+          // this.count5 = res.data[5][0].count; //艺术学习记录
         })
         .catch((err) => {
           console.error(err);