Explorar o código

fix: 修改新建课程和更新课程的bug

mjh %!s(int64=4) %!d(string=hai) anos
pai
achega
0dce34537c

+ 0 - 457
src/api/mock.js

@@ -1,457 +0,0 @@
-const getAllEvalExams = function () {
-  return {
-    data: {
-      data: {
-        "examVOList": [
-          {
-            "examId": 23,
-            "examName": "smart-test3",
-            "position": "backend",
-            "skills": [
-              "Java"
-            ],
-            "difficulty": 0,
-            "startTime": "2022-02-28 23:30:00",
-            "endTime": "2022-02-28 23:37:00",
-            "comment": "",
-            "inviteCode": "",
-            "creatorId": 1480,
-            "antiCheating": false,
-            "isJoined": false,
-            "isPublic": true,
-            "isHidden": false
-          },
-          {
-            "examId": 18,
-            "examName": "敏捷测试",
-            "position": "无",
-            "skills": [
-              "Java"
-            ],
-            "difficulty": 0,
-            "startTime": "2022-01-21 18:45:00",
-            "endTime": "2022-01-28 18:30:00",
-            "comment": "",
-            "inviteCode": "",
-            "creatorId": 1480,
-            "antiCheating": false,
-            "isJoined": false,
-            "isPublic": true,
-            "isHidden": false
-          },
-          {
-            "examId": 11,
-            "examName": "基于Java的面向对象编程范式-学前测试",
-            "position": "学生",
-            "skills": [
-              "Java"
-            ],
-            "difficulty": 0,
-            "startTime": "2021-11-05 14:32:00",
-            "endTime": "2021-12-31 23:59:00",
-            "comment": "",
-            "inviteCode": "",
-            "creatorId": 1480,
-            "antiCheating": false,
-            "isJoined": false,
-            "isPublic": true,
-            "isHidden": false
-          },
-          {
-            "examId": 8,
-            "examName": "软件工程测试",
-            "position": "seecoder",
-            "skills": [
-              "Java",
-              "JavaScript"
-            ],
-            "difficulty": 0,
-            "startTime": "2021-11-02 20:00:00",
-            "endTime": "2021-11-03 20:00:00",
-            "comment": "软件工程第一次测试",
-            "inviteCode": "urethrae",
-            "creatorId": 1480,
-            "antiCheating": false,
-            "isJoined": false,
-            "isPublic": false,
-            "isHidden": false
-          },
-          {
-            "examId": 9,
-            "examName": "设计模式测试",
-            "position": "设计师",
-            "skills": [
-              "Vue"
-            ],
-            "difficulty": 0,
-            "startTime": "2021-11-02 20:00:00",
-            "endTime": "2021-11-03 20:00:00",
-            "comment": "设计模式练习",
-            "inviteCode": "",
-            "creatorId": 1480,
-            "antiCheating": false,
-            "isJoined": false,
-            "isPublic": true,
-            "isHidden": false
-          },
-          {
-            "examId": 10,
-            "examName": "软件过程测试",
-            "position": "荣老师的学生",
-            "skills": [
-              "Go",
-              "Python"
-            ],
-            "difficulty": 0,
-            "startTime": "2021-11-02 20:00:00",
-            "endTime": "2021-11-03 20:00:00",
-            "comment": "软件过程要好好学",
-            "inviteCode": "",
-            "creatorId": 1480,
-            "antiCheating": false,
-            "isJoined": false,
-            "isPublic": true,
-            "isHidden": false
-          }
-        ],
-        "totalNum": 6
-      }
-    }
-  };
-};
-
-const getAllCourses = function () {
-  return {
-    data: {
-      data: [
-        {
-          "id": 37,
-          "name": "2022-2",
-          "teacher": {
-            "id": 3117,
-            "phone": "13382405535",
-            "username": "PortalTestTeacher",
-            "name": "PortalTestTeacher",
-            "email": "m15256072859@163.com",
-            "photo": null,
-            "role": "TEACHER",
-            "signature": "无",
-            "createdTime": "2022-02-21T13:21:26.171+08:00",
-            "valid": true
-          },
-          "semester": "2022春",
-          "imageUrl": null,
-          "description": "minim eu sit Lorem as minim eu sit Lorem as minim eu sit Lorem as ",
-          "startTime": "2022-02-28T11:08:07.608+08:00",
-          "endTime": "2022-02-28T11:08:07.608+08:00",
-          "invitationCode": "3117-4",
-          "moocUrl": null,
-          "evalId": null,
-          "coderId": 12,
-          "helperId": null,
-          "createdTime": "2022-02-20T11:54:34.084+08:00",
-          "price": 0,
-          "courseState": "NORMAL"
-        },
-        {
-          "id": 42,
-          "name": "redrew",
-          "teacher": {
-            "id": 3117,
-            "phone": "13382405535",
-            "username": "PortalTestTeacher",
-            "name": "PortalTestTeacher",
-            "email": "m15256072859@163.com",
-            "photo": null,
-            "role": "TEACHER",
-            "signature": "无",
-            "createdTime": "2022-02-21T13:21:26.171+08:00",
-            "valid": true
-          },
-          "semester": "2023春",
-          "imageUrl": null,
-          "description": "redrew",
-          "startTime": "2022-02-28T16:52:27.67+08:00",
-          "endTime": "2022-02-28T16:52:27.67+08:00",
-          "invitationCode": "fd sfs",
-          "moocUrl": "",
-          "evalId": null,
-          "coderId": 17,
-          "helperId": null,
-          "createdTime": "2022-02-28T16:52:06.235+08:00",
-          "price": 0,
-          "courseState": "NORMAL"
-        },
-        {
-          "id": 44,
-          "name": "rewrite",
-          "teacher": {
-            "id": 3117,
-            "phone": "13382405535",
-            "username": "PortalTestTeacher",
-            "name": "PortalTestTeacher",
-            "email": "m15256072859@163.com",
-            "photo": null,
-            "role": "TEACHER",
-            "signature": "无",
-            "createdTime": "2022-02-21T13:21:26.171+08:00",
-            "valid": true
-          },
-          "semester": "2022春",
-          "imageUrl": null,
-          "description": "rewriter",
-          "startTime": "2022-02-28T21:46:24.307+08:00",
-          "endTime": "2022-02-28T21:46:24.307+08:00",
-          "invitationCode": "rewriterule",
-          "moocUrl": null,
-          "evalId": null,
-          "coderId": 19,
-          "helperId": null,
-          "createdTime": "2022-02-28T21:46:24.008+08:00",
-          "price": 0,
-          "courseState": "NORMAL"
-        },
-        {
-          "id": 3,
-          "name": "提象何角众交",
-          "teacher": {
-            "id": 1481,
-            "phone": "17301585267",
-            "username": "seecoder",
-            "name": "root",
-            "email": "seecoder@163.com",
-            "photo": null,
-            "role": "ADMIN",
-            "signature": "无",
-            "createdTime": "2021-08-26T14:24:37.859+08:00",
-            "valid": true
-          },
-          "semester": "2022春",
-          "imageUrl": "https://lain.bgm.tv/pic/cover/l/60/4d/325585_HHZpF.jpg",
-          "description": "minim eu sit Lorem",
-          "startTime": "2022-02-24T10:24:18.129+08:00",
-          "endTime": "2022-02-24T10:24:18.129+08:00",
-          "invitationCode": "15",
-          "moocUrl": null,
-          "evalId": null,
-          "coderId": null,
-          "helperId": null,
-          "createdTime": "2022-02-20T11:54:34.084+08:00",
-          "price": 0,
-          "courseState": "NORMAL"
-        }
-      ]
-    }
-  };
-};
-
-const getAllCoderExams = function () {
-  return {
-    "data": {
-      "code": 0,
-      "data": {
-        "res": [
-          {
-            "creator": {
-              "id": 271,
-              "username": "kenny67nju"
-            },
-            "joined": false,
-            "created_at": 1646636481,
-            "endAt": 1646755200,
-            "url": null,
-            "result": null,
-            "name": "作业3内测",
-            "course": "软件工程与计算-I-2022-内测",
-            "id": 1273,
-            "courseId": 2,
-            "startAt": 1646582400,
-            "status": "AVAILABLE",
-            "problems": [
-              {
-                "name": "ValidateInput",
-                "description": "ValidateInput",
-                "id": 11,
-                "type": "PYTHON"
-              },
-              {
-                "name": "LogoPlus",
-                "description": "LogoPlus",
-                "id": 10,
-                "type": "PYTHON"
-              }
-            ]
-          },
-          {
-            "creator": {
-              "id": 271,
-              "username": "kenny67nju"
-            },
-            "joined": false,
-            "created_at": 1646065877,
-            "endAt": 1646582399,
-            "url": null,
-            "result": null,
-            "name": "作业2",
-            "course": "软件工程与计算-I-2022",
-            "id": 959,
-            "courseId": 3,
-            "startAt": 1646064000,
-            "status": "CLOSED",
-            "problems": [
-              {
-                "name": "MaximumDifference",
-                "description": "MaximumDifference",
-                "id": 8,
-                "type": "PYTHON"
-              },
-              {
-                "name": "Logo",
-                "description": "Logo",
-                "id": 9,
-                "type": "PYTHON"
-              }
-            ]
-          },
-          {
-            "creator": {
-              "id": 271,
-              "username": "kenny67nju"
-            },
-            "joined": false,
-            "created_at": 1646034591,
-            "endAt": 1646150399,
-            "url": null,
-            "result": null,
-            "name": "作业2内测",
-            "course": "软件工程与计算-I-2022-内测",
-            "id": 948,
-            "courseId": 2,
-            "startAt": 1645977600,
-            "status": "CLOSED",
-            "problems": [
-              {
-                "name": "MaximumDifference",
-                "description": "MaximumDifference",
-                "id": 8,
-                "type": "PYTHON"
-              },
-              {
-                "name": "Logo",
-                "description": "Logo",
-                "id": 9,
-                "type": "PYTHON"
-              }
-            ]
-          },
-          {
-            "creator": {
-              "id": 271,
-              "username": "kenny67nju"
-            },
-            "joined": false,
-            "created_at": 1645372587,
-            "endAt": 1645977600,
-            "url": null,
-            "result": null,
-            "name": "作业1",
-            "course": "软件工程与计算-I-2022",
-            "id": 437,
-            "courseId": 3,
-            "startAt": 1645286400,
-            "status": "CLOSED",
-            "problems": [
-              {
-                "name": "buy_lolipop",
-                "description": "buy_lolipop",
-                "id": 6,
-                "type": "PYTHON"
-              },
-              {
-                "name": "flight",
-                "description": "Flight",
-                "id": 7,
-                "type": "PYTHON"
-              }
-            ]
-          },
-          {
-            "creator": {
-              "id": 271,
-              "username": "kenny67nju"
-            },
-            "joined": false,
-            "created_at": 1645337694,
-            "endAt": 1645372800,
-            "url": null,
-            "result": null,
-            "name": "lab0测试",
-            "course": "软件工程与计算-I-2022-内测",
-            "id": 418,
-            "courseId": 2,
-            "startAt": 1645286400,
-            "status": "CLOSED",
-            "problems": [
-              {
-                "name": "buy_lolipop",
-                "description": "buy_lolipop",
-                "id": 6,
-                "type": "PYTHON"
-              },
-              {
-                "name": "flight",
-                "description": "Flight",
-                "id": 7,
-                "type": "PYTHON"
-              }
-            ]
-          },
-          {
-            "creator": {
-              "id": 271,
-              "username": "kenny67nju"
-            },
-            "joined": false,
-            "created_at": 1645251063,
-            "endAt": 1645286400,
-            "url": null,
-            "result": null,
-            "name": "lab0内测",
-            "course": "软件工程与计算-I-2022-内测",
-            "id": 393,
-            "courseId": 2,
-            "startAt": 1645200000,
-            "status": "CLOSED",
-            "problems": [
-              {
-                "name": "buy_lolipop",
-                "description": "buy_lolipop",
-                "id": 6,
-                "type": "PYTHON"
-              },
-              {
-                "name": "flight",
-                "description": "Flight",
-                "id": 7,
-                "type": "PYTHON"
-              }
-            ]
-          }
-        ],
-        "err": 0,
-        "page": {
-          "total": 6,
-          "size": 6,
-          "limit": 10,
-          "page": 1
-        }
-      }
-    }
-  };
-};
-
-const mockAPIs = {
-
-};
-
-export default mockAPIs;

