From b0dc1a2227ea2f0f81de3175bac6f992d9158773 Mon Sep 17 00:00:00 2001 From: zhaofang <752743406@qq.com> Date: Thu, 8 Sep 2022 15:07:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Course/catalogCourseware.vue | 7 ++ src/components/Course/courseForm.vue | 91 ++++++++++++++++++++- src/components/Course/weikeContent.vue | 68 +++++++++++++++ src/views/portal/course/Index.vue | 2 +- 4 files changed, 165 insertions(+), 3 deletions(-) diff --git a/src/components/Course/catalogCourseware.vue b/src/components/Course/catalogCourseware.vue index 516c6077..7cae07fe 100644 --- a/src/components/Course/catalogCourseware.vue +++ b/src/components/Course/catalogCourseware.vue @@ -333,6 +333,7 @@ import pdfPreview from "@/components/PdfPreview/index.vue"; import audioPlayer from '@/components/AudioPlayer/index.vue'; import videoPlayer from '@/components/VideoPlayer/index.vue'; + import { deepClone, param } from "../../utils"; export default{ props: { reset:{ @@ -389,6 +390,7 @@ setupTage:0, }, homework:{courseId: '', name:'', content:'', file:'', deadTime: '', submitMode: 3}, + homeworkChange:{}, exam:{ courseId:'', contentId:'', @@ -408,7 +410,9 @@ info:'',//考试说明 paperContent:'',//试题的json字符串 }, + examChange:{}, onlyQuestion:true, + examPaperChange:{}, examPaper:{items:[]}, assess:{ countType:'权重配置', @@ -515,6 +519,7 @@ apiCourse.getHomework(this.content.id).then(res=>{ if(res.status==200){ this.homework=res.result; + this.homeworkChange = deepClone(res.result); }else if(res.status==404){ //没有找到作业信息 }else{ @@ -527,6 +532,8 @@ if(res.status==200){ this.exam=res.result; this.examPaper=JSON.parse(res.result.paperContent); + this.examChange = deepClone(res.result); + this.examPaperChange = deepClone(JSON.parse(res.result.paperContent)); }else if(res.status==404){ //没有找到作业信息 }else{ diff --git a/src/components/Course/courseForm.vue b/src/components/Course/courseForm.vue index 627d5d5f..95095e1e 100644 --- a/src/components/Course/courseForm.vue +++ b/src/components/Course/courseForm.vue @@ -156,7 +156,7 @@ -
+
@@ -350,7 +350,7 @@ - + @@ -1036,7 +1036,94 @@ export default { this.btnLoading = false; }); }, + // 判断是否有未保存的内容 + unsavedContent() { + const courseware = this.$refs.courseware; + let pass = true; + if(this.curContent.id == '') {// 新增 + if(this.curContent.contentType == 60) { // 判断作业是否保存 + if(courseware.homework.content || courseware.homework.name || courseware.homework.deadTime){ + pass = false; + } + } else if(this.curContent.contentType == 61) { //考试 + if(courseware.examPaper.items.length>1) { + pass = false; + } + if(courseware.examPaper.items[0].content != '点击编辑试题内容') { + pass = false; + } + }else if(this.curContent.contentType == 41) { //图文 + if(courseware.htmlContent.length > 7){ + pass = false; + } + }else if(this.curContent.contentType == 52) { //外部链接 + if(courseware.linkInfo.url != '') { + pass = false; + } + } + } else {// 编辑 + if(this.curContent.contentType == 60) { // 判断作业是否保存 + if(JSON.stringify(courseware.homeworkChange) !== JSON.stringify(courseware.homework)) { + pass = false; + } + } else if(this.curContent.contentType == 61) { //考试 + if(JSON.stringify(courseware.examPaper) !== JSON.stringify(courseware.examPaperChange || + JSON.stringify(courseware.exam)) !== JSON.stringify(courseware.examChange)) { + pass = false; + } + } else if(this.curContent.contentType == 41) { //图文 + if(this.curContent.content !== courseware.htmlContent) { + pass = false; + } + } else if(this.curContent.contentType == 52) { //外部链接 + if(this.curContent.content !== JSON.stringify(courseware.linkInfo)) { + pass = false; + } + } else if(this.curContent.contentType == 10 || this.curContent.contentType == 20) {// 视频 + if(this.curContent.content !== JSON.stringify(courseware.curriculumData)) { + pass = false; + } + } + } + return pass; + }, + unsavedWeiContent() { + // console.log(this.contentInfo.list,'contentInfo.list'); + // console.log(this.courseInfo,'courseInfo'); + // console.log(this.$refs.weikeContent,'weikeContent'); + const courseware = this.$refs.weikeContent; + // console.log(this.catalogTree,'this.catalogTree'); + let pass = true; + // if(this.curContent.contentType == 60) { // 判断作业是否保存 + if(JSON.stringify(courseware.homeworkChange.info) !== JSON.stringify(courseware.homework.info)) { + pass = false; + } + // } else if(this.curContent.contentType == 61) { //考试 + // if(JSON.stringify(courseware.exam.info) !== JSON.stringify(courseware.examChange.info)) { + // console.log("2222"); + // pass = false; + // } + // } else { + // if(courseware.cware.content.content !== courseware.cwareChange.content.content) { + // console.log('333'); + // pass = false; + // } + // if(courseware.cware.linkInfo.content !== courseware.cwareChange.content.content) { + // console.log('333'); + // pass = false; + // } + // } + return pass; + }, submitCourse() { + if(this.biaoke.dlgShow && !this.unsavedContent()){ + this.$message.error('您有未保存的内容,请先保存'); + return; + } + if(this.weike.dlgShow && !this.unsavedWeiContent()){ + this.$message.error('您有未保存的内容,请先保存'); + return; + } //console.log(this.resOwnerListMap[0],'this.resOwnerListMap[0]'); //return; let ownerCode=this.resOwnerListMap[0].code; diff --git a/src/components/Course/weikeContent.vue b/src/components/Course/weikeContent.vue index 1bcfd522..04d0f8bf 100644 --- a/src/components/Course/weikeContent.vue +++ b/src/components/Course/weikeContent.vue @@ -529,6 +529,7 @@ import apiCourseFile from '../../api/modules/courseFile.js'; import audioPlayer from '@/components/AudioPlayer/index.vue'; import {getType} from '../../utils/tools.js'; + import { deepClone } from "../../utils"; export default{ components:{WxEditor,simplePaper,FileUpload,pdfPreview,audioPlayer}, props: { @@ -576,6 +577,23 @@ // {id:'5',type:'scorm',name:'SCORM(Q2)',img:'el-icon-suitcase',resType: 50}, {id:'6',type:'link',name:'外部连接',img:'el-icon-link', resType: 52} ], + cwareChange:{ + show:1,//1表新添加,2表选择 + content:{id:'',contentType:0,sortIndex:1,contentRefId:'',pdfPath:''}, + findShow:false,//是否显示查询 + curType:{type:'jpg',name:''},//这一项要去掉的 + linkInfo:{ + openType:1, + url:'' + }, + curriculumData:{ + url:'', + isDrag:true, + completeSetup:0, + second:5, + setupTage:0, + }, + }, cware:{ show:1,//1表新添加,2表选择 content:{id:'',contentType:0,sortIndex:1,contentRefId:'',pdfPath:''}, @@ -609,6 +627,48 @@ submitMode: 3, } }, + homeworkChange:{ + show:1, + content:{id:'',contentType:60,sortIndex:2}, + dtime:'', + info:{ + id:'', + courseId: '', + name:'', + content:'', + file:'', + deadTime: '', + submitMode: 3, + } + }, + examChange:{ + show:1, + content:{id:'',contentType:61,sortIndex:3}, + paperJson:{items:[]}, + paperShow:false, + customerShow:false, + onlyQuestion:true, + info:{ + courseId:'', + contentId:'', + testName:this.course.name, + testDuration:30, + showAnalysis:false, + showAnswer:false, + times:1, + qnum:0,//试题数量,只是模式是随机生成试题时才会有 + arrange:0, + scoringType:1, + passLine:60, + randomMode:false, + percentScore:true, + paperType:1,//自定义试卷 + paperId:'',//试卷的id,只有paperType为2的时间才会有值 + info:'',//考试说明 + paperContent:'',//试题的json字符串 + + } + }, exam:{ show:1, content:{id:'',contentType:61,sortIndex:3}, @@ -713,6 +773,7 @@ $this.cware.curriculumData.url=con.content; } } + $this.cwareChange = deepClone($this.cware); }else if(con.sortIndex==2){ $this.homework.content=con; //查询作业信息,并显示 @@ -758,6 +819,7 @@ if(res.status==200){ this.homework.info=res.result; this.homework.show=3;//显示作业内容 + this.homeworkChange = deepClone(this.homework); }else if(res.status==404){ //没有找到作业信息 this.homework.info.id=''; @@ -773,6 +835,7 @@ this.exam.info=res.result; this.exam.paperJson=JSON.parse(res.result.paperContent); this.exam.show=9; + this.examChange = deepClone(this.exam); }else if(res.status==404){ //没有找到作业信息 //this.exam.paperJson={items:[]}; @@ -890,22 +953,26 @@ } if(index==1){ postData.content=this.cware.content; + this.cwareChange.content = deepClone(this.cware.content) if(this.cware.content.contentType==52){ if(this.cware.linkInfo.url==''){ this.$message.error("请填写外连URL地址"); return; } postData.content.content=JSON.stringify(this.cware.linkInfo); + this.cwareChange.linkInfo = deepClone(this.cware.linkInfo) }else if(this.cware.content.contentType==10 || this.cware.content.contentType==20){ if(this.cware.curriculumData.url==''){ this.$message.error("请选择课件"); return; } postData.content.content=JSON.stringify(this.cware.curriculumData); + this.cwareChange.curriculumData = deepClone(this.cware.curriculumData) } }else if(index==2){ postData.content=this.homework.content; postData.homework=this.homework.info; + this.homeworkChange = deepClone(this.homework) }else if(index==3){ postData.content=this.exam.content; //检查是不是所有的试题都有了答案 @@ -932,6 +999,7 @@ } this.exam.info.paperContent=JSON.stringify(this.exam.paperJson); postData.exam=this.exam.info; + this.examChange = deepClone(this.exam); }else if(index==4){ this.assess.content.content=JSON.stringify(this.assess.json); postData.content=this.assess.content; diff --git a/src/views/portal/course/Index.vue b/src/views/portal/course/Index.vue index 74ec1125..2618c4c3 100644 --- a/src/views/portal/course/Index.vue +++ b/src/views/portal/course/Index.vue @@ -479,11 +479,11 @@ export default { } } }, - // 分类 changeType(num) { this.types.oneSubList = []; this.types.subOne = "0"; + this.types.subTow = "0"; this.types.towSubList = []; let list = {}; if (num !== 0) {