guhongwei 4 years ago
parent
commit
b085d06030
3 changed files with 36 additions and 19 deletions
  1. 2 1
      src/layout/teacherscore/mainData.vue
  2. 0 1
      src/views/index.vue
  3. 34 17
      src/views/teacherscore/index.vue

+ 2 - 1
src/layout/teacherscore/mainData.vue

@@ -10,7 +10,8 @@
           <el-col :span="24"></el-col>
           <el-col :span="24"></el-col>
           <el-col :span="24" class="pingfen">
           <el-col :span="24" class="pingfen">
             <el-form-item>
             <el-form-item>
-              <el-rate v-model="form.score" :max="10"></el-rate>
+              <!-- <el-rate v-model="form.score"></el-rate> -->
+              <van-rate v-model="form.score" :max="10" :count="10" />
             </el-form-item>
             </el-form-item>
           </el-col>
           </el-col>
           <el-col :span="24">
           <el-col :span="24">

+ 0 - 1
src/views/index.vue

@@ -8,7 +8,6 @@
         <el-col :span="24" class="main" v-if="view === 'arrange'">
         <el-col :span="24" class="main" v-if="view === 'arrange'">
           <mainData :lesson="lesson" :today="today" :arrange="arrange" @getLesson="getLesson" :locationList="locationList" :classInfo="classInfo"></mainData>
           <mainData :lesson="lesson" :today="today" :arrange="arrange" @getLesson="getLesson" :locationList="locationList" :classInfo="classInfo"></mainData>
         </el-col>
         </el-col>
-
         <el-col :span="24" class="foot">
         <el-col :span="24" class="foot">
           <footInfo></footInfo>
           <footInfo></footInfo>
         </el-col>
         </el-col>

+ 34 - 17
src/views/teacherscore/index.vue

@@ -23,6 +23,7 @@ import mainData from '@/layout/teacherscore/mainData.vue';
 import { mapState, createNamespacedHelpers, mapGetters } from 'vuex';
 import { mapState, createNamespacedHelpers, mapGetters } from 'vuex';
 const { mapActions: teacher } = createNamespacedHelpers('teacher');
 const { mapActions: teacher } = createNamespacedHelpers('teacher');
 const { mapActions: mapScore } = createNamespacedHelpers('score');
 const { mapActions: mapScore } = createNamespacedHelpers('score');
+const { mapActions: util } = createNamespacedHelpers('util');
 export default {
 export default {
   name: 'index',
   name: 'index',
   props: {},
   props: {},
@@ -64,29 +65,45 @@ export default {
   },
   },
   methods: {
   methods: {
     ...teacher({ columnList: 'query', teacherInfo: 'fetch' }),
     ...teacher({ columnList: 'query', teacherInfo: 'fetch' }),
-    ...mapScore(['fetch', 'create', 'update']),
+    ...mapScore(['query', 'fetch', 'create', 'update']),
+    ...util({ modelFetch: 'fetch' }),
     // 查询教师详情
     // 查询教师详情
     async searchInfo() {
     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, `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) {
     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();
+      }
     },
     },
   },
   },
 };
 };