From fe80219cbe56d50bf0175c397bbfddf997a3dfc7 Mon Sep 17 00:00:00 2001 From: 18571350067 Date: Tue, 21 Dec 2021 20:33:07 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BE=E4=BB=B6=E4=B8=8A=E4=BC=A0=EF=BC=8C?= =?UTF-8?q?=E5=BF=85=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/course/courseware.js | 12 +- src/api/course/question/requiredQuestion.js | 54 ++++++ src/views/course/CoursewareAddOrUpdate.vue | 187 ++++++++++++-------- src/views/course/CoursewareList.vue | 22 ++- src/views/course/CoursewarePreview.vue | 53 ++++++ src/views/course/question/ExamQuestion.vue | 87 +++++++++ 6 files changed, 339 insertions(+), 76 deletions(-) create mode 100644 src/api/course/question/requiredQuestion.js create mode 100644 src/views/course/CoursewarePreview.vue create mode 100644 src/views/course/question/ExamQuestion.vue diff --git a/src/api/course/courseware.js b/src/api/course/courseware.js index 66245dd..7e96e62 100644 --- a/src/api/course/courseware.js +++ b/src/api/course/courseware.js @@ -2,7 +2,7 @@ import request from '@/utils/request' const coursewareApi = { add: '/courseManagement/xmCourseCourseware/addOrUpdate', - // get: '/courseManagement/course/details', + get: '/courseManagement/xmCourseCourseware/details', // update: 'sys/menu/update', del: 'courseManagement/xmCourseCourseware/delete', // updateStatus: 'sys/menu/updateStatus', @@ -40,4 +40,14 @@ export function coursewareClassList(params) { method: 'get', params: params }) +} + + +// 课件详情 +export function coursewareDeatil(params) { + return request({ + url: coursewareApi.get, + method: 'get', + params: params + }) } \ No newline at end of file diff --git a/src/api/course/question/requiredQuestion.js b/src/api/course/question/requiredQuestion.js new file mode 100644 index 0000000..d191bab --- /dev/null +++ b/src/api/course/question/requiredQuestion.js @@ -0,0 +1,54 @@ +import request from '@/utils/request' + +const requiredQuesitonApi = { + list: 'courseManagement/requiredQuestion/listPage', + addOrUpdate: '/courseManagement/requiredQuestion/addOrUpdate', + requiredQuestionId:'courseManagement/requiredQuestion/requiredQuestionId', + // questionList:'/courseManagement/course/questionList', +} + + +// 必选题列表 +export function requiredList(params) { + return request({ + url: requiredQuesitonApi.list, + method: 'get', + params: params + }) +} + +// 必选题新增和设置 +export function addOrUpdate(params) { + return request({ + url: requiredQuesitonApi.addOrUpdate, + method: 'post', + params: params + }) +} + +//必选题题目ID +export function requiredQuestionId(params) { + return request({ + url: requiredQuesitonApi.requiredQuestionId, + method: 'get', + params: params + }) +} + + +// export function menuGet (params) { +// return request({ +// url: menuApi.get, +// method: 'post', +// data: params +// }) +// } +// export function menuUpdate (params) { +// return request({ +// url: menuApi.update, +// method: 'post', +// data: params +// }) +// } + + diff --git a/src/views/course/CoursewareAddOrUpdate.vue b/src/views/course/CoursewareAddOrUpdate.vue index 0523cea..088e2b2 100644 --- a/src/views/course/CoursewareAddOrUpdate.vue +++ b/src/views/course/CoursewareAddOrUpdate.vue @@ -4,15 +4,15 @@ 返回 保存 - + - +
课件名称:  - +
课件分类:  @@ -23,18 +23,39 @@ 添加分类 - -

hello world

+
课件大小:  -     MB +     MB

- 视频上传:  + 视频上传:  - {{uploadButtonText}} + {{fileUpload.uploadButtonText}}    
@@ -43,17 +64,10 @@
- -
- 视频上传:  - - 选择文件 -     - -
+
课件名称:  - +
课件分类:  @@ -64,12 +78,20 @@ 添加分类 - -

hello world

+ +
课件大小:  - +     MB +
+
+
+ 文件上传:  + + {{fileUpload.uploadButtonText}} +     +
@@ -93,22 +115,37 @@ import axios from 'axios' import { ossUpload } from '@/api/sys/oss' import { coursewareAdd } from '@/api/course/courseware' import { dictionaryDropDown } from '@/api/sys/dictionaryItem' -import { forEach } from 'store/storages/all' export default { data() { return { - visible: false, - textForm: {}, - videoForm: { - sizeStr: '0', - videoPath: [], //用于存放视频路径 + fileUpload: { + visible: false, + textForm: {}, //文本上传表单 + videoForm: { + //视频上传表单 + sizeStr: '0', //视频大小 + videoPath: [], //用于存放视频路径 + }, + parentTabKey: '1', //顶级选项卡, 文件上传/视频服务器连接/第三方连接 + tabkey: '1', + uploadButtonText: '选择文件', + successOssFile: [], + uploadLoading: false, // 控制 选择文件 按钮是否转圈 + columns: [ + { + title: '标签名', + dataIndex: 'name', + width: '20%' + }, + ], + // loadData: parameter => { + // return menuList(Object.assign(parameter, this.queryParam)).then((res) => { + // const menuList = listToTree(res.data, [], rootParentId) + // return menuList + // }) + // } }, - parentTabKey: '1', - tabkey: '1', - uploadButtonText: '选择文件', - successOssFile: [], - uploadLoading: false, // 控制 选择文件 按钮是否转圈 } }, components: {}, @@ -125,10 +162,16 @@ export default { }, //顶级标签页 - parentcallback(key) {}, + parentcallback(key) { + console.log(key) + this.fileUpload = { videoForm: [] } + this.parentTabKey = key + }, //作用于子标签页 callback(key) { console.log(key) + this.fileUpload = { videoForm: [] } //清空视频上传的form表单 + this.tabKey = key //等于当前的Key }, //获取Tonken @@ -139,12 +182,15 @@ export default { }, beforeUpload(file) { - this.uploadLoading = true - this.uploadButtonText = '上传中...' - //文件类型 (后缀) var suffix = file.name.substring(file.name.lastIndexOf('.') + 1) - if (suffix != 'mp4') return this.$message.error('文件类型必须是mp4') + if (this.fileUpload.tabkey == 1 && suffix != 'mp4') { + return this.$message.error('文件类型必须是mp4') + } + + //告知用户是否正在上传 + this.fileUpload.uploadLoading = true + this.fileUpload.uploadButtonText = '上传中...' //处理视频上传 const data = new FormData() @@ -159,14 +205,14 @@ export default { axios .post(ossUpload(), data, { headers: header }) .then((res) => { - this.uploadLoading = false - this.uploadButtonText = '选择文件' + this.fileUpload.uploadLoading = false + this.fileUpload.uploadButtonText = '选择文件' if (res.data.code === 200) { this.$message.success('视频上传成功!') res.data.uuid = file.uid res.data.size = file.size - this.successOssFile.push(res.data) + this.fileUpload.successOssFile.push(res.data) //刷新文件大小 this.refreshFileSize() @@ -184,26 +230,26 @@ export default { //刷新大小 refreshFileSize() { - this.videoForm.size = 0 - for (let i = 0; i < this.successOssFile.length; i++) { + this.fileUpload.videoForm.size = 0 + for (let i = 0; i < this.fileUpload.successOssFile.length; i++) { //读取文件大小 - let fileSize = this.successOssFile[i].size + let fileSize = this.fileUpload.successOssFile[i].size //视频转换成MB var videoSize = parseFloat(fileSize) / 1024 / 1024 //保留两位小数 - this.videoForm.size = this.videoForm.size + parseFloat(videoSize) + this.fileUpload.videoForm.size = this.fileUpload.videoForm.size + parseFloat(videoSize) } - this.videoForm.sizeStr = this.videoForm.size.toFixed(2) + this.fileUpload.videoForm.sizeStr = this.fileUpload.videoForm.size.toFixed(2) }, //删除已上传的视频 deleteVideo(file) { // 删除元素 - for (let i = 0; i < this.successOssFile.length; i++) { - if (this.successOssFile[i].uuid == file.uid) { - this.successOssFile.splice(i, 1) + for (let i = 0; i < this.fileUpload.successOssFile.length; i++) { + if (this.fileUpload.successOssFile[i].uuid == file.uid) { + this.fileUpload.successOssFile.splice(i, 1) break } } @@ -213,39 +259,42 @@ export default { //弹框 showModal() { - this.visible = true + this.fileUpload.visible = true }, //保存 save() { + + console.log("课程IDID ID-------",this.$route.query.courseId); + //视频赋给表单里面的字段 - this.successOssFile.forEach((item, index) => { - this.videoForm.videoPath.push(item.url) + this.fileUpload.successOssFile.forEach((item, index) => { + this.fileUpload.videoForm.videoPath.push(item.url) }) - console.log(this.videoForm.videoPath.toString()) + console.log(this.fileUpload.videoForm.videoPath.toString()) //转JSON - this.videoForm.videoPath = this.videoForm.videoPath.toString(); + this.fileUpload.videoForm.videoPath = this.fileUpload.videoForm.videoPath.toString() //给课程ID - this.videoForm.courseId = this.$route.query.courseId; - console.log(this.videoForm) + this.fileUpload.videoForm.courseId = this.$route.query.courseId + console.log(this.fileUpload.videoForm) - let from; - if (this.parentTabKey == '1' && this.tabkey == '1') { - //保存视频上传 + let from + if (this.fileUpload.parentTabKey == '1' && this.fileUpload.tabkey == '1') { + //保存视频上传 from = this.videoFormV() if (typeof form == 'boolean' && !form) return } //提交保存请求 - coursewareAdd(from).then((res) =>{ - console.log(res); + coursewareAdd(from).then((res) => { + console.log(res) if (res.code == 200) { - this.$message.success('课件保存成功!'); - this.goback(); - }else{ - this.$message.error('保存失败!'); + this.$message.success('课件保存成功!') + this.goback() + } else { + this.$message.error('保存失败!') } }) }, @@ -253,18 +302,18 @@ export default { //视频上传 videoFormV() { // 验证课件名称是否为空 - if (!this.videoForm.name || this.videoForm.name === '') { + if (!this.fileUpload.videoForm.name || this.fileUpload.videoForm.name === '') { this.$message.error('课件名称不能为空!') return false - } else if (this.videoForm.videoPath.length == 0) { + } else if (this.fileUpload.videoForm.videoPath.length == 0) { this.$message.error('请上传课件文件!') return false } - let form = {}; - form = this.videoForm; - console.log('111111',form); - return form; + let form = {} + form = this.fileUpload.videoForm + console.log('111111', form) + return form }, }, } diff --git a/src/views/course/CoursewareList.vue b/src/views/course/CoursewareList.vue index 2aed53c..da31fec 100644 --- a/src/views/course/CoursewareList.vue +++ b/src/views/course/CoursewareList.vue @@ -36,7 +36,7 @@ export default { return { queryParam: { id: this.$route.query.id }, - loadData: (parameter) => { + loadData:(parameter) => { return getCoursewareListByCourseId(Object.assign(parameter, this.queryParam)).then((res) => { return res }) @@ -60,7 +60,6 @@ export default { //新增课件 coursewareAdd() { this.$router.push({ path: '/course/CoursewareAddOrUpdate', query: { courseId: this.$route.query.id } }) - console.log('IDIDIDID', this.$route.query.id) }, //返回 @@ -73,17 +72,28 @@ export default { deleteCourseware({ id: record.id }).then((res) => { if (res.code == 200) { this.$refs.table.refresh(true) - this.$message.success('删除成功!'); + this.$message.success('删除成功!') } else { - this.$message.error('删除失败!'); + this.$message.error('删除失败!') } }) }, // 抽考題 courseQuestion(record) { - console.log('哈哈') - this.$router.push({ path: '/course/question/examQuestion', query: { id: record.id } }) + this.$router.push({ + path: '/course/question/ExamQuestion', + query: { coursewareId: record.id, courseId: this.$route.query.id }, + }) }, + + //课件预览 + detail(record){ + this.$router.push({ + path: '/course/CoursewarePreview', + query: { coursewareId: record.id} + }) + } + }, } \ No newline at end of file diff --git a/src/views/course/CoursewarePreview.vue b/src/views/course/CoursewarePreview.vue new file mode 100644 index 0000000..3d58f27 --- /dev/null +++ b/src/views/course/CoursewarePreview.vue @@ -0,0 +1,53 @@ + + + \ No newline at end of file diff --git a/src/views/course/question/ExamQuestion.vue b/src/views/course/question/ExamQuestion.vue new file mode 100644 index 0000000..230def0 --- /dev/null +++ b/src/views/course/question/ExamQuestion.vue @@ -0,0 +1,87 @@ + + + \ No newline at end of file