课件设置为一个文件上传

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