|
@@ -37,12 +37,12 @@ import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
export default {
|
|
|
name: 'leagueData',
|
|
|
props: {
|
|
|
- lessonList: { type: Array },
|
|
|
- groupList: { type: Array },
|
|
|
- list: { type: Array },
|
|
|
- getPScore: { type: Array },
|
|
|
- homeworkList: { type: Array },
|
|
|
- groupscoreList: { type: Array },
|
|
|
+ lessonList: { type: Array, default: () => [] },
|
|
|
+ groupList: { type: Array, default: () => [] },
|
|
|
+ list: { type: Array, default: () => [] },
|
|
|
+ getPScore: { type: Array, default: () => [] },
|
|
|
+ homeworkList: { type: Array, default: () => [] },
|
|
|
+ groupscoreList: { type: Array, default: () => [] },
|
|
|
},
|
|
|
components: {},
|
|
|
data: function() {
|
|
@@ -95,11 +95,32 @@ export default {
|
|
|
let homework = this.homeworkList.filter(f => f.studentid == data.stuid);
|
|
|
let hwSum = homework.reduce((p, n) => p + (n['score'] * 1 || 0), 0);
|
|
|
// // 团队
|
|
|
- let groupscore = this.groupscoreList.filter(f => f.groupid == data.groupid);
|
|
|
- let groupLength = this.groupList.find(f => f.id == data.groupid);
|
|
|
- let grSum = groupscore.reduce((p, n) => p + ((n['score'] * 1) / groupLength.students.length || 0), 0);
|
|
|
+ const groupscoreList = this.cleanSame(this.groupscoreList, 'groupid');
|
|
|
+ let groupscore = groupscoreList.filter(f => f.groupid == data.groupid).reduce((p, n) => p + n['score'] * 1, 0);
|
|
|
+ let groupLength = _.get(
|
|
|
+ this.groupList.find(f => f.id == data.groupid),
|
|
|
+ 'students.length',
|
|
|
+ 0
|
|
|
+ );
|
|
|
+ let grSum = 0;
|
|
|
+ if (groupLength > 0) grSum = groupscore / groupLength;
|
|
|
+ // let grSum = groupscore.reduce((p, n) => p + ((n['score'] * 1) / groupLength.students.length || 0), 0);
|
|
|
+ // if (this.getPScore.length > 0 && this.homeworkList.length > 0 && this.groupscoreList.length > 0 && data.stuname === '谷彦庆') {
|
|
|
+ // console.group(data.stuname);
|
|
|
+ // console.log(`个人:${psSum}`);
|
|
|
+ // console.log(`作业:${hwSum}`);
|
|
|
+ // let t = this.groupscoreList.filter(f => f.groupid == data.groupid);
|
|
|
+ // console.log(t);
|
|
|
+ // console.log(`团队:${grSum}`);
|
|
|
+ // console.groupEnd(data.stuname);
|
|
|
+ // }
|
|
|
+
|
|
|
return _.round(hwSum + psSum + grSum, 2);
|
|
|
},
|
|
|
+ cleanSame(list, key) {
|
|
|
+ console.log(list);
|
|
|
+ return _.uniqBy(list, key);
|
|
|
+ },
|
|
|
},
|
|
|
};
|
|
|
</script>
|