From 88f253cff9f1aa856e0aee46f4da38524ad77f93 Mon Sep 17 00:00:00 2001 From: 18571350067 Date: Fri, 11 Mar 2022 15:30:10 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=88=A0=E9=99=A4=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E4=B8=AD=E4=B8=8D=E8=A6=81=E7=9A=84=E5=AD=97=E6=AE=B5=EF=BC=8C?= =?UTF-8?q?=E8=AF=BE=E4=BB=B6=E5=A2=9E=E5=8A=A0=E4=B8=8A=E4=BC=A0=E8=BF=9B?= =?UTF-8?q?=E5=BA=A6=E6=9D=A1=E3=80=81=E5=8F=96=E6=B6=88=E8=AF=BE=E4=BB=B6?= =?UTF-8?q?=E5=88=86=E7=B1=BB=EF=BC=8C=E8=AF=BE=E4=BB=B6=E9=A2=84=E8=A7=88?= =?UTF-8?q?=E8=AF=BE=E4=BB=B6=E7=B1=BB=E5=88=AB=E5=8F=96=E6=B6=88=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/course/CourseAdd.vue | 18 ++--- src/views/course/CoursewareAddOrUpdate.vue | 93 +++++++++++++--------- src/views/course/CoursewarePreview.vue | 2 +- 3 files changed, 63 insertions(+), 50 deletions(-) diff --git a/src/views/course/CourseAdd.vue b/src/views/course/CourseAdd.vue index 87b39d8..6196511 100644 --- a/src/views/course/CourseAdd.vue +++ b/src/views/course/CourseAdd.vue @@ -29,8 +29,7 @@ - - {{ dataValue }}分钟 + @@ -42,7 +41,7 @@ - + - + - + @@ -146,9 +145,6 @@ export default { }, methods: { - //显示页面上的数字 - onChange(dataValue) {}, - //加载数据 loadData() { if (this.$route.query.id) { diff --git a/src/views/course/CoursewareAddOrUpdate.vue b/src/views/course/CoursewareAddOrUpdate.vue index 3ea2e44..74a4d4f 100644 --- a/src/views/course/CoursewareAddOrUpdate.vue +++ b/src/views/course/CoursewareAddOrUpdate.vue @@ -8,61 +8,62 @@ - +
课件名称: 
-
+
课件学时: 

-
课件学分:  +
课件大小:      MB

- 视频上传:  + 视频上传: +   {{this.uploadButtonText}}    
+
- - + +
课件名称: 
-
+
课件学时: 

-
课件学分:  +
课件大小:      MB
@@ -150,18 +151,19 @@ import { ossUpload } from '@/api/sys/oss'; import { coursewareAdd, coursewareClassList } from '@/api/course/courseware'; // import { listToTree } from '@/utils/util' import { dictToTree } from '@/utils/util'; -import { dictionaryDropDown } from '@/api/sys/dictionaryItem'; +// import { dictionaryDropDown } from '@/api/sys/dictionaryItem'; // const rootParentId = 0 export default { data() { return { - isSave:false, + schedule: 0, //进度 + isSave: false, pageName: '', // treeData: [], ifResources: this.$route.query.ifResources, - coursewareClassfiy: [], + // coursewareClassfiy: [], courseware: {}, //课件详情 queryParam: { coursewareId: this.$route.query.coursewareId }, //编辑传参 successOssFile: [], @@ -203,7 +205,7 @@ export default { components: { STable }, created() { //数据字典加载 - this.dictionaryDropDown(); + // this.dictionaryDropDown(); //判断是否加载数据 if (this.queryParam.coursewareId) this.load(); @@ -227,13 +229,13 @@ export default { // this.classfiy() }, - dictionaryDropDown() { - // 课件分类 - dictionaryDropDown({ dictionaryCode: '0009' }).then(res => { - // 词典转树结构 - this.coursewareClassfiy = dictToTree(res.data, [], 0); - }); - }, + // dictionaryDropDown() { + // // 课件分类 + // dictionaryDropDown({ dictionaryCode: '0009' }).then(res => { + // // 词典转树结构 + // this.coursewareClassfiy = dictToTree(res.data, [], 0); + // }); + // }, //返回 goback() { @@ -277,18 +279,17 @@ export default { }, beforeUpload(file) { - //文件类型 (后缀) - // var suffix = file.name.substring(file.name.lastIndexOf('.') + 1); - // if (this.fileUpload.tabkey == '1' && suffix != 'mp4') { - // return this.$message.error('文件类型必须是mp4'); - // } + console.log('file', file); + const _this = this; + + console.log("fileSize",file.size) //告知用户是否正在上传 this.uploadLoading = true; this.uploadButtonText = '上传中...'; //不让他保存 - this.isSave= true; + this.isSave = true; //处理视频上传 const data = new FormData(); @@ -300,32 +301,49 @@ export default { header['Content-Type'] = 'multipart/form-data'; header[ACCESS_TOKEN] = storage.get(ACCESS_TOKEN); + var config = { + headers: header, + onUploadProgress: function (e) { + console.log(e); + //属性lengthComputable主要表明总共需要完成的工作量和已经完成的工作是否可以被测量 + //如果lengthComputable为false,就获取不到e.total和e.loaded + if (e.lengthComputable) { + let a = ((e.loaded / e.total) * 100).toFixed(2); + // _this.schedule = ((e.loaded / e.total) * 100).toFixed(2) ; //已上传的比例 + console.log('进度', a); + + _this.schedule = parseInt(a) > 99 ? 99 : parseInt(a) + } + }, + }; + + // { headers: header } axios - .post(ossUpload(), data, { headers: header }) + .post(ossUpload(), data, config) .then(res => { this.isSave = false; this.uploadLoading = false; this.uploadButtonText = '选择文件'; if (res.data.code === 200) { this.$message.success('上传成功!'); - + + this.schedule = 100; res.data.uuid = file.uid; res.data.size = file.size; this.successOssFile.push(res.data); //刷新文件大小 this.refreshFileSize(); - } else { this.$message.error(res.data.msg); this.$refs.inputFile.value = ''; } }) .catch(err => { + console.log("进来了!!!!!",err); this.$message.error(err); this.uploadButtonText = '选择文件'; }); - return false; }, @@ -380,13 +398,12 @@ export default { break; } } - + this.schedule = 0; this.refreshFileSize(); }, //保存 save() { - //视频赋给表单里面的字段 this.successOssFile.forEach((item, index) => { this.videoPath.push(item.url); @@ -509,7 +526,7 @@ export default { this.fileUpload.textForm.disabled = true; this.videoServerLink.disabled = true; this.thirdAddress.disabled = true; - + //分配到各自的提交模块 if (this.courseware.type == '1' || this.courseware.type == '2') { this.parentTabKey = '1'; @@ -525,7 +542,7 @@ export default { successOssFile_['url'] = element.path; successOssFile_['size'] = element.size; this.successOssFile.push(successOssFile_); - console.log("文件问见",this.successOssFile); + console.log('文件问见', this.successOssFile); }); if (this.courseware.type == '1') { diff --git a/src/views/course/CoursewarePreview.vue b/src/views/course/CoursewarePreview.vue index 4b11cb4..d088457 100644 --- a/src/views/course/CoursewarePreview.vue +++ b/src/views/course/CoursewarePreview.vue @@ -1,7 +1,7 @@