|
|
@@ -1,20 +1,21 @@
|
|
|
<template>
|
|
|
<div class="course_tree">
|
|
|
- <div v-for="(courseItem, courseIndex) in courseList" :key="courseIndex">
|
|
|
+ <div v-for="(courseItem, courseIndex) in treeList" :key="courseIndex">
|
|
|
<div v-if="courseItem.courseList" class="teacherList_name">
|
|
|
- <div v-for="(tea, index) in courseItem.courseList" :key="index" class="names"
|
|
|
- :class="{ nactive: teaIndex == index }" @click="activeFunc(tea.courseId, index)">
|
|
|
+ <div v-for="tea in courseItem.courseList" :key="tea.courseId" class="names"
|
|
|
+ :class="{ nactive: tea.courseId == courseItem.courseId }"
|
|
|
+ @click="activeFunc(tea.courseId, courseIndex)">
|
|
|
{{ tea.aliasName }}
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div class="item__title" @click="getMenuList(courseItem)">
|
|
|
+ <div class="item__title" @click="getMenuList(courseItem)" v-if="treeList.length != 1">
|
|
|
<i :class="{
|
|
|
'el-icon-caret-right': !courseItem.showList,
|
|
|
'el-icon-caret-bottom': courseItem.showList,
|
|
|
}"></i>
|
|
|
{{ courseItem.courseName }}
|
|
|
</div>
|
|
|
- <div v-if="courseItem.showList" style="padding-left:12px">
|
|
|
+ <div v-if="courseItem.showList" :style="{ paddingLeft: (treeList.length != 1 ? '12px' : '0') }">
|
|
|
<div class="item" v-for="(menu, index) in courseItem.list" :key="index">
|
|
|
<template v-if="menu.type == 1">
|
|
|
<div class="item__title" @click="openModule(menu)">
|
|
|
@@ -45,7 +46,8 @@
|
|
|
active: isActive(section),
|
|
|
}" v-for="(
|
|
|
section, sectionIndex
|
|
|
- ) in chapter.list" :key="sectionIndex" @click="getResource(section, 1)">
|
|
|
+ ) in chapter.list" :key="sectionIndex"
|
|
|
+ @click="getResource(section, 1, courseIndex)">
|
|
|
<template v-if="section.type != 2">
|
|
|
<template>
|
|
|
<div class="note note--blue" v-if="
|
|
|
@@ -192,7 +194,7 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
<div v-if="chapter.type == 2" class="bank-section__item"
|
|
|
- @click="getResource(chapter, 3)">
|
|
|
+ @click="getResource(chapter, 3, courseIndex)">
|
|
|
<template>
|
|
|
<template>
|
|
|
<div class="test-btn" v-if="chapter.doType == 1">
|
|
|
@@ -238,7 +240,8 @@
|
|
|
active: isActive(section),
|
|
|
}" v-for="(
|
|
|
section, sectionIndex
|
|
|
- ) in menu.list" :key="sectionIndex" @click="getResource(section, 1)">
|
|
|
+ ) in menu.list" :key="sectionIndex"
|
|
|
+ @click="getResource(section, 1, courseIndex)">
|
|
|
<template v-if="section.type != 2">
|
|
|
<template>
|
|
|
<div class="note note--blue" v-if="
|
|
|
@@ -389,7 +392,7 @@
|
|
|
<div class="bank-section">
|
|
|
<div class="bank-section__item" :class="{
|
|
|
active: isActive(menu),
|
|
|
- }" @click="getResource(menu, 1)">
|
|
|
+ }" @click="getResource(menu, 1, courseIndex)">
|
|
|
<template>
|
|
|
<div class="note note--blue" v-if="menu.sectionType == 1">
|
|
|
视频
|
|
|
@@ -489,28 +492,77 @@ export default {
|
|
|
default: () => {
|
|
|
return []
|
|
|
}
|
|
|
+ },
|
|
|
+ goodsLearningOrder: {
|
|
|
+ type: Number
|
|
|
+ },
|
|
|
+ sectionMaxNum: {
|
|
|
+ type: Number
|
|
|
}
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
teaIndex: 0,
|
|
|
nowTime: 0,
|
|
|
+ treeList: [],
|
|
|
+ query: this.$route.query,
|
|
|
+ sectionItem: {}
|
|
|
}
|
|
|
},
|
|
|
+ created() {
|
|
|
+ this.init()
|
|
|
+ },
|
|
|
mounted() {
|
|
|
- this.nowTime = Number(new Date().getTime() / 1000).toFixed(0);
|
|
|
+
|
|
|
},
|
|
|
methods: {
|
|
|
- activeFunc() {
|
|
|
+ async init() {
|
|
|
this.nowTime = Number(new Date().getTime() / 1000).toFixed(0);
|
|
|
+ this.treeList = await this.getDoubleTeacherList()
|
|
|
+ let index = this.treeList.findIndex(e => e.courseId == this.activeCourseId)
|
|
|
+ let list = await this.getMenuList(this.treeList[index])
|
|
|
+
|
|
|
+ // 判断已选中的视频的父级
|
|
|
+ let { moduleId, chapterId, sectionId } = this.query
|
|
|
+ if (moduleId) {
|
|
|
+ list = await this.openModule(list.find(e => e.menuId == moduleId), true);
|
|
|
+ }
|
|
|
+ if (chapterId) {
|
|
|
+ list = await this.openChapter(list.find(e => e.chapterId == chapterId))
|
|
|
+ }
|
|
|
+ this.sectionItem = list.find(e => e.id == sectionId)
|
|
|
+
|
|
|
},
|
|
|
- async getMenuList(course) {
|
|
|
+ activeFunc(courseId, index) {
|
|
|
+ let { courseId: nowCourseId, courseList } = this.treeList[index]
|
|
|
+ if (courseId == nowCourseId) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (index) {
|
|
|
+ let { stuAllNum, secAllNum } = this.treeList[index - 1];
|
|
|
+ if (stuAllNum != secAllNum) {
|
|
|
+ return this.$message({
|
|
|
+ type: "warning",
|
|
|
+ message: "需按课程顺序学习",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let course = this.courseList.find(e => e.courseId == courseId)
|
|
|
+ if (course) {
|
|
|
+ course.courseList = courseList
|
|
|
+ course.list = []
|
|
|
+ course.showList = false
|
|
|
+ }
|
|
|
+ this.treeList.splice(index, 1, JSON.parse(JSON.stringify(course)))
|
|
|
+ this.getMenuList(this.treeList[index])
|
|
|
+ },
|
|
|
+ getMenuList(course) {
|
|
|
let { showList, courseId, list } = course
|
|
|
course.showList = !showList
|
|
|
if (list.length) return;
|
|
|
- this.$request
|
|
|
+ return this.$request
|
|
|
.reMenuList({ courseId, gradeId: this.gradeId })
|
|
|
- .then(async (res) => {
|
|
|
+ .then((res) => {
|
|
|
for (let i = 0; i < res.rows.length; i++) {
|
|
|
let item = res.rows[i];
|
|
|
item.id = item.menuId;
|
|
|
@@ -521,12 +573,13 @@ export default {
|
|
|
item.parent = this.menuList;
|
|
|
}
|
|
|
course.list = res.rows
|
|
|
+ return Promise.resolve(res.rows)
|
|
|
})
|
|
|
},
|
|
|
openModule(module, status = false, isAuto = false) {
|
|
|
+ console.log(module)
|
|
|
let { list, isRebuild, id, courseId, showList } = module;
|
|
|
module.showList = !showList;
|
|
|
- console.log(module.showList)
|
|
|
if (list.length) return;
|
|
|
return this.$request
|
|
|
.reChapterList({
|
|
|
@@ -545,24 +598,7 @@ export default {
|
|
|
isRebuild ? (item.isRebuild = 1) : (item.menuType = 2);
|
|
|
}
|
|
|
module.list = res.data;
|
|
|
- if (isAuto) {
|
|
|
- return Promise.resolve(res.data);
|
|
|
- }
|
|
|
- if (isRebuild) return;
|
|
|
- if (status) {
|
|
|
- const FindIndexs = module.list.findIndex((item) => {
|
|
|
- return item.chapterId == this.sectionItem.chapterId;
|
|
|
- });
|
|
|
- if (FindIndexs != -1) {
|
|
|
- this.openChapter(module.list[FindIndexs]);
|
|
|
- } else {
|
|
|
- this.$message.warning("章列表定位失败");
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (this.needOpen) {
|
|
|
- this.openChapter(module.list[0]);
|
|
|
- }
|
|
|
- }
|
|
|
+ return Promise.resolve(res.data);
|
|
|
});
|
|
|
},
|
|
|
openChapter(chapter) {
|
|
|
@@ -589,13 +625,9 @@ export default {
|
|
|
moduleId: moduleId || 0,
|
|
|
})
|
|
|
.then((res) => {
|
|
|
- chapter.canLearn = res.data.filter(item => item.type != 2).every(item => item.learning == 1)
|
|
|
+ chapter.canLearn = res.data.filter(item => item.type != 2).every(item => item.learning == 1)
|
|
|
res.data.forEach((section) => {
|
|
|
section.parent = chapter;
|
|
|
- // let { sectionId, moduleId, chapterId } = this.sectionItem
|
|
|
- // if (section.sectionId == sectionId && section.moduleId == moduleId && section.chapterId == chapterId) {
|
|
|
- // this.sectionItem = section
|
|
|
- // }
|
|
|
});
|
|
|
chapter.list = res.data;
|
|
|
if (this.needOpen) {
|
|
|
@@ -604,19 +636,233 @@ export default {
|
|
|
return Promise.resolve(chapter.list);
|
|
|
});
|
|
|
},
|
|
|
- isActive() { },
|
|
|
- getResource() { },
|
|
|
- checkSection() { }
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async getResource(section, type, courseIndex) {
|
|
|
+ if (!(await this.orderTopTobottom(section, type, courseIndex))) {
|
|
|
+ this.clickLock = false;
|
|
|
+ this.$message({
|
|
|
+ type: "warning",
|
|
|
+ message:
|
|
|
+ section.type == 2
|
|
|
+ ? "请学完视频课程再进行练习和测试"
|
|
|
+ : "请按顺序学习视频课程",
|
|
|
+ });
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (
|
|
|
+ section.sectionType === 2 &&
|
|
|
+ section.liveStartTime &&
|
|
|
+ section.liveEndTime
|
|
|
+ ) {
|
|
|
+ if (section.liveStartTime > this.nowTime) {
|
|
|
+ this.$message.warning("直播待开播");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (section.liveEndTime < this.nowTime) {
|
|
|
+ this.$message.warning("直播已结束");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ section.type == 2 ? this.toCourseExam(section) : this.toPlay()
|
|
|
+ },
|
|
|
+ async toCourseExam(section, type) {
|
|
|
+ //试卷
|
|
|
+ // 学习次数
|
|
|
+ if (!(await this.exceedLearnNum(section))) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ let num =
|
|
|
+ this.goodsLearningOrder != 2 || section.rebuild
|
|
|
+ ? await this.bankRecordDoNum(section.typeId)
|
|
|
+ : section.doNum;
|
|
|
+ if (section.answerNum - num > 0 && section.answerNum > 0 || section.answerNum == 0) {
|
|
|
+ this.$router.push({
|
|
|
+ path: "/course-exam/" + this.goodsId,
|
|
|
+ query: {
|
|
|
+ courseId: this.courseId,
|
|
|
+ gradeId: this.gradeId,
|
|
|
+ moduleId: section.moduleId || 0,
|
|
|
+ sectionId: section.sectionId || 0,
|
|
|
+ examId: section.typeId,
|
|
|
+ learning: section.learning,
|
|
|
+ type: type,
|
|
|
+ chapterId: section.chapterId || 0,
|
|
|
+ orderGoodsId: this.orderGoodsId,
|
|
|
+ },
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.$message({
|
|
|
+ type: "warning",
|
|
|
+ message: "该试卷只能答题" + section.answerNum + "次",
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async exceedLearnNum(section) {
|
|
|
+ let learnNum = await this.goodsTodayStudySectionNum();
|
|
|
+ let hasLearn = await this.gradeCheckGoodsStudy(section.typeId);
|
|
|
+ if (this.sectionMaxNum > 0) {
|
|
|
+ if (learnNum >= this.sectionMaxNum && !hasLearn) {
|
|
|
+ this.$message({
|
|
|
+ type: "warning",
|
|
|
+ message: `每天最多学习${this.sectionMaxNum}节`,
|
|
|
+ });
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ },
|
|
|
+ goodsTodayStudySectionNum(option) {
|
|
|
+ return new Promise((resolve) => {
|
|
|
+ this.$request
|
|
|
+ .goodsTodayStudySectionNum({
|
|
|
+ goodsId: this.goodsId,
|
|
|
+ gradeId: this.gradeId,
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ resolve(res.data);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ gradeCheckGoodsStudy(option) {
|
|
|
+ return new Promise((resolve) => {
|
|
|
+ this.$request
|
|
|
+ .gradeCheckGoodsStudy({
|
|
|
+ goodsId: this.goodsId,
|
|
|
+ gradeId: this.gradeId,
|
|
|
+ moduleId: option.moduleId || 0,
|
|
|
+ chapterId: option.chapterId || 0,
|
|
|
+ sectionId: option.sectionId || option.menuId,
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ resolve(res.data);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ bankRecordDoNum(section) {
|
|
|
+ return new Promise((resolve) => {
|
|
|
+ this.$request
|
|
|
+ .bankRecordDoNum({
|
|
|
+ goodsId: this.goodsId,
|
|
|
+ gradeId: this.gradeId,
|
|
|
+ chapterId: section.chapterId,
|
|
|
+ courseId: this.courseId,
|
|
|
+ moduleId: 0,
|
|
|
+ examId: section.typeId,
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ resolve(res.data);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ toPlay() {
|
|
|
+ // this.$emit('getResource', section, type)
|
|
|
+ },
|
|
|
+ checkSection() { },
|
|
|
+ //获取商品双师资模板
|
|
|
+ getDoubleTeacherList() {
|
|
|
+ let rows = JSON.parse(JSON.stringify(this.courseList))
|
|
|
+ rows.forEach(e => {
|
|
|
+ e.list = []
|
|
|
+ e.showList = false
|
|
|
+ })
|
|
|
+ return this.$request
|
|
|
+ .courseTeacherList({
|
|
|
+ goodsId: this.$route.params.goodsId,
|
|
|
+ })
|
|
|
+ .then(({ data }) => {
|
|
|
+ data.forEach(ele => {
|
|
|
+ rows.forEach((e, i) => {
|
|
|
+ let actvieIndex = ele.courseIds.indexOf(this.activeCourseId)
|
|
|
+ let index = ele.courseIds.indexOf(e.courseId)
|
|
|
+ if (actvieIndex != -1 && index != -1) {
|
|
|
+ if (e.courseId == this.activeCourseId) {
|
|
|
+ e.courseList = ele.courseList
|
|
|
+ } else {
|
|
|
+ delete rows[i]
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (index == 0) {
|
|
|
+ e.courseList = ele.courseList
|
|
|
+ }
|
|
|
+ if (index > 0) {
|
|
|
+ delete rows[i]
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ })
|
|
|
+ })
|
|
|
+ return Promise.resolve(rows.filter(e => e))
|
|
|
+ });
|
|
|
+ },
|
|
|
+ async orderTopTobottom(section, type, courseIndex) {
|
|
|
+ let { rebuild, moduleId, chapterId } = section;
|
|
|
+ if (this.goodsLearningOrder != 2 || rebuild) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if (this.treeList.length > 1 && courseIndex > 0) {
|
|
|
+ let isAllLear = this.treeList.filter((e, i) => i < courseIndex).every(ele => ele.stuAllNum == ele.secAllNum)
|
|
|
+ if (!isAllLear) return false
|
|
|
+ }
|
|
|
+ let list = await this.studyRecordMenuAllList(this.treeList[courseIndex].courseId);
|
|
|
+ type = type == 1 && section.type == 2 ? 2 : type;
|
|
|
+ if (type == 1) {
|
|
|
+ let index = list.findIndex(
|
|
|
+ (e) =>
|
|
|
+ e.moduleId == moduleId &&
|
|
|
+ e.chapterId == chapterId &&
|
|
|
+ e.id == section.sectionId
|
|
|
+ );
|
|
|
+ list = list.slice(0, index);
|
|
|
+ } else if (type != 3) {
|
|
|
+ list = list.filter(
|
|
|
+ (e) => e.moduleId == moduleId && e.chapterId == chapterId
|
|
|
+ );
|
|
|
+ }
|
|
|
+ return list.every((item) => item.studyStatus == 1);
|
|
|
+ },
|
|
|
+ studyRecordMenuAllList(courseId) {
|
|
|
+ return new Promise((resolve) => {
|
|
|
+ this.$request
|
|
|
+ .studyRecordMenuAllList({
|
|
|
+ courseId,
|
|
|
+ gradeId: this.gradeId,
|
|
|
+ goodsId: this.goodsId,
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ resolve(res.data);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
},
|
|
|
computed: {
|
|
|
gradeId() {
|
|
|
- return this.$route.query.gradeId
|
|
|
+ return this.query.gradeId
|
|
|
+ },
|
|
|
+ activeCourseId() {
|
|
|
+ return this.query.courseId
|
|
|
+ },
|
|
|
+ goodsId() {
|
|
|
+ return this.$route.params.goodsId;
|
|
|
}
|
|
|
},
|
|
|
watch: {
|
|
|
courseList: {
|
|
|
- handler(newVal, oldVal) {
|
|
|
- // console.log(newVal, 'newVal')
|
|
|
+ async handler(newVal, oldVal) {
|
|
|
+
|
|
|
},
|
|
|
deep: true,
|
|
|
immediate: true
|