|
@@ -1,6 +1,11 @@
|
|
|
<template>
|
|
|
<div id="index">
|
|
|
<list-frame :title="pageTitle" @query="search" :total="total" :needFilter="false" :needAdd="false">
|
|
|
+ <el-col :span="24" class="teascore">
|
|
|
+ <p>
|
|
|
+ 教师:<span>{{ teacherinfo.name }}</span> 总分:<span>{{ teascore.teatotal }}分</span> 平均分:<span>{{ teascore.teapinjuntotal }}分</span>
|
|
|
+ </p>
|
|
|
+ </el-col>
|
|
|
<data-table :fields="fields" :data="list" :opera="opera">
|
|
|
<template #custom="{item, row}">
|
|
|
<template v-if="item.prop === 'stuid'">
|
|
@@ -19,6 +24,7 @@ import _ from 'lodash';
|
|
|
import { mapState, createNamespacedHelpers, mapGetters } from 'vuex';
|
|
|
const { mapActions: student } = createNamespacedHelpers('student');
|
|
|
const { mapActions: mapScore } = createNamespacedHelpers('score');
|
|
|
+const { mapActions: teacher } = createNamespacedHelpers('teacher');
|
|
|
|
|
|
export default {
|
|
|
name: 'index',
|
|
@@ -34,19 +40,34 @@ export default {
|
|
|
total: 0,
|
|
|
// 學生列表
|
|
|
stuList: [],
|
|
|
+ stutotal: 0,
|
|
|
+ // 教师信息
|
|
|
+ teacherinfo: {},
|
|
|
+ // 教师分
|
|
|
+ teascore: {},
|
|
|
}),
|
|
|
- created() {
|
|
|
- this.searchstu();
|
|
|
- this.search();
|
|
|
+ async created() {
|
|
|
+ await this.searchstu();
|
|
|
+ await this.search();
|
|
|
},
|
|
|
methods: {
|
|
|
...student({ stuquery: 'query' }),
|
|
|
+ ...teacher({ teafetch: 'fetch' }),
|
|
|
...mapScore(['query', 'fetch', 'create', 'update']),
|
|
|
async search({ skip, limit = 10, ...info } = {}) {
|
|
|
let res = await this.query({ lessonid: this.lessonid, teacherid: this.teacherid, skip, limit, ...info });
|
|
|
if (res.errcode === 0) {
|
|
|
this.$set(this, `list`, res.data);
|
|
|
this.$set(this, `total`, res.total);
|
|
|
+ // 教师总分
|
|
|
+ let teatotal = res.data.reduce((p, n) => p + (n['score'] * 1 || 0), 0);
|
|
|
+ // 教师平均分
|
|
|
+ let teapinjuntotal = _.round(teatotal / this.stutotal, 2);
|
|
|
+ let data = {
|
|
|
+ teatotal: teatotal,
|
|
|
+ teapinjuntotal: teapinjuntotal,
|
|
|
+ };
|
|
|
+ this.$set(this, `teascore`, data);
|
|
|
}
|
|
|
},
|
|
|
// 过滤学生
|
|
@@ -57,9 +78,14 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
async searchstu() {
|
|
|
- const res = await this.stuquery({ classid: this.defaultOption.classid });
|
|
|
+ let res = await this.stuquery({ classid: this.defaultOption.classid });
|
|
|
if (this.$checkRes(res)) {
|
|
|
this.$set(this, `stuList`, res.data);
|
|
|
+ this.$set(this, `stutotal`, res.total);
|
|
|
+ }
|
|
|
+ res = await this.teafetch(this.teacherid);
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ this.$set(this, `teacherinfo`, res.data);
|
|
|
}
|
|
|
},
|
|
|
},
|
|
@@ -81,4 +107,11 @@ export default {
|
|
|
};
|
|
|
</script>
|
|
|
|
|
|
-<style lang="less" scoped></style>
|
|
|
+<style lang="less" scoped>
|
|
|
+.teascore {
|
|
|
+ span {
|
|
|
+ font-weight: bold;
|
|
|
+ color: #ff0000;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|