wuhongyu 5 tahun lalu
induk
melakukan
b966acd2c4

+ 1 - 1
src/views/class/index.vue

@@ -253,7 +253,7 @@ export default {
     async queren(item) {
       item.status = '1';
       console.log(item);
-      const res = await this.create(item);
+      const res = await this.update(item);
     },
     //教师查看班级列表
     async class() {

+ 8 - 5
src/views/user/checkWork.vue

@@ -6,9 +6,9 @@
           <NavBar v-show="navShow" :title="title" :isleftarrow="isleftarrow"> </NavBar>
         </el-col>
         <el-col :span="24" class="main">
-          <el-col :span="24" class="leaveBtn">
-            <punchBtn :show="show" :form="form" :dates="dates" @openClick="openClick" @onSubmit="onSubmit"></punchBtn>
-          </el-col>
+          <!-- <el-col :span="24" class="leaveBtn">
+        <punchBtn :show="show" :form="form" :dates="dates" @openClick="openClick" @onSubmit="onSubmit"></punchBtn>
+          </el-col> -->
           <el-col :span="24" class="leaveList">
             <checkList :checkWorkList="checkWorkList" :anames="anames"></checkList>
           </el-col>
@@ -21,7 +21,7 @@
 <script>
 import NavBar from '@/layout/common/topInfo.vue';
 import checkList from '@/layout/user/checkList.vue';
-import punchBtn from '@/layout/user/punchBtn.vue';
+// import punchBtn from '@/layout/user/punchBtn.vue';
 import { mapState, createNamespacedHelpers, mapGetters } from 'vuex';
 const { mapActions: mapAttendance } = createNamespacedHelpers('attendance');
 const { mapActions: mapClass } = createNamespacedHelpers('classes');
@@ -31,7 +31,7 @@ export default {
   components: {
     NavBar, //头部导航
     checkList, //考勤列表
-    punchBtn, //考勤打卡
+    // punchBtn, //考勤打卡
   },
   data: () => ({
     show: false,
@@ -136,4 +136,7 @@ export default {
   text-align: center;
   padding: 15px 0;
 }
+.leaveList {
+  padding: 15px 0 0 0;
+}
 </style>

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

@@ -72,6 +72,7 @@ export default {
       let data = this.form;
       console.log(data);
       let res = await this.add(data);
+      this.$checkRes(res, '提交成功', res.errmsg);
     },
   },
 };

+ 139 - 120
src/views/user/dati.vue

@@ -96,6 +96,9 @@ export default {
       let lessonid = this.lessonid;
 
       let ress = await this.Uploadtasklist({ lessonid });
+
+      console.log(ress.data);
+
       console.log(ress.data);
 
       this.$set(this, `resdata`, ress.data);
@@ -160,131 +163,147 @@ export default {
 
       //上传
       let dati = this.resdata;
-      //作业
-      let task = this.datilist;
-
-      task.question.map(n => {
-        console.log(n._id);
-
-        if (n.type == 1) {
-          // a b array类型
-          let a = n.answer.split(';');
-          let b = n.answers;
-
-          let c = new Set(a);
-          let d = new Set(b);
-          console.log(d);
-          console.log(c);
-          let differenceABSet = new Set([...d].filter(x => !c.has(x)));
-
-          var sc = this.datilist.question.map(a => {
-            if (n._id == a._id) {
-              console.log('dw');
-
-              if (differenceABSet.size === 0) {
-                return {
-                  // 转换成string
-                  answer: JSON.stringify(n.answers),
-                  questionid: n._id,
-                  questionscore: n.score,
-                };
+      console.log(dati);
+
+      if (dati.length) {
+        let task = this.datilist;
+        let newsc = [];
+        task.question.map(n => {
+          if (n.type == 1) {
+            // a b array类型
+            let a = n.answer.split(';');
+            let b = n.answers;
+
+            let c = new Set(a);
+            let d = new Set(b);
+
+            let differenceABSet = new Set([...d].filter(x => !c.has(x)));
+
+            var sc = this.datilist.question.map(a => {
+              if (n._id == a._id) {
+                if (differenceABSet.size === 0) {
+                  return {
+                    // 转换成string
+                    // answer: JSON.stringify(n.answers),
+
+                    answer: JSON.stringify(n.answers),
+                    questionid: n._id,
+                    questionscore: n.score,
+                  };
+                } else {
+                  return {
+                    // 转换成string
+                    // answer: JSON.stringify(n.answers),
+
+                    answer: JSON.stringify(n.answers),
+                    questionid: n._id,
+                    questionscore: 0,
+                  };
+                }
               }
-            }
-          });
-          console.log(sc);
-        } else {
-          console.log(this.datilist.question);
-
-          var sc = this.datilist.question.map(a => {
-            console.log(n._id);
-            console.log(a.questionid);
-
-            if (n._id == a._id) {
-              if (n.answers === n.answer) {
-                return {
-                  answer: n.answers,
-                  questionid: n._id,
-                  questionscore: n.score,
-                };
-              } else {
-                return {
-                  answer: n.answers,
-                  questionid: n._id,
-                  questionscore: 0,
-                };
+            });
+          } else {
+            var sc = this.datilist.question.map(a => {
+              if (n._id == a._id) {
+                if (n.answers === n.answer) {
+                  return {
+                    answer: n.answers,
+                    questionid: n._id,
+                    questionscore: n.score,
+                  };
+                } else {
+                  return {
+                    answer: n.answers,
+                    questionid: n._id,
+                    questionscore: 0,
+                  };
+                }
               }
-            }
-          });
-
-          // var sc = shangchan.answers.map(a => {
-          //   //字符串判断答案
-          //   if (n._id == a.questionid) {
-          //     if (n.answers === n.answer) {
-          //       return {
-          //         answer: n.answers,
-          //         questionid: n._id,
-          //         questionscore: n.score,
-          //       };
-          //     }
-          //   }
-          // });
-        }
+            });
+          }
 
-        // console.log(sc);
+          newsc = [...sc, ...newsc];
 
-        //合并数组
-        // newsc = [...sc, ...newsc];
-        // var arr = newsc.filter(item => item);
-        // answerss.answers = arr;
-      });
+          var arr = newsc.filter(item => item);
+          answerss.answers = arr;
+        });
+        console.log(answerss);
+
+        let res = await this.Uploadtaskupdates(answerss);
+      } else {
+        //作业
+        let task = this.datilist;
+        let newsc = [];
+        task.question.map(n => {
+          console.log(n._id);
 
-      // //合并集合时使用
-      // let newsc = [];
-      // for (const shangchan of dati) {
-      //   console.log(shangchan);
-      //   task.question.map(n => {
-      //     if (n.type == 1) {
-      //       // a b array类型
-      //       let a = n.answer.split(';');
-      //       let b = n.answers;
-      //       console.log(b);
-      //       let c = new Set(a);
-      //       let d = new Set(b);
-      //       //差集判断答案
-      //       let differenceABSet = new Set([...d].filter(x => !c.has(x)));
-      //       var sc = shangchan.answers.map(a => {
-      //         if (n._id == a.questionid) {
-      //           if (differenceABSet.size === 0) {
-      //             return {
-      //               // 转换成string
-      //               answer: JSON.stringify(n.answers),
-      //               questionid: n._id,
-      //               questionscore: n.score,
-      //             };
-      //           }
-      //         }
-      //       });
-      //     } else {
-      //       var sc = shangchan.answers.map(a => {
-      //         //字符串判断答案
-      //         if (n._id == a.questionid) {
-      //           if (n.answers === n.answer) {
-      //             return {
-      //               answer: n.answers,
-      //               questionid: n._id,
-      //               questionscore: n.score,
-      //             };
-      //           }
-      //         }
-      //       });
-      //     }
-      //     //合并数组
-      //     newsc = [...sc, ...newsc];
-      //     var arr = newsc.filter(item => item);
-      //     answerss.answers = arr;
-      //   });
-      // }
-      // let res = await this.Uploadtaskupdates(answerss);
+          if (n.type == 1) {
+            // a b array类型
+            let a = n.answer.split(';');
+            let b = n.answers;
+
+            let c = new Set(a);
+            let d = new Set(b);
+
+            let differenceABSet = new Set([...d].filter(x => !c.has(x)));
+
+            var sc = this.datilist.question.map(a => {
+              if (n._id == a._id) {
+                if (differenceABSet.size === 0) {
+                  console.log(n.answers);
+
+                  return {
+                    // 转换成string
+                    // answer: JSON.stringify(n.answers),
+
+                    answer: JSON.stringify(n.answers),
+                    questionid: n._id,
+                    questionscore: n.score,
+                  };
+                } else {
+                  return {
+                    // 转换成string
+                    // answer: JSON.stringify(n.answers),
+
+                    answer: JSON.stringify(n.answers),
+                    questionid: n._id,
+                    questionscore: 0,
+                  };
+                }
+              }
+            });
+          } else {
+            console.log(this.datilist.question);
+            var sc = this.datilist.question.map(a => {
+              if (n._id == a._id) {
+                if (n.answers === n.answer) {
+                  return {
+                    answer: n.answers,
+                    questionid: n._id,
+                    questionscore: n.score,
+                  };
+                } else {
+                  return {
+                    answer: n.answers,
+                    questionid: n._id,
+                    questionscore: 0,
+                  };
+                }
+              }
+            });
+          }
+
+          newsc = [...sc, ...newsc];
+
+          console.log(newsc);
+          var arr = newsc.filter(item => item);
+          answerss.answers = arr;
+          console.log(answerss);
+        });
+        console.log(answerss);
+
+        let res = await this.Uploadtaskadd(answerss);
+      }
     },
   },
 };