|
@@ -5,7 +5,7 @@
|
|
|
<div style="width: 348px;height: 40px;flex-shrink: 0;" v-if="!isPdf">
|
|
|
<el-select
|
|
|
v-model="year"
|
|
|
- @change="getData"
|
|
|
+ @change="getClassAva"
|
|
|
style="width: 100%;"
|
|
|
placeholder="请选择"
|
|
|
>
|
|
@@ -76,6 +76,8 @@
|
|
|
:tid="i.id"
|
|
|
:tit="i.name"
|
|
|
:userid="userid"
|
|
|
+ :classScoreData="classScoreData"
|
|
|
+ :claStuNum="claStuNum"
|
|
|
:isPdf="isPdf"
|
|
|
:year="year"
|
|
|
:radarData="radarData"
|
|
@@ -125,6 +127,12 @@ export default {
|
|
|
// 学期数组
|
|
|
termList: [],
|
|
|
|
|
|
+ // 单个班级学生人数
|
|
|
+ claStuNum: 0,
|
|
|
+ // 班级分数数据
|
|
|
+ classScoreData: [],
|
|
|
+ classAvaScoreData: [],
|
|
|
+
|
|
|
info: {},
|
|
|
classJuri: [],
|
|
|
termName: "",
|
|
@@ -223,9 +231,10 @@ export default {
|
|
|
});
|
|
|
// 数据分类底部标签
|
|
|
this.categories = aaa;
|
|
|
-
|
|
|
- // 雷达图数据
|
|
|
+ console.log(1111);
|
|
|
+ // 处理数据数据
|
|
|
this.countRadar();
|
|
|
+ console.log(222);
|
|
|
|
|
|
// 柱状图
|
|
|
this.countCro();
|
|
@@ -255,7 +264,7 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
this.termList = yearJuri;
|
|
|
- this.getData();
|
|
|
+ this.getClassAva();
|
|
|
|
|
|
this.getEvidence();
|
|
|
})
|
|
@@ -281,6 +290,34 @@ export default {
|
|
|
this.healthEvidence = res.data[0];
|
|
|
}); //
|
|
|
},
|
|
|
+
|
|
|
+ // 获取班级平均
|
|
|
+ getClassAva() {
|
|
|
+ this.claStuNum= 0,
|
|
|
+ // 班级分数数据
|
|
|
+ this.classScoreData= []
|
|
|
+ this.classScoreData = []; //数据
|
|
|
+ let params = {
|
|
|
+ cid: this.cid,
|
|
|
+ trm: this.year
|
|
|
+ };
|
|
|
+ // console.log("params", params);
|
|
|
+ this.ajax
|
|
|
+ .get(this.$store.state.api + "selectClaAvaScore", params)
|
|
|
+ .then(res => {
|
|
|
+ this.claStuNum = res.data[0].length > 0 ? res.data[0][0].num : 0;
|
|
|
+ let AvaData = res.data[0];
|
|
|
+ AvaData.forEach((item, index) => {
|
|
|
+ this.classScoreData.push(JSON.parse(item.json));
|
|
|
+ });
|
|
|
+ console.log('this.classScoreData',JSON.parse(JSON.stringify(this.classScoreData)) );
|
|
|
+ // 第一次渲染,要放在这里,不然没有办法循环班级平均数
|
|
|
+ this.getData();
|
|
|
+
|
|
|
+ // console.log("班级平均数据1", this.classScoreData);
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
// 获取打分数据
|
|
|
getData() {
|
|
|
// this.isLoading = true;
|
|
@@ -345,12 +382,13 @@ export default {
|
|
|
// this.radarData = {};
|
|
|
// },
|
|
|
|
|
|
- // 雷达图数据
|
|
|
countRadar() {
|
|
|
- // console.log("数据?", this.radarData);
|
|
|
+ // 分数数据并进行处理
|
|
|
+ // 个人平均分数据开始
|
|
|
let raData = this.radarData;
|
|
|
|
|
|
- // 将数据复制在大分类里面用child来存储
|
|
|
+ // 分数与分类是两个数组
|
|
|
+ // 将分数数据复制在大分类里面用child来存储
|
|
|
this.VeidooList.forEach(e => {
|
|
|
// console.log(e);
|
|
|
let fid = e.id;
|
|
@@ -367,37 +405,101 @@ export default {
|
|
|
});
|
|
|
|
|
|
// 第三次提取,将每个小分类的数据进行相加再除以小分类的长度得到平均值,再将平均值存储在大分类的num中
|
|
|
- let a = 0;
|
|
|
- let b = 0;
|
|
|
- let c = 0;
|
|
|
+
|
|
|
this.VeidooList.forEach((e, k) => {
|
|
|
- e.num = [];
|
|
|
+ let stockpile = [];
|
|
|
e.child2.forEach((i, index) => {
|
|
|
- a = a + i[0];
|
|
|
- b = b + i[1];
|
|
|
- c = c + i[2];
|
|
|
+ stockpile = this.addArrays(stockpile, i);
|
|
|
});
|
|
|
- a = (a / e.child2.length).toFixed(1);
|
|
|
- b = (b / e.child2.length).toFixed(1);
|
|
|
- c = (c / e.child2.length).toFixed(1);
|
|
|
-
|
|
|
- // 综合的柱状图,使用的是雷达图的数据再加工的数据。
|
|
|
- //toFixed会把数字转换成字符串,所以要转换成数字,不然柱状没法用
|
|
|
- e.num.push(a * 1, b * 1, c * 1);
|
|
|
- a = 0;
|
|
|
- b = 0;
|
|
|
- c = 0;
|
|
|
+
|
|
|
+ e.num = stockpile.map(item => {
|
|
|
+ return (item / e.child2.length).toFixed(1);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ // 个人平均分数据结束
|
|
|
+
|
|
|
+// 班级平均分数据开始
|
|
|
+ // console.log("????", this.classScoreData);
|
|
|
+ // 先将每个学生的小分类整理好,放在child里面
|
|
|
+ console.log('this.classScoreData',this.classScoreData);
|
|
|
+
|
|
|
+ this.classScoreData.forEach(i => {
|
|
|
+ for (let j in i) {
|
|
|
+ i[j].child = [];
|
|
|
+ console.log(i[j]);
|
|
|
+ for (let k in i[j]) {
|
|
|
+ if (k != "child") {
|
|
|
+ i[j].child.push(i[j][k][i[j][k].id]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
});
|
|
|
+ console.log(333);
|
|
|
+
|
|
|
+ // 将学生每个大分类的平均分整合
|
|
|
+ this.classScoreData.forEach(i => {
|
|
|
+ for (let j in i) {
|
|
|
+ // console.log(i[j]);
|
|
|
+ let arr = [];
|
|
|
+ i[j].child2 = [];
|
|
|
+ i[j].child.forEach(e => {
|
|
|
+
|
|
|
+ arr = this.addArrays(arr, e);
|
|
|
+ });
|
|
|
+ // console.log(i[j].child);
|
|
|
+ i[j].child2 = arr.map(item => {
|
|
|
+ return ((item * 1) / i[j].child.length).toFixed(1);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ console.log(444);
|
|
|
+
|
|
|
+ // 获取学生大分类平均分
|
|
|
+ this.classScoreData.forEach(i => {
|
|
|
+ i.arr = [];
|
|
|
+ for (let j in i) {
|
|
|
+ if (j != "arr") {
|
|
|
+ let new1 = 0;
|
|
|
+ new1 = i[j].child2.reduce((pre, cur) => {
|
|
|
+ return pre * 1 + cur * 1;
|
|
|
+ }, 0);
|
|
|
+ i.arr.push((new1 / 3).toFixed(1));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 获取大分类班级平均数
|
|
|
+ let ClaAvaArr = [];
|
|
|
+ this.classScoreData.forEach(i => {
|
|
|
+ ClaAvaArr.push(i.arr);
|
|
|
+ });
|
|
|
+ // console.log(ClaAvaArr);
|
|
|
+
|
|
|
+ let AvaArrItem = [];
|
|
|
+ ClaAvaArr.forEach((i, index) => {
|
|
|
+ AvaArrItem = this.addArrays(AvaArrItem, i);
|
|
|
+ });
|
|
|
+ AvaArrItem = AvaArrItem.map(item => {
|
|
|
+ return (item / this.claStuNum).toFixed(1);
|
|
|
+ });
|
|
|
+ this.classAvaScoreData = AvaArrItem;
|
|
|
+
|
|
|
+ // console.log("AvaArr", AvaArr);
|
|
|
+
|
|
|
+ // console.log("this.classScoreData", this.classScoreData);
|
|
|
+
|
|
|
+// 班级平均分数据结束
|
|
|
|
|
|
// 雷达图数据---- 最后把每个大分类下的num按照,第一次第二次第三次,存储到raDataCopy中,为
|
|
|
let raDataCopy = [[], [], []];
|
|
|
+ // console.log("VeidooList", this.VeidooList);
|
|
|
this.VeidooList.forEach((e, k) => {
|
|
|
raDataCopy[0].push(e.num[0]);
|
|
|
raDataCopy[1].push(e.num[1]);
|
|
|
raDataCopy[2].push(e.num[2]);
|
|
|
});
|
|
|
- // console.log("旧raDataCopy", raDataCopy);
|
|
|
this.chartData = raDataCopy;
|
|
|
+ // console.log("raDataCopy", raDataCopy);
|
|
|
},
|
|
|
// 柱状图
|
|
|
countCro() {
|
|
@@ -407,10 +509,19 @@ export default {
|
|
|
// console.log(e);
|
|
|
croMapData = this.addArrays(croMapData, e);
|
|
|
});
|
|
|
-
|
|
|
+ let _this = this;
|
|
|
this.croColumnarData = croMapData.map(function(item) {
|
|
|
- return (item / 3).toFixed(1);
|
|
|
+ return (item / _this.chartData.length).toFixed(1);
|
|
|
});
|
|
|
+ // this.croColumnarData=this.combineArrays(this.croColumnarData,this.classAvaScoreData)
|
|
|
+ // console.log("this.classAvaScoreData", this.classAvaScoreData);
|
|
|
+ let k = [this.croColumnarData, this.classAvaScoreData];
|
|
|
+ // this.croColumnarData.forEach((e, index) => {
|
|
|
+ // k[index] = [];
|
|
|
+ // k[index].push(e * 1, this.classAvaScoreData[index] * 1);
|
|
|
+ // });
|
|
|
+ this.croColumnarData = k;
|
|
|
+ // console.log("k", this.croColumnarData);
|
|
|
},
|
|
|
|
|
|
// 数据相同下标相加组成一个新数组
|
|
@@ -449,7 +560,7 @@ export default {
|
|
|
const result = [];
|
|
|
|
|
|
for (let i = 0; i < array2.length; i++) {
|
|
|
- const sum = (array1[i] || 0) + array2[i];
|
|
|
+ const sum = (array1[i] || 0) + array2[i] * 1;
|
|
|
result.push(sum);
|
|
|
}
|
|
|
|
|
@@ -558,16 +669,18 @@ export default {
|
|
|
// this.classid = res.data[0][0].classid;
|
|
|
// this.getClassStudent();
|
|
|
|
|
|
- console.log("this.info", this.info);
|
|
|
+ // console.log("this.info", this.info);
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
mounted() {},
|
|
|
created() {
|
|
|
this.fullscreenLoading = true;
|
|
|
+
|
|
|
this.getStudentDetail();
|
|
|
this.getClass();
|
|
|
this.getYear();
|
|
|
+
|
|
|
// console.log('数据',this.$route.query);
|
|
|
}
|
|
|
};
|