上传视频修改逻辑

This commit is contained in:
zhangsir
2024-12-04 16:47:57 +08:00
parent efb70690c3
commit 7375f9df04
3 changed files with 78 additions and 63 deletions

View File

@@ -51,9 +51,6 @@
</el-radio-group> </el-radio-group>
<br/> <br/>
</div> </div>
<div style="margin-top: 10px;display: flex;">时长分钟
<el-input-number style="width:146px;margin-left:5px;" :precision="0" v-model="curriculumData.duration" size="mini" :min="1" :max="999999999" label="描述文字" controls-position="right"></el-input-number>
</div>
</div> </div>
</div> </div>
<div style="margin-top:35px;text-align: center"> <el-button type="primary" @click="saveData()" size="mini">保存</el-button> </div> <div style="margin-top:35px;text-align: center"> <el-button type="primary" @click="saveData()" size="mini">保存</el-button> </div>
@@ -80,9 +77,6 @@
</el-radio> --> </el-radio> -->
</el-radio-group> </el-radio-group>
</div> </div>
<div style="margin-top: 10px;display: flex;">时长分钟
<el-input-number style="width:146px;margin-left:5px;" :precision="0" v-model="curriculumData.duration" size="mini" :min="1" :max="999999999" label="描述文字" controls-position="right"></el-input-number>
</div>
</div> </div>
<div style="margin-top:35px;text-align: center;"> <el-button type="primary" @click="saveData()" size="mini">保存</el-button> </div> <div style="margin-top:35px;text-align: center;"> <el-button type="primary" @click="saveData()" size="mini">保存</el-button> </div>
</div> </div>
@@ -331,7 +325,6 @@
completeSetup:0, completeSetup:0,
second:5, second:5,
setupTage:0, setupTage:0,
duration: 0,
}, },
homework:{courseId: '', name:'', content:'', file:'', deadTime: '', submitMode: 3}, homework:{courseId: '', name:'', content:'', file:'', deadTime: '', submitMode: 3},
homeworkChange:{}, homeworkChange:{},
@@ -395,10 +388,8 @@
if(newVal.content!=''){ if(newVal.content!=''){
if(newVal.content.startsWith('\{')){ if(newVal.content.startsWith('\{')){
this.curriculumData =JSON.parse(newVal.content); this.curriculumData =JSON.parse(newVal.content);
this.curriculumData.duration = Math.round(this.curriculumData.duration/60);
}else{ }else{
this.curriculumData.url=newVal.content; this.curriculumData.url=newVal.content;
this.curriculumData.duration = Math.round(newVal.duration/60);
} }
} }
} }
@@ -421,7 +412,6 @@
completeSetup:0, completeSetup:0,
second:5, second:5,
setupTage:0, setupTage:0,
duration: 0,
}; };
//this.assess //this.assess
}, },
@@ -513,12 +503,6 @@
this.content.content=JSON.stringify(this.linkInfo); this.content.content=JSON.stringify(this.linkInfo);
} }
} else if(this.content.contentType==10 || this.content.contentType==20) { } else if(this.content.contentType==10 || this.content.contentType==20) {
if(!this.curriculumData.duration){
this.$message.error("请手动输入课件时长");
return;
}
this.curriculumData.duration = this.curriculumData.duration*60;
this.content.duration = this.curriculumData.duration;
this.content.content=JSON.stringify(this.curriculumData); this.content.content=JSON.stringify(this.curriculumData);
} }
let jsonData={ let jsonData={
@@ -655,7 +639,6 @@
this.content.content=cfile.filePath; this.content.content=cfile.filePath;
} }
} }
this.curriculumData.duration = Math.round(cfile.duration/60);
this.content.courseId=this.course.id; this.content.courseId=this.course.id;
this.content.duration=cfile.duration;//时长 this.content.duration=cfile.duration;//时长
this.content.sortIndex=1; this.content.sortIndex=1;

View File

