xiejiebiao 2 years ago
parent
commit
018d0b7fcd
1 changed files with 32 additions and 27 deletions
  1. 32 27
      src/components/courseTree/CourseTree.vue

+ 32 - 27
src/components/courseTree/CourseTree.vue

@@ -467,9 +467,7 @@
                                             'sectionExamList'
                                         )
                                     ">
-                                        <div class="exercises" @click.stop="
-    handelPracticeOrRxam(menu, 3)
-                                        ">
+                                        <div class="exercises" @click.stop="handelPracticeOrRxam(menu, 3)">
                                             习题
                                             <i class="el-icon-arrow-right icons"></i>
                                         </div>
@@ -506,7 +504,9 @@ export default {
             nowTime: 0,
             treeList: [],
             query: this.$route.query,
-            sectionItem: {}
+            sectionItem: {},
+            sectionExam: [],
+            sectionExamList: []
         }
     },
     created() {
@@ -531,7 +531,7 @@ export default {
                 list = await this.openChapter(list.find(e => e.chapterId == chapterId))
             }
             this.sectionItem = list.find(e => e.id == sectionId)
-            
+            console.log(this.sectionItem, 'this.sectionItem', list, sectionId)
         },
         activeFunc(courseId, index) {
             let { courseId: nowCourseId, courseList } = this.treeList[index]
@@ -560,6 +560,15 @@ export default {
             let { showList, courseId, list } = course
             course.showList = !showList
             if (list.length) return;
+            this.$request
+                .reSectionExamList({
+                    chapterId: 0,
+                    courseId,
+                    gradeId: this.gradeId,
+                })
+                .then((res) => {
+                    this.sectionExamList = res.data;
+                });
             return this.$request
                 .reMenuList({ courseId, gradeId: this.gradeId })
                 .then((res) => {
@@ -604,15 +613,15 @@ export default {
         openChapter(chapter) {
             let { chapterId, menuId, list, moduleId, id, isRebuild, courseId, showList } = chapter;
             chapter.showList = !showList;
-            // this.$request
-            //     .reSectionExamList({
-            //         chapterId: chapterId || menuId,
-            //         courseId: this.courseId,
-            //         gradeId: this.gradeId,
-            //     })
-            //     .then((res) => {
-            //         this.sectionExam = [...this.sectionExam, ...res.data];
-            //     });
+            this.$request
+                .reSectionExamList({
+                    chapterId: chapterId || menuId,
+                    courseId,
+                    gradeId: this.gradeId,
+                })
+                .then((res) => {
+                    this.sectionExam = [...this.sectionExam, ...res.data];
+                });
             if (list.length) {
                 return;
             }
@@ -637,18 +646,7 @@ export default {
                 });
         },
         isActive(section) {
-            let moduleId = section.moduleId || 0;
-            let chapterId = section.chapterId || 0;
-            let sectionId = section.sectionId || section.menuId;
-            if (
-                moduleId == this.moduleId &&
-                chapterId == this.chapterId &&
-                sectionId == this.playSectionId
-            ) {
-                return true;
-            } else {
-                return false;
-            }
+            return section == this.sectionItem
         },
         async getResource(section, type, courseIndex) {
             if (!(await this.orderTopTobottom(section, type, courseIndex))) {
@@ -771,7 +769,6 @@ export default {
         toPlay() {
             // this.$emit('getResource', section, type)
         },
-        checkSection() { },
         //获取商品双师资模板
         getDoubleTeacherList() {
             let rows = JSON.parse(JSON.stringify(this.courseList))
@@ -847,6 +844,14 @@ export default {
                     });
             });
         },
+        //校验节是否有试卷
+        checkSection(sectionId, key) {
+            let _data = this[key];
+            if (_data.length == 0) {
+                return false;
+            }
+            return _data.some((section) => section.sectionId == sectionId);
+        },
     },
     computed: {
         gradeId() {