Sfoglia il codice sorgente

Merge branch 'master' of http://git.cc-lotus.info/new_train/train-student

lrf402788946 4 anni fa
parent
commit
aaaee2a3e7

+ 4 - 4
src/layout/teacherscore/mainData.vue

@@ -10,13 +10,13 @@
           <el-col :span="24"></el-col>
           <el-col :span="24" class="pingfen">
             <el-form-item>
-              <el-rate v-model="form.score" :max="10"></el-rate>
+              <van-rate v-model="form.score" :max="10" :count="10" />
             </el-form-item>
           </el-col>
           <el-col :span="24">
             <el-col :span="16" class="title">工作量</el-col>
-            <el-col :span="8" class="fenshu">评分:{{ xsscore === undefined ? '0' : xsscore }}分</el-col>
-            <el-col :span="24" class="work">{{ xsscore > 5 ? '本月工作量饱满' : '本月工作量干枯' }}</el-col>
+            <el-col :span="8" class="fenshu">评分:{{ form.score === undefined ? 0 : form.score }}分</el-col>
+            <el-col :span="24" class="work">{{ form.score > 5 ? '本月工作量饱满' : '本月工作量干枯' }}</el-col>
           </el-col>
           <el-col :span="24" class="beizhu">
             <span>备注</span>
@@ -37,7 +37,7 @@
 <script>
 export default {
   name: 'mainData',
-  props: { teacherinfo: null, xsscore: null, form: null, disabled: Boolean },
+  props: { teacherinfo: null, form: null, disabled: Boolean },
   components: {},
   data: () => ({
     srcurl: require('@/assets/circle.png'),

+ 0 - 1
src/views/index.vue

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

+ 39 - 22
src/views/teacherscore/index.vue

@@ -6,7 +6,7 @@
           <NavBar v-show="navShow" :title="title" :isleftarrow="isleftarrow"> </NavBar>
         </el-col>
         <el-col :span="24" class="main">
-          <mainData :teacherinfo="teacherinfo" :xsscore="xsscore" :form="form" @onsave="onsave" :disabled="disabled"></mainData>
+          <mainData :teacherinfo="teacherinfo" :form="form" @onsave="onsave" :disabled="disabled"></mainData>
         </el-col>
         <el-col :span="24" class="foot">
           <footInfo></footInfo>
@@ -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: {},
@@ -32,13 +33,12 @@ export default {
     mainData, //课程安排主体
   },
   data: () => ({
-    teacherinfo: {},
-    xsscore: '',
-    form: {},
     title: '',
     isleftarrow: '',
     navShow: true,
     disabled: false,
+    teacherinfo: {},
+    form: {},
   }),
   created() {
     this.searchInfo();
@@ -64,29 +64,46 @@ 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) {
+        console.log(res.data);
+        let data = res.data;
+        data.score = Number(res.data.score);
+        console.log(data);
+        this.$set(this, `form`, data);
+      }
     },
     // 为教师打分
-    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();
+    async onsave({ data }) {
+      if (data) {
+        let res = await this.update(data);
+        this.$notify({
+          message: '修改评分成功',
+          type: 'success',
+        });
+        this.form = {};
+        this.disabled = false;
+        this.searchInfo();
+      } else {
+        this.disabled = true;
+        data.stuid = this.user.id;
+        data.lessonid = this.lessonid;
+        data.teacherid = this.teaid;
+        const res = await this.create(data);
+        this.$notify({
+          message: '评分成功',
+          type: 'success',
+        });
+        this.form = {};
+        this.disabled = false;
+        this.searchInfo();
+      }
     },
   },
 };