+ 84 - 63
src/components/TestCard.vue

@@ -25,7 +25,7 @@
         <el-tag v-else-if="state==='CLOSED'" size="small" type="info">已关闭</el-tag>
       </el-col>
     </el-row>
-<!--    {{testVO}}-->
+    <!--    {{testVO}}-->
     <el-row class="course" v-if="course!==''">
       {{ course }}
     </el-row>
@@ -45,7 +45,7 @@
 </template>
 
 <script>
-import { ElMessage, ElMessageBox } from "element-plus";
+import {ElMessage, ElMessageBox} from "element-plus";
 import store from "@/store";
 
 export default {
@@ -62,6 +62,19 @@ export default {
     isLogin() {
       return store.state.user.token;
     },
+    isCreator() {
+      if (this.testVO.examId) {
+        return Number(this.testVO.course.teacherId) === Number(this.$store.state.user.id);
+      }else{
+        return this.testVO.creator.username === this.$store.state.user.phone;
+      }
+    },
+    isTeacher() {
+      return this.$store.getters.isTeacher;
+    },
+    isStudent() {
+      return this.$store.getters.isStudent;
+    },
     type() {
       if (this.testVO.examId) {
         return "eval";
@@ -132,7 +145,7 @@ export default {
       if (res.data.code === 0) {
         this.teacher = res.data.data;
       } else {
-        this.teacher = { name: this.testVO.creator.username };
+        this.teacher = {name: this.testVO.creator.username};
       }
     }
   },
@@ -154,79 +167,87 @@ export default {
           type: "warning",
           duration: 1000,
         });
-        await this.$router.push({ name: "Auth", params: { login_to: "/portal" } });
+        await this.$router.push({name: "Auth", params: {login_to: "/portal"}});
         return;
       }
 
-      let messageBoxContent = "";
-      let messageBoxTitle = "";
-      let confirmButtonText = "";
-      let cancelButtonText = "让我想想";
-      let nextURL = "";
-
-      if (this.type === "eval") {
-        messageBoxTitle = "Eval";
-        if (this.testVO.isJoined) {
-          nextURL = "https://eval.seec.seecoder.cn/exam/" + this.testVO.id + "/before-exam/?id_token=" + this.$store.state.user.token;
-          window.open(nextURL);
-          return;
+      if (this.isCreator) {
+        if (this.type === "eval") {
+          window.open("https://eval.seec.seecoder.cn/teacher/exam/" + this.testVO.examId + "/details?id_token" + this.$store.state.user.token);
         } else {
-          const courseId = (await this.$apis.getCourseByEvalId(this.testVO.course.id)).data.data;
-          if (courseId) {
-            const isCourseSelected = (await this.$apis.checkCourseSelection(courseId, this.$store.state.user.id)).data.data;
-            if (isCourseSelected) {
-              messageBoxContent = "尚未参加该测试,是否立即参加?";
-              confirmButtonText = "立即参加";
-              nextURL = "https://eval.seec.seecoder.cn/student/home/?id_token=" + this.$store.state.user.token;
+          window.open("https://coder.seec.seecoder.cn/exam/" + this.testVO.id + "?id_token=" + this.$store.state.user.token);
+        }
+      } else if (this.isTeacher) {
+        this.$message.error("无权访问其他教师创建的课程");
+      } else {
+        let messageBoxContent = "";
+        let messageBoxTitle = "";
+        let confirmButtonText = "";
+        let cancelButtonText = "让我想想";
+        let nextURL = "";
+        if (this.type === "eval") {
+          messageBoxTitle = "Eval";
+          if (this.testVO.isJoined) {
+            nextURL = "https://eval.seec.seecoder.cn/exam/" + this.testVO.id + "/before-exam/?id_token=" + this.$store.state.user.token;
+            window.open(nextURL);
+            return;
+          } else {
+            const courseId = (await this.$apis.getCourseByEvalId(this.testVO.course.id)).data.data;
+            if (courseId) {
+              const isCourseSelected = (await this.$apis.checkCourseSelection(courseId, this.$store.state.user.id)).data.data;
+              if (isCourseSelected) {
+                messageBoxContent = "是否立即查看测试详情";
+                confirmButtonText = "立即查看";
+                nextURL = "https://eval.seec.seecoder.cn/student/home/?id_token=" + this.$store.state.user.token;
+              } else {
+                messageBoxContent = "尚未参加课程,是否立即参加?";
+                confirmButtonText = "立即选课";
+                nextURL = "/course/" + courseId;
+              }
             } else {
-              messageBoxContent = "尚未参加该课程,是否立即参加?";
-              confirmButtonText = "立即选课";
-              nextURL = "/course/" + courseId;
+              messageBoxContent = "是否立即查看测试详情";
+              confirmButtonText = "立即查看";
+              nextURL = "https://eval.seec.seecoder.cn/student/home/?id_token=" + this.$store.state.user.token;
             }
-          } else {
-            messageBoxContent = "尚未参加该测试,是否立即参加?";
-            confirmButtonText = "立即参加";
-            nextURL = "https://eval.seec.seecoder.cn/student/home/?id_token=" + this.$store.state.user.token;
           }
-        }
-      } else {
-        messageBoxTitle = "Coder";
-        if (this.testVO.joined) {
-          nextURL = "https://coder.seec.seecoder.cn/exam/" + this.testVO.id + "?id_token=" + this.$store.state.user.token;
-          window.open(nextURL);
-          return;
         } else {
-          const courseId = (await this.$apis.getCourseByCoderId(this.testVO.courseId)).data.data;
-          if (courseId) {
-            const isCourseSelected = (await this.$apis.checkCourseSelection(courseId, this.$store.state.user.id)).data.data;
-            if (isCourseSelected) {
-              messageBoxContent = "尚未参加该测试,是否立即参加?";
-              confirmButtonText = "立即参加";
-              nextURL = "https://coder.seec.seecoder.cn/exam?id_token=" + this.$store.state.user.token;
+          messageBoxTitle = "Coder";
+          if (this.testVO.joined) {
+            nextURL = "https://coder.seec.seecoder.cn/exam/" + this.testVO.id + "?id_token=" + this.$store.state.user.token;
+            window.open(nextURL);
+            return;
+          } else {
+            const courseId = (await this.$apis.getCourseByCoderId(this.testVO.courseId)).data.data;
+            if (courseId) {
+              const isCourseSelected = (await this.$apis.checkCourseSelection(courseId, this.$store.state.user.id)).data.data;
+              if (isCourseSelected) {
+                messageBoxContent = "是否立即查看测试详情";
+                confirmButtonText = "立即查看";
+                nextURL = "https://coder.seec.seecoder.cn/exam?id_token=" + this.$store.state.user.token;
+              } else {
+                messageBoxContent = "尚未选择课程,是否立即参加?";
+                confirmButtonText = "立即选课";
+                nextURL = "/course/" + courseId;
+              }
             } else {
-              messageBoxContent = "尚未选择该课程,是否立即参加?";
-              confirmButtonText = "立即选课";
-              nextURL = "/course/" + courseId;
+              messageBoxContent = "是否立即查看测试详情";
+              confirmButtonText = "立即查看";
+              nextURL = "https://coder.seec.seecoder.cn/exam?id_token=" + this.$store.state.user.token;
             }
-          } else {
-            messageBoxContent = "尚未参加该测试,是否立即参加?";
-            confirmButtonText = "立即参加";
-            nextURL = "https://coder.seec.seecoder.cn/exam?id_token=" + this.$store.state.user.token;
           }
         }
+        ElMessageBox.confirm(messageBoxContent, messageBoxTitle, {
+          distinguishCancelAndClose: true,
+          confirmButtonText,
+          cancelButtonText,
+        }).then(() => {
+          if (nextURL.startsWith("http")) {
+            window.open(nextURL);
+          } else {
+            this.$router.push(nextURL);
+          }
+        });
       }
-
-      ElMessageBox.confirm(messageBoxContent, messageBoxTitle, {
-        distinguishCancelAndClose: true,
-        confirmButtonText,
-        cancelButtonText,
-      }).then(() => {
-        if (nextURL.startsWith("http")) {
-          window.open(nextURL);
-        } else {
-          this.$router.push(nextURL);
-        }
-      });
     },
   }
 };

+ 0 - 4
src/views/CoursePage/CourseDetail.vue

@@ -633,7 +633,6 @@ export default {
               .then((res) => {
                 if (res.data.code === -1) {
                   ElMessage.error("选课失败");
-                  console.log(res.data.message);
                 } else {
                   ElMessage.success("选课成功");
                   setTimeout(function () {
@@ -657,14 +656,12 @@ export default {
             }
           )
             .then(res => {
-              console.log(res);
               ElMessage.success("退课成功");
               setTimeout(function () {
                 location.reload();
               }, 500);
             })
             .catch(err => {
-              console.log("handleCancelCourse: " + err);
               ElMessage.error("handleCancelCourse: " + err);
             });
         })
@@ -715,7 +712,6 @@ export default {
           this.$apis.getCommentsByCourseId(this.$route.params.id)
             .then(res => {
               this.commentTree = res.data.data;
-              console.log(this.commentTree);
             })
             .catch();
           break;

+ 61 - 40
src/views/ManagePage/ManagePage.vue

@@ -175,9 +175,9 @@
 
 <script>
 import CourseCard from "@/components/CourseCard";
-import { ElMessage, ElMessageBox } from "element-plus";
+import {ElMessage, ElMessageBox} from "element-plus";
 import client from "@/utils/oss";
-import { Back, Document } from "@element-plus/icons-vue";
+import {Back, Document} from "@element-plus/icons-vue";
 import TestCard from "@/components/TestCard";
 
 export default {
@@ -254,16 +254,16 @@ export default {
           required: true, validator: validateName, trigger: "blur",
         },
         year: {
-          required: true, message: "请选择年份", trigger: "change",
+          required: true, message: "请选择年份", trigger: "blur",
         },
         season: {
-          required: true, message: "请选择季节", trigger: "change",
+          required: true, message: "请选择季节", trigger: "blur",
         },
         description: {
           required: true, message: "请输入课程简介", trigger: "blur",
         },
         time: {
-          required: true, validator: validateTime, trigger: "change",
+          required: true, validator: validateTime, trigger: "blur",
         },
         invitationCode: {
           required: true, validator: validateCode, trigger: "blur",
@@ -277,19 +277,19 @@ export default {
       myCourseList: [],
       courseType: "all",
       courseTypeOptions: [
-        { value: "all", label: "全部课程" },
-        { value: "pending", label: "未开始" },
-        { value: "start", label: "正在进行" },
-        { value: "end", label: "已结束" },
+        {value: "all", label: "全部课程"},
+        {value: "pending", label: "未开始"},
+        {value: "start", label: "正在进行"},
+        {value: "end", label: "已结束"},
       ],
       evalExamList: [],
       coderExamList: [],
       examType: "all",
       examTypeOptions: [
-        { value: "all", label: "全部测试" },
-        { value: "pending", label: "未开始" },
-        { value: "start", label: "正在进行" },
-        { value: "end", label: "已结束" },
+        {value: "all", label: "全部测试"},
+        {value: "pending", label: "未开始"},
+        {value: "start", label: "正在进行"},
+        {value: "end", label: "已结束"},
       ],
     };
   },
@@ -311,10 +311,10 @@ export default {
         this.$router.push("portal");
       }
       if (index === "1") {
-        document.getElementById("app").scrollIntoView({ behavior: "smooth" });
+        document.getElementById("app").scrollIntoView({behavior: "smooth"});
       }
       if (index === "2") {
-        document.querySelector("#manage-page-divider").scrollIntoView({ behavior: "smooth" });
+        document.querySelector("#manage-page-divider").scrollIntoView({behavior: "smooth"});
       }
       this.activeIndex = index;
     },
@@ -345,6 +345,7 @@ export default {
       });
 
       function createOrUpdateCourse() {
+        console.log(_this.form);
         if (_this.form.id === null) {
           _this.$apis.createCourse({
             name: _this.form.name,
@@ -366,11 +367,7 @@ export default {
             .then((res) => {
               _this.myCourseList.push(res.data.data);
               _this.dialogVisible = false;
-              _this.$refs.formRef.resetFields();
-              _this.form.courseTime = [null, null];
-              _this.form.fileList = [];
-              _this.form.coderLink = false;
-              _this.form.evalLink = false;
+              _this.clearForm();
               ElMessage.success("新建课程成功");
             })
             .catch(err => {
@@ -397,11 +394,7 @@ export default {
               }
               _this.$refs["courseCard" + _this.form.id][0].$props.courseVO = res.data.data;
               _this.dialogVisible = false;
-              _this.$refs.formRef.resetFields();
-              _this.form.courseTime = [null, null];
-              _this.form.fileList = [];
-              _this.form.coderLink = false;
-              _this.form.evalLink = false;
+              _this.clearForm();
               ElMessage.success("更新课程成功");
             })
             .catch(err => {
@@ -420,16 +413,29 @@ export default {
       })
         .then(() => {
           this.dialogVisible = false;
-          this.$refs.formRef.resetFields();
-          this.form.courseTime = [null, null];
-          this.form.fileList = [];
-          this.form.coderLink = false;
-          this.form.evalLink = false;
+          this.clearForm();
         })
         .catch((err) => {
           console.log(err);
         });
     },
+    clearForm() {
+      this.form = {
+        id: null,
+        name: "",
+        year: "",
+        season: "",
+        description: "",
+        courseTime: [null, null],
+        invitationCode: "",
+        price: "0",//input均会将Number类型转化成为字符串类型
+        moocUrl: null,
+        fileList: [],
+        imageUrl: null,
+        coderLink: false,
+        evalLink: false,
+      };
+    },
     // el-upload相关的方法
     handleChange(file, fileList) {
       this.form.fileList = fileList;
@@ -478,17 +484,32 @@ export default {
       if (item.state === "EXAMPLE") {
         ElMessage.error("无法删除示例课程");
       } else {
-        this.$apis.deleteCourse(item.id)
-          .then(res => {
-            for (let i = 0; i < this.myCourseList.length; i++) {
-              if (this.myCourseList[i].id === item.id) {
-                this.myCourseList.splice(i, 1);
-              }
-            }
-            ElMessage.success(res.data.data);
+        ElMessageBox.confirm(
+          "确定删除课程",
+          "Warning",
+          {
+            confirmButtonText: "立即删除",
+            cancelButtonText: "让我想想",
+            type: "warning",
+            center: true,
+          }
+        )
+          .then(() => {
+            this.$apis.deleteCourse(item.id)
+              .then(res => {
+                for (let i = 0; i < this.myCourseList.length; i++) {
+                  if (this.myCourseList[i].id === item.id) {
+                    this.myCourseList.splice(i, 1);
+                  }
+                }
+                ElMessage.success(res.data.data);
+              });
           })
-          .catch(err => {
-            ElMessage.error(err);
+          .catch(() => {
+            ElMessage({
+              type: "info",
+              message: "取消删除",
+            });
           });
       }
     },

+ 6 - 5
src/views/TaskPage/TaskPage.vue

@@ -144,7 +144,7 @@ const options = [
 ];
 export default {
   name: "TaskPage",
-  components: { TestCard },
+  components: {TestCard},
   data() {
     return {
       myEvalExamList: [],
@@ -173,7 +173,10 @@ export default {
     myTaskList() {
       let out = []
         .concat(this.myEvalExamList)
-        .concat(this.myCoderExamList);
+        .concat(this.myCoderExamList)
+        .sort((a, b) => {
+          return this.state(b).charCodeAt(0) - this.state(a).charCodeAt(0);
+        });
       switch (this.selector) {
         case "ALL":
           break;
@@ -225,10 +228,8 @@ export default {
   },
 
   async created() {
-    this.myEvalExamList = (await this.$apis.getStudentEvalExams({ state: 0 })).data.data["examVOList"];
+    this.myEvalExamList = (await this.$apis.getStudentEvalExams()).data.data;
     this.myCoderExamList = (await this.$apis.getStudentCoderExams({})).data.data["res"];
-    // this.myEvalExamList = (await this.$apis.getAllEvalExams()).data.data["examVOList"];
-    // this.myCoderExamList = (await this.$apis.getExampleCoderExams({})).data.data["res"];
   },
 
   methods: {