|
@@ -23,6 +23,7 @@ import mainData from '@/layout/teacherscore/mainData.vue';
|
|
|
import { mapState, createNamespacedHelpers, mapGetters } from 'vuex';
|
|
|
const { mapActions: teacher } = createNamespacedHelpers('teacher');
|
|
|
const { mapActions: mapScore } = createNamespacedHelpers('score');
|
|
|
+const { mapActions: util } = createNamespacedHelpers('util');
|
|
|
export default {
|
|
|
name: 'index',
|
|
|
props: {},
|
|
@@ -64,29 +65,45 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
...teacher({ columnList: 'query', teacherInfo: 'fetch' }),
|
|
|
- ...mapScore(['fetch', 'create', 'update']),
|
|
|
+ ...mapScore(['query', 'fetch', 'create', 'update']),
|
|
|
+ ...util({ modelFetch: 'fetch' }),
|
|
|
// 查询教师详情
|
|
|
async searchInfo() {
|
|
|
- const res = await this.teacherInfo(this.teaid);
|
|
|
- let xsscore = parseFloat(res.data.xsscore).toFixed(2);
|
|
|
+ let res = await this.teacherInfo(this.teaid);
|
|
|
this.$set(this, `teacherinfo`, res.data);
|
|
|
- this.$set(this, `xsscore`, xsscore);
|
|
|
+ res = await this.modelFetch({ model: 'score', stuid: this.user.id, lessonid: this.lessonid, teacherid: this.teaid });
|
|
|
+ if (res.errcode == 0) {
|
|
|
+ this.$set(this, `xsscore`, res.data.score);
|
|
|
+ this.$set(this.form, `score`, res.data.score);
|
|
|
+ }
|
|
|
},
|
|
|
// 为教师打分
|
|
|
async onsave(form) {
|
|
|
- this.disabled = true;
|
|
|
- this.form.stuid = this.user.id;
|
|
|
- this.form.lessonid = this.lessonid;
|
|
|
- this.form.teacherid = this.teaid;
|
|
|
- let data = this.form;
|
|
|
- const res = await this.create(data);
|
|
|
- this.$notify({
|
|
|
- message: '评分成功',
|
|
|
- type: 'success',
|
|
|
- });
|
|
|
- this.form = {};
|
|
|
- this.disabled = false;
|
|
|
- this.searchInfo();
|
|
|
+ if (form.id) {
|
|
|
+ let data = this.form;
|
|
|
+ const res = await this.update(data);
|
|
|
+ this.$notify({
|
|
|
+ message: '修改评分成功',
|
|
|
+ type: 'success',
|
|
|
+ });
|
|
|
+ this.form = {};
|
|
|
+ this.disabled = false;
|
|
|
+ this.searchInfo();
|
|
|
+ } else {
|
|
|
+ this.disabled = true;
|
|
|
+ this.form.stuid = this.user.id;
|
|
|
+ this.form.lessonid = this.lessonid;
|
|
|
+ this.form.teacherid = this.teaid;
|
|
|
+ let data = this.form;
|
|
|
+ const res = await this.create(data);
|
|
|
+ this.$notify({
|
|
|
+ message: '评分成功',
|
|
|
+ type: 'success',
|
|
|
+ });
|
|
|
+ this.form = {};
|
|
|
+ this.disabled = false;
|
|
|
+ this.searchInfo();
|
|
|
+ }
|
|
|
},
|
|
|
},
|
|
|
};
|