lrf402788946 4 anos atrás
pai
commit
f2504b639e

+ 9 - 5
src/layout/user/workList.vue

@@ -4,10 +4,14 @@
       <el-col :span="24" class="info">
         <el-col :span="24" class="list" v-for="(item, index) in workLists" :key="index">
           <el-col :span="24" class="time">
-            <el-col :span="18">科目:{{ item.subname }}</el-col>
-            <el-col :span="6" class="anniu">
+            <el-col :span="item.score ? 14 : 18">科目:{{ item.subname }}</el-col>
+            <el-col :span="4">{{ item.score }}</el-col>
+            <el-col :span="6" class="anniu" v-if="!item.have">
               <el-button v-if="item.display === 'second'" type="primary" size="small" @click="clickBtn(item.subname, item.subid, item._id)">在线作答</el-button>
-              <el-button v-else type="primary" size="small" @click="clickzy(item.subid, item.subname)">上传作业</el-button>
+              <el-button v-else type="primary" size="small" @click="clickzy(item.subid, item.subname, item._id)">上传作业</el-button>
+            </el-col>
+            <el-col :span="6" class="anniu" v-else>
+              已提交作业
             </el-col>
           </el-col>
         </el-col>
@@ -32,8 +36,8 @@ export default {
     clickBtn(subname, subid, _id) {
       this.$router.push({ path: '/user/dati', query: { name: subname, id: subid, lessonid: _id } });
     },
-    clickzy(subid, subname) {
-      this.$router.push({ path: '/user/chuanzuoye', query: { id: subid, name: subname } });
+    clickzy(subid, subname, _id) {
+      this.$router.push({ path: '/user/chuanzuoye', query: { id: subid, name: subname, lessonid: _id } });
     },
   },
 };

+ 4 - 1
src/views/user/chuanzuoye.vue

@@ -58,6 +58,9 @@ export default {
     id() {
       return this.$route.query.id;
     },
+    lessonid() {
+      return this.$route.query.lessonid;
+    },
 
     name() {
       return this.$route.query.name;
@@ -71,7 +74,7 @@ export default {
       this.form.batchid = this.user.batchid;
       this.form.classid = this.user.classid;
       this.form.studentid = this.user.userid;
-      this.form.lessonid = this.id;
+      this.form.lessonid = this.lessonid;
       this.form.lessonname = this.name;
       let data = this.form;
       console.log();

+ 1 - 0
src/views/user/dati.vue

@@ -317,6 +317,7 @@ export default {
         console.log(answerss);
 
         let res = await this.Uploadtaskadd(answerss);
+        if (this.$checkRes(res, '作业提交成功', res.errmsg || '作业提交失败')) window.history.go(-1);
       }
     },
   },

+ 32 - 8
src/views/user/homework.vue

@@ -27,6 +27,7 @@ const { mapActions: mapClass } = createNamespacedHelpers('classes');
 const { mapActions: mapLesson } = createNamespacedHelpers('lesson');
 const { mapActions: mapTask } = createNamespacedHelpers('task');
 const { mapActions: mapSubject } = createNamespacedHelpers('subject');
+const { mapActions: uploadtask } = createNamespacedHelpers('uploadtask');
 
 export default {
   name: 'homework',
@@ -60,6 +61,7 @@ export default {
     ...mapState(['user']),
   },
   methods: {
+    ...uploadtask({ getUploadTask: 'query' }),
     ...mapTask({ list: 'query', add: 'create', fet: 'fetch', updates: 'update' }),
     ...mapClass({ classinfo: 'fetch', classquery: 'query' }),
     ...mapLesson({ lessonList: 'query', lessonadd: 'create', lessonfet: 'fetch', lessonupdates: 'update' }),
@@ -73,20 +75,42 @@ export default {
       const resout = await this.list();
 
       let lessons = _.get(res.data[0], `lessons`);
-      let r = _.uniqBy(lessons, 'subid');
-      r = r.filter(f => f.subid);
-
+      // lesson排序,只去时间最早的作为作业的上传lessonid,需要和教师处相同处理
+      let r = lessons.filter(f => f.subid);
+      r = r.map(r => {
+        let time = r.time.split('-');
+        r.start = `${r.date} ${time[0]}`;
+        return r;
+      });
+      r = Object.values(_.groupBy(r, 'subid'));
+      r = r.map(a => {
+        let na = _.orderBy(a, ['start'], ['asc']);
+        return _.head(na);
+      });
       var crr = r.filter(item => item.subid);
       this.$set(this, `workLists`, crr);
       for (const val of resout.data) {
         var arr = crr.filter(item => item.subid === val.code);
-        console.log(arr);
+        for (const att of arr) {
+          att.display = 'second';
+        }
       }
-
-      for (const att of arr) {
-        console.log(att);
-        att.display = 'second';
+      this.getUpload();
+    },
+    async getUpload() {
+      let list = _.cloneDeep(this.workLists);
+      for (let i of list) {
+        let res = await this.getUploadTask({ studentid: this.user.userid, lessonid: i._id });
+        if (this.$checkRes(res)) {
+          let r = res.data;
+          if (r.length > 0) {
+            let head = _.head(r);
+            i.have = true;
+            if (head.score) i.score = head.score;
+          } else i.have = false;
+        }
       }
+      this.$set(this, `workLists`, list);
     },
   },
 };