@@ -25,7 +25,7 @@
<el-table-column label="创建时间" prop="sysCreateTime" width="100"></el-table-column> <el-table-column label="创建时间" prop="sysCreateTime" width="100"></el-table-column>
<el-table-column label="选择" width="70" align="center"> <el-table-column label="选择" width="70" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button size="mini" @click="chooseCourseFile(scope.row)" type="primary">选择</el-button> <el-button size="mini" @click="chooseCourseFile(scope.row,false)" type="primary">选择</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@@ -43,19 +43,30 @@
</div> </div>
</el-tab-pane> </el-tab-pane>
<el-tab-pane :label="'上传新'+curComType.name"> <el-tab-pane :label="'上传新'+curComType.name">
<div v-if="!courseFile.id"> <div v-if="!courseFile.id||resType==10||resType==20">
<div v-if="resType>20" style="padding-bottom: 10px;"> <div v-if="resType>20" style="padding-bottom: 10px;">
<span style="font-weight: 700;">内容时长</span> <span style="font-weight: 700;">内容时长</span>
<span> <span>
<el-input-number v-model="duration" size="mini" :min="1" :max="100"></el-input-number> <el-input-number v-model="duration" size="mini" :min="1" :max="100"></el-input-number>
</span> </span>
</div> </div>
<el-upload class="upload-demo" :headers="headers" :data="data" drag :action="uploadFileUrl" :on-success="handleUploadSuccess" :before-upload="handleBeforeUpload"> <el-upload class="upload-demo" :limit="1" :on-exceed="handleExceed" :on-remove="handleDelete" :headers="headers" :data="data" drag :action="uploadFileUrl" :on-success="handleUploadSuccess" :before-upload="handleBeforeUpload">
<i class="el-icon-upload"></i> <i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处<em>点击上传</em></div> <div class="el-upload__text">将文件拖到此处<em>点击上传</em></div>
<div class="el-upload__tip" slot="tip">文件大小限制{{curComType.maxSizeName}},支持的文件类型{{curComType.fileTypes.join(',')}}</div> <div class="el-upload__tip" slot="tip">文件大小限制{{curComType.maxSizeName}},支持的文件类型{{curComType.fileTypes.join(',')}}</div>
</el-upload> </el-upload>
<div v-if="courseFile.id&&resType==10||resType==20" class="video_audio_info">
<div class="info_item">
<div class="item_text">名称</div>
<el-input v-model="courseFile.fileName" size="mini" style="width:300px;" placeholder="请输入名称"></el-input>
</div>
<div class="info_item">
<div class="item_text">时长</div>
<el-input-number style="width:260px;" v-model="courseFile.duration" :precision="0" size="mini" :min="1" :max="999999999" placeholder="请输入时长" controls-position="right"></el-input-number>
<div style="margin-left: 10px;">分钟</div>
</div>
<div class="btn"><el-button @click="chooseCourseFile(courseFile,true)" type="primary" size="mini">确定</el-button></div>
</div>
</div> </div>
<div v-else style="text-align: center;"> <div v-else style="text-align: center;">
<div style="padding: 20px;">{{courseFile.fileName}} <span style="color: green;">上传成功</span></div> <div style="padding: 20px;">{{courseFile.fileName}} <span style="color: green;">上传成功</span></div>
@@ -90,7 +101,7 @@
}, },
data(){ data(){
return { return {
successParams: {}, courseWare: {},
uploadFileUrl: process.env.VUE_APP_BASE_API + "/xboe/sys/xuploader/file/upload", // 上传的图片服务器地址 uploadFileUrl: process.env.VUE_APP_BASE_API + "/xboe/sys/xuploader/file/upload", // 上传的图片服务器地址
data:{ data:{
dir:'course' dir:'course'
@@ -119,6 +130,7 @@
}, },
mounted() { mounted() {
this.courseFile={}; this.courseFile={};
this.courseWare = {};
let $this=this; let $this=this;
this.comTypes.some(ct=>{ this.comTypes.some(ct=>{
if(ct.resType==$this.resType){ if(ct.resType==$this.resType){
@@ -140,6 +152,9 @@
} }
}, },
methods:{ methods:{
handleExceed(){
this.$message({message:`只允许一次性上传一个`,type:'error',offset:100})
},
handleBeforeUpload(file) { handleBeforeUpload(file) {
if(file.name.lastIndexOf(".") ==-1) { if(file.name.lastIndexOf(".") ==-1) {
this.$message({message:`文件格式不正确!`,type:'error',offset:100}) this.$message({message:`文件格式不正确!`,type:'error',offset:100})
@@ -173,27 +188,28 @@
}, },
// 上传成功回调 // 上传成功回调
handleUploadSuccess(res, file) { handleUploadSuccess(res, file) {
console.log(res,file,'resfile') // console.log(res,file,'xixixixiix');
if(res.status == 200) { if(res.status == 200) {
//上传到课件库 //上传到课件库
//console.log(res.result); //console.log(res.result);
let courseWare={ this.courseWare={
fileName:res.result.displayName, fileName:res.result.displayName,
fileType:res.result.fileType, fileType:res.result.fileType,
filePath:res.result.filePath, filePath:res.result.filePath,
resType:this.resType, resType:this.resType,
orgId:this.orgId, orgId:this.orgId,
orgName:this.orgName, orgName:this.orgName,
duration:this.duration, duration:res.result.duration||this.duration,
remark:'课程中直接上传' remark:'课程中直接上传'
} }
if(res.result.fileType == 'mp4'||res.result.fileType == 'mp3'){ this.$message({message:"上传成功",type:'success',offset:100});
this.successParams = courseWare this.courseFile = {
this.courseFile = {fileName:res.result.displayName,id: '1',resType:'10'} id: res.result.filePath,
this.$message({message:"上传成功",type:'success',offset:100}); fileName:res.result.displayName.replace(/\.[^/.]+$/, ""),
return duration:res.result.duration,
} }
apiCourseFile.saveUpload(courseWare).then(rs=>{ return
apiCourseFile.saveUpload(this.courseWare).then(rs=>{
if(rs.status==200){ if(rs.status==200){
this.courseFile=rs.result; this.courseFile=rs.result;
this.$message({message:"上传成功",type:'success',offset:100}); this.$message({message:"上传成功",type:'success',offset:100});
@@ -212,7 +228,8 @@
}, },
// 删除文件 // 删除文件
handleDelete(index) { handleDelete(index) {
this.fileList.splice(index, 1); this.courseFile = {};
// this.fileList.splice(index, 1);
//注意删除处理 //注意删除处理
//this.$emit("remove", ''); //this.$emit("remove", '');
}, },
@@ -255,24 +272,58 @@
}) })
}, },
chooseCourseFile(ccfile,val=false){ chooseCourseFile(ccfile,isUpload){
if(ccfile.resType == 10&&val){ if(isUpload){
apiCourseFile.saveUpload(this.successParams).then(rs=>{ if(this.resType == 10||this.resType == 20){
if(rs.status==200){ if(!this.courseFile.fileName){
this.$emit('choose', rs.result); this.$message({message:`${this.resType == 10?'视频':'音频'}名称不能为空`,type:'error',offset:100});
}else{ return
this.$message.error(rs.message); }
} if(!this.courseFile.duration){
this.$message({message:"时长不能为空",type:'error',offset:100});
return
}
this.courseWare.fileName = this.courseFile.fileName + '.' + this.courseWare.fileType
this.courseWare.duration = this.courseFile.duration
}
apiCourseFile.saveUpload(this.courseWare).then(rs=>{
if(rs.status==200){
this.courseFile=rs.result;
this.$message({message:"保存成功",type:'success',offset:100});
this.$emit('choose', this.courseFile);
}else{
this.$message.error(rs.message);
}
}).catch(err=>{ }).catch(err=>{
console.log(err,'errrrrr') this.$message.error(err.message);
}) })
}else{ return
this.$emit('choose', ccfile);
} }
this.$emit('choose', ccfile);
} }
} }
} }
</script> </script>
<style> <style>
.video_audio_info{
margin-top: 10px;
.info_item{
width: 360px;
margin-top: 10px;
display: flex;
align-items: center;
.el-input-number .el-input__inner{
text-align: left;
}
.item_text{
margin-right: 10px;
}
}
.btn{
margin-top: 10px;
width: 360px;
text-align: center;
}
}
</style> </style>

View File

@@ -75,9 +75,6 @@
</el-radio> --> </el-radio> -->
</el-radio-group> </el-radio-group>
</div> </div>
<div style="margin-top: 10px;display: flex;">时长分钟
<el-input-number style="width:146px;margin-left:5px;" v-model="cware.curriculumData.duration" :precision="0" size="mini" :min="1" :max="999999999" label="描述文字" controls-position="right"></el-input-number>
</div>
</div> </div>
</div> </div>
<div style="margin-top:35px;text-align: center;"> <el-button :loading="loading" type="primary" @click="saveContent(1)" size="mini">保存</el-button> </div> <div style="margin-top:35px;text-align: center;"> <el-button :loading="loading" type="primary" @click="saveContent(1)" size="mini">保存</el-button> </div>
@@ -105,9 +102,6 @@
</el-radio-group> </el-radio-group>
<br/> <br/>
</div> </div>
<div style="margin-top: 10px;display: flex;">时长分钟
<el-input-number style="width:146px;margin-left:5px;" v-model="cware.curriculumData.duration" :precision="0" size="mini" :min="1" :max="999999999" label="描述文字" controls-position="right"></el-input-number>
</div>
</div> </div>
<div style="margin-top:35px;text-align: center;"> <el-button :loading="loading" type="primary" @click="saveContent(1)" size="mini">保存</el-button> </div> <div style="margin-top:35px;text-align: center;"> <el-button :loading="loading" type="primary" @click="saveContent(1)" size="mini">保存</el-button> </div>
</div> </div>
@@ -663,7 +657,6 @@
completeSetup:0, completeSetup:0,
second:5, second:5,
setupTage:0, setupTage:0,
duration: 0,
}, },
}, },
pdfTip:'',//pdf文件的提示 pdfTip:'',//pdf文件的提示
@@ -842,13 +835,10 @@
} }
} }
if(con.contentType==10 || con.contentType==20){ if(con.contentType==10 || con.contentType==20){
console.log(con.content,'con.content')
if(con.content.startsWith('\{')){ if(con.content.startsWith('\{')){
$this.cware.curriculumData=JSON.parse(con.content); $this.cware.curriculumData=JSON.parse(con.content);
$this.cware.curriculumData.duration = Math.round($this.cware.curriculumData.duration/60);
}else{ }else{
$this.cware.curriculumData.url=con.content; $this.cware.curriculumData.url=con.content;
$this.cware.curriculumData.duration = Math.round(con.duration/60);
} }
} }
$this.cwareChange = deepClone($this.cware); $this.cwareChange = deepClone($this.cware);
@@ -996,7 +986,6 @@
this.cware.content.contentName=row.name; this.cware.content.contentName=row.name;
this.cware.content.content=row.filePath; this.cware.content.content=row.filePath;
this.cware.curriculumData.url = row.filePath; this.cware.curriculumData.url = row.filePath;
this.cware.curriculumData.duration=Math.round(row.duration/60);
this.cware.content.duration=row.duration;//时长 this.cware.content.duration=row.duration;//时长
this.cware.findShow=false; this.cware.findShow=false;
if(this.cware.content.contentType==40){ if(this.cware.content.contentType==40){
@@ -1078,13 +1067,6 @@
this.$message.error("请选择课件"); this.$message.error("请选择课件");
return; return;
} }
if(!this.cware.curriculumData.duration){
this.$message.error("请手动输入课件时长");
this.loading=false;
return;
}
this.cware.curriculumData.duration = Math.round(this.cware.curriculumData.duration*60);
postData.content.duration = this.cware.curriculumData.duration;
postData.content.content=JSON.stringify(this.cware.curriculumData); postData.content.content=JSON.stringify(this.cware.curriculumData);
this.cwareChange.curriculumData = deepClone(this.cware.curriculumData) this.cwareChange.curriculumData = deepClone(this.cware.curriculumData)
} }
@@ -1151,7 +1133,6 @@
if(res.status==200){ if(res.status==200){
if(index==1){ if(index==1){
$this.cware.content=res.result.content; $this.cware.content=res.result.content;
this.cware.curriculumData.duration = Math.round(this.cware.curriculumData.duration/60);
}else if(index==2){ }else if(index==2){
$this.homework.content=res.result.content; $this.homework.content=res.result.content;
$this.homework.info=res.result.homework; $this.homework.info=res.result.homework;
@@ -1169,6 +1150,7 @@
//if(res.result.homework) //if(res.result.homework)
this.$message.success('保存成功'); this.$message.success('保存成功');
//保存成功的统一处理 //保存成功的统一处理
}else{ }else{
this.$message.error(res.message); this.$message.error(res.message);
} }
@@ -1234,7 +1216,6 @@
this.cware.curriculumData.url = cfile.filePath; this.cware.curriculumData.url = cfile.filePath;
} }
} }
this.cware.curriculumData.duration=Math.round(cfile.duration/60);
this.cware.content.duration=cfile.duration;//时长 this.cware.content.duration=cfile.duration;//时长
this.saveContent(1); this.saveContent(1);