浏览代码

活动跳转

XW 2 年之前
父节点
当前提交
72e72aea86
共有 1 个文件被更改,包括 21 次插入9 次删除
  1. 21 9
      TEAMModelOS/ClientApp/src/components/student-web/HomeView/newHomeView.vue

+ 21 - 9
TEAMModelOS/ClientApp/src/components/student-web/HomeView/newHomeView.vue

@@ -641,13 +641,24 @@ export default {
             })
         },
         sentSelectedEventTitle(item) {
-            let index =  this.getCourseIndex(item.subjects)
-            this.$EventBus.$emit('classIndex', index + 1)
-            let path = item.type === 'Exam' ? '/studentWeb/examView' : (item.type === 'Homework' ? '/studentWeb/homeworkView' : '/studentWeb/eventView')
-            this.$router.push({
-                path,
-                query: {aId: item.id}
-            })
+            if(item.type === "Exam" || item.type === "Homework") {
+                let index =  this.getCourseIndex(item.subjects, item.classIds)
+                if(index === -1) {
+                    this.$Message.error("未找到发布该活动的课程")
+                } else {
+                    this.$EventBus.$emit('classIndex', index + 1)
+                    let path = item.type === 'Exam' ? '/studentWeb/examView' : '/studentWeb/homeworkView'
+                    this.$router.push({
+                        path,
+                        query: {aId: item.id}
+                    })
+                }
+            } else {
+                this.$router.push({
+                    path: '/studentWeb/eventView',
+                    query: {aId: item.id}
+                })
+            }
         },
         toRecord(item) {
             let index =  this.getCourseIndex([item.courseId])
@@ -699,9 +710,10 @@ export default {
                 })
             }
         },
-        getCourseIndex(ids) {
+        getCourseIndex(ids, classIds) {
             return this.getAllCourse.findIndex(course => {
-                return ids.includes(course.id) || ids.includes(course.subject.id)
+                // 要同时匹配课程和班级id
+                return (ids.includes(course.id) || ids.includes(course.subject.id)) && classIds.includes(course.list)
             })
         },
     },