课件设置为一个文件上传

This commit is contained in:
18571350067 2022-02-25 15:18:58 +08:00
parent fb6aecd22c
commit 542c0bba40
1 changed files with 29 additions and 43 deletions

View File

@ -6,10 +6,10 @@
</template>
<a-tabs type="card" :default-active-key="parentTabKey" @change="parentcallback">
<a-tab-pane key="1" tab="文件上传">
<a-tabs :default-active-key="fileUpload.tabkey" @change="callback">
<a-tabs v-model="fileUpload.tabkey" @change="callback">
<a-tab-pane key="1" tab="视频上传" :disabled="fileUpload.videoForm.disabled">
<div style="background: #ececec; padding: 30px">
<div v-if="fileUpload.tabkey == 1" style="background: #ececec; padding: 30px">
<a-card title="视频上传" :bordered="false" style="width: 100%">
<div style="margin-bottom: 30px">
课件名称&nbsp;
@ -32,8 +32,9 @@
</div>
<br />
<div>
视频上传&nbsp; <a-upload list-type="picture" :default-file-list="this.successOssFile" :beforeUpload="beforeUpload" :remove="deleteVideo" :disabled="this.uploadLoading">
<a-button>
<span v-show="this.successOssFile.length < 1">视频上传</span>&nbsp; <a-upload list-type="picture" v-model="this.successOssFile" :beforeUpload="beforeUpload" :remove="deleteVideo" accept=".mp4"
:disabled="this.uploadLoading">
<a-button v-show="this.successOssFile.length <1">
<a-icon type="upload" /> {{this.uploadButtonText}}
</a-button>&nbsp;&nbsp;&nbsp;
</a-upload>
@ -43,7 +44,7 @@
</a-tab-pane>
<a-tab-pane key="2" tab="文本上传" :disabled="fileUpload.textForm.disabled">
<div style="background: #ececec; padding: 30px">
<div v-if="fileUpload.tabkey == 2" style="background: #ececec; padding: 30px">
<a-card title="文本上传" :bordered="false" style="width: 100%">
<div style="margin-bottom: 30px">
课件名称&nbsp;
@ -66,8 +67,9 @@
</div>
<br />
<div>
文件上传&nbsp; <a-upload list-type="picture" :default-file-list="this.successOssFile" :beforeUpload="beforeUpload" :remove="deleteVideo" :disabled="this.uploadLoading">
<a-button>
<span v-show="this.successOssFile.length < 1">文件上传</span>&nbsp; <a-upload list-type="picture" :default-file-list="this.successOssFile" :beforeUpload="beforeUpload" :remove="deleteVideo"
:disabled="this.uploadLoading">
<a-button v-show="this.successOssFile.length < 1">
<a-icon type="upload" /> {{this.uploadButtonText}}
</a-button>&nbsp;&nbsp;&nbsp;
</a-upload>
@ -204,21 +206,18 @@ export default {
if (this.queryParam.coursewareId) this.load();
// ifResources
console.log("资源库标号"+this.$route.query.ifResources+"课件ID"+this.$route.query.coursewareId)
if(this.$route.query.coursewareId && this.$route.query.ifResources == 1 ) {
this.pageName = '资源库编辑'
}else if(!this.$route.query.coursewareId && this.$route.query.ifResources == 1){
this.pageName = '资源库新增'
if (this.$route.query.coursewareId && this.$route.query.ifResources == 1) {
this.pageName = '资源库编辑';
} else if (!this.$route.query.coursewareId && this.$route.query.ifResources == 1) {
this.pageName = '资源库新增';
}
if(this.$route.query.coursewareId && this.$route.query.ifResources == 0) {
this.pageName = '课件编辑'
}else if(!this.$route.query.coursewareId && this.$route.query.ifResources == 0){
this.pageName = '课件新增'
if (this.$route.query.coursewareId && this.$route.query.ifResources == 0) {
this.pageName = '课件编辑';
} else if (!this.$route.query.coursewareId && this.$route.query.ifResources == 0) {
this.pageName = '课件新增';
}
},
},
methods: {
//
showModal() {
@ -248,7 +247,6 @@ export default {
//
parentcallback(key) {
console.log(key);
this.fileUpload.videoForm = {};
this.fileUpload.textForm = {};
this.videoPath = []; //
@ -258,16 +256,15 @@ export default {
callback(key) {
this.fileUpload.videoForm = {};
this.fileUpload.textForm = {};
console.log('aaaaaaa ', this.fileUpload.videoForm);
console.log('aaaaaaa ', this.fileUpload.textForm);
this.videoPath = []; //
this.successOssFile = this.successOssFile.splice(this.successOssFile.length, 0); //
console.log('清除后的文件', this.successOssFile);
// this.successOssFile = this.successOssFile.splice(this.successOssFile.length, 0); //
this.fileUpload.tabkey = key; //Key
//
// this.initialize(key)
for (let i = 0; i < this.successOssFile.length; i++) {
this.deleteVideo(this.successOssFile[i]);
}
},
//Tonken
@ -308,13 +305,11 @@ export default {
res.data.uuid = file.uid;
res.data.size = file.size;
console.log('文件大小---', file.size);
this.successOssFile.push(res.data);
//
this.refreshFileSize();
console.log('上传之后的文件', this.successOssFile);
} else {
this.$message.error(res.data.msg);
this.$refs.inputFile.value = '';
@ -372,10 +367,9 @@ export default {
//
deleteVideo(file) {
console.log('deleteVideo - file:{}', file);
//
for (let i = 0; i < this.successOssFile.length; i++) {
if (this.successOssFile[i].uuid == file.uid) {
if (this.successOssFile[i].uuid == file.uid || this.successOssFile[i].uuid == file.uuid) {
this.successOssFile.splice(i, 1);
break;
}
@ -386,7 +380,6 @@ export default {
//
save() {
console.log('this.ifResources', this.ifResources);
//
this.successOssFile.forEach((item, index) => {
@ -407,7 +400,6 @@ export default {
from = this.textFormV();
if (typeof from == 'boolean' && !from) return;
} else if (this.parentTabKey == '2') {
console.log(this.videoServerLink);
from = this.videoServerLinkV();
if (typeof from == 'boolean' && !from) return;
} else if (this.parentTabKey == '3') {
@ -417,7 +409,6 @@ export default {
//
coursewareAdd(from).then(res => {
console.log(res);
if (res.code == 200) {
this.$message.success('课件保存成功!');
this.goback();
@ -445,7 +436,6 @@ export default {
this.fileUpload.videoForm.ifResources = this.$route.query.ifResources || 0;
let form = {};
form = this.fileUpload.videoForm;
console.log('FORM', form);
return form;
},
@ -477,7 +467,6 @@ export default {
//ID
this.videoServerLink.courseId = this.$route.query.courseId;
this.videoServerLink.videoPath = this.videoPath;
console.log(this.videoServerLink);
let form = {};
form = this.videoServerLink;
@ -495,7 +484,6 @@ export default {
this.thirdAddress.courseId = this.$route.query.courseId;
this.thirdAddress.videoPath = this.videoPath;
console.log(this.thirdAddress);
let form = {};
form = this.thirdAddress;
return form;
@ -508,8 +496,6 @@ export default {
let parameter = {};
coursewareDeatil(Object.assign(parameter, this.queryParam)).then(res => {
this.courseware = res.data;
console.log('加载数据了');
console.log('courseware:', this.courseware);
//
this.fileUpload.disabled = true;