Ver código fonte

gengxinzuoye

wuhongyuq 5 anos atrás
pai
commit
979f45186a

+ 6 - 7
src/layout/user/datiList.vue

@@ -12,11 +12,11 @@
             </el-form-item>
             <template v-if="item.type === '0'">
               <el-col :span="24" v-for="(items, index) in item.option" :key="index">
-                <el-radio v-model="item.answer" :label="items.opname">{{ items.opname }}</el-radio>
+                <el-radio v-model="item.answers" :label="items.opname">{{ items.opname }}</el-radio>
               </el-col>
             </template>
             <template v-else-if="item.type === '1'">
-              <el-checkbox-group v-model="item.answer">
+              <el-checkbox-group v-model="item.answers">
                 <el-col :span="24" v-for="(items, index) in item.option" :key="index">
                   <el-checkbox :label="items.opname">{{ items.opname }}</el-checkbox>
                 </el-col>
@@ -26,7 +26,7 @@
               <el-input
                 type="textarea"
                 placeholder="请输入内容"
-                v-model="item.answer"
+                v-model="item.answers"
                 :autosize="{ minRows: 4, maxRows: 6 }"
                 maxlength="300"
                 show-word-limit
@@ -49,16 +49,15 @@ export default {
   props: {
     form: null,
     datilist: null,
+    answer: null,
   },
   components: {},
-  data: () => ({
-    task: {},
-  }),
+  data: () => ({}),
   created() {},
   computed: {},
   methods: {
     onSubmit() {
-      this.$emit('submit', this.task);
+      this.$emit('submit');
     },
   },
 };

+ 6 - 6
src/layout/user/workList.vue

@@ -4,9 +4,9 @@
       <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.name }}</el-col>
+            <el-col :span="18">科目:{{ item.subname }}</el-col>
             <el-col :span="6" class="anniu">
-              <el-button v-if="item.display === 'second'" type="primary" size="small" @click="clickBtn(item.name)">在线作答</el-button>
+              <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.id)">上传作业</el-button>
             </el-col>
           </el-col>
@@ -29,11 +29,11 @@ export default {
   created() {},
   computed: {},
   methods: {
-    clickBtn(name) {
-      this.$router.push({ path: '/user/dati', query: { name: name } });
+    clickBtn(subname, subid, _id) {
+      this.$router.push({ path: '/user/dati', query: { name: subname, id: subid, lessonid: _id } });
     },
-    clickzy(id) {
-      this.$router.push({ path: '/user/chuanzuoye', query: { id: id } });
+    clickzy(_id) {
+      this.$router.push({ path: '/user/chuanzuoye', query: { id: _id } });
     },
   },
 };

+ 76 - 9
src/views/user/dati.vue

@@ -8,7 +8,7 @@
         <el-col :span="24" class="main">
           <el-col :span="24" class="leaveBtn"> </el-col>
           <el-col :span="24" class="leaveList">
-            <datiList :datilist="datilist"></datiList>
+            <datiList :datilist="datilist" :form="form" :answer="answer" @submit="onsave"></datiList>
           </el-col>
         </el-col>
       </el-col>
@@ -21,6 +21,8 @@ import NavBar from '@/layout/common/topInfo.vue';
 import datiList from '@/layout/user/datiList.vue';
 import { mapState, createNamespacedHelpers, mapGetters } from 'vuex';
 const { mapActions: mapTask } = createNamespacedHelpers('task');
+const { mapActions: mapTaskUploadtask } = createNamespacedHelpers('uploadtask');
+
 export default {
   name: 'homework',
   props: {},
@@ -35,6 +37,9 @@ export default {
     navShow: true,
     title: '',
     isleftarrow: '',
+    answer: [],
+    form: {},
+    taskid: '',
   }),
   mounted() {
     this.title = this.$route.meta.title;
@@ -55,26 +60,88 @@ export default {
     name() {
       return this.$route.query.name;
     },
+    id() {
+      return this.$route.query.id;
+    },
+    lessonid() {
+      return this.$route.query.lessonid;
+    },
   },
   methods: {
     ...mapTask({ list: 'query', add: 'create', fet: 'fetch', updates: 'update' }),
+    ...mapTaskUploadtask({ Uploadtasklist: 'query', Uploadtaskadd: 'create', Uploadtaskfet: 'fetch', Uploadtaskupdates: 'update' }),
+
+    //查询作业
     async search() {
       console.log(this.name);
       const res = await this.list();
-      var tilist = res.data.filter(item => item.name === this.name);
-      for (const result of tilist) {
-        this.$set(this, `datilist`, result);
 
-        for (const option of result.question) {
-   
-          console.log(answer);
+      var tilist = res.data.filter(item => item.code === this.id);
+      let result = tilist[0];
+      console.log(result.id);
+      this.$set(this, `taskid`, result.id);
+      result.question = result.question.map(i => {
+        if (i.type == 1) {
+          i.answers = [];
+        } else {
+          i.answers = '';
         }
 
-        // let  answer=[]
-      }
+        // i.answers = JSON.parse(i.answers);
+        return i;
+        console.log(result.question);
+      });
+      this.$set(this, `datilist`, result);
 
       this.loading = false;
     },
+
+    async onsave() {
+      // let data = this.datilist.question;
+      // let new_arr = [];
+      // for (const acc of data) {
+
+      //   let less = { questionid: acc._id };
+      //   less.answer = JSON.stringify(acc.answers);
+      //   new_arr.push(less.answer);
+      //   console.log(less);
+      //   let answers = [less];
+      //   let lesson = { termid: this.user.termid, lessonid: this.lessonid, batchid: this.user.batchid, classid: this.user.classid, studentid: this.user.userid };
+      //   lesson.answers = answers;
+      //   console.log(lesson);
+      // }
+      let answerss = {
+        termid: this.user.termid,
+        batchid: this.user.batchid,
+        classid: this.user.classid,
+        lessonid: this.lessonid,
+        studentid: this.user.userid,
+        taskid: this.taskid,
+      };
+      let answers = {};
+
+      let data = this.datilist.question;
+      var answer = data.map(i => {
+        answers.questionid = i._id;
+        answers.answer = JSON.stringify(i.answers);
+
+        if (i.type == 1) {
+          return {
+            answer: JSON.stringify(i.answers),
+            questionid: i._id,
+          };
+        } else {
+          return {
+            answer: i.answers,
+            questionid: i._id,
+          };
+        }
+      });
+      console.log(answer);
+
+      answerss.answer = answer;
+      let res = await this.Uploadtaskadd(answerss);
+    },
   },
 };
 </script>

+ 9 - 7
src/views/user/homework.vue

@@ -70,16 +70,18 @@ export default {
     async search() {
       let classid = this.user.classid;
       const ress = await this.classinfo(classid);
-      console.log(ress.data.lessonid);
+
       let lessonid = ress.data.lessonid;
-      const res = await this.subjectList({ lessonid });
-      console.log(res.data);
+      const res = await this.lessonList({ lessonid });
       const resout = await this.list();
       for (const val of resout.data) {
-        // console.log(result.data.lessons);
-        // var crr = result.data.lessons.filter(item => item.subid);
-        this.$set(this, `workLists`, res.data);
-        var arr = res.data.filter(item => item.name === val.name);
+        for (const tyl of res.data) {
+          var crr = tyl.lessons.filter(item => item.subid);
+          this.$set(this, `workLists`, crr);
+        }
+
+        console.log(crr);
+        var arr = crr.filter(item => item.subid === val.code);
 
         for (const att of arr) {
           att.display = 'second';