mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-07 18:06:44 +08:00
上传视频修改逻辑
This commit is contained in:
@@ -51,9 +51,6 @@
|
||||
</el-radio-group>
|
||||
<br/>
|
||||
</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>
|
||||
@@ -80,9 +77,6 @@
|
||||
秒</el-radio> -->
|
||||
</el-radio-group>
|
||||
</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 style="margin-top:35px;text-align: center;"> <el-button type="primary" @click="saveData()" size="mini">保存</el-button> </div>
|
||||
</div>
|
||||
@@ -331,7 +325,6 @@
|
||||
completeSetup:0,
|
||||
second:5,
|
||||
setupTage:0,
|
||||
duration: 0,
|
||||
},
|
||||
homework:{courseId: '', name:'', content:'', file:'', deadTime: '', submitMode: 3},
|
||||
homeworkChange:{},
|
||||
@@ -395,10 +388,8 @@
|
||||
if(newVal.content!=''){
|
||||
if(newVal.content.startsWith('\{')){
|
||||
this.curriculumData =JSON.parse(newVal.content);
|
||||
this.curriculumData.duration = Math.round(this.curriculumData.duration/60);
|
||||
}else{
|
||||
this.curriculumData.url=newVal.content;
|
||||
this.curriculumData.duration = Math.round(newVal.duration/60);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -421,7 +412,6 @@
|
||||
completeSetup:0,
|
||||
second:5,
|
||||
setupTage:0,
|
||||
duration: 0,
|
||||
};
|
||||
//this.assess
|
||||
},
|
||||
@@ -513,12 +503,6 @@
|
||||
this.content.content=JSON.stringify(this.linkInfo);
|
||||
}
|
||||
} 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);
|
||||
}
|
||||
let jsonData={
|
||||
@@ -655,7 +639,6 @@
|
||||
this.content.content=cfile.filePath;
|
||||
}
|
||||
}
|
||||
this.curriculumData.duration = Math.round(cfile.duration/60);
|
||||
this.content.courseId=this.course.id;
|
||||
this.content.duration=cfile.duration;//时长
|
||||
this.content.sortIndex=1;
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
<el-table-column label="创建时间" prop="sysCreateTime" width="100"></el-table-column>
|
||||
<el-table-column label="选择" width="70" align="center">
|
||||
<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>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -43,19 +43,30 @@
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
<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;">
|
||||
<span style="font-weight: 700;">内容时长(分):</span>
|
||||
<span>
|
||||
<el-input-number v-model="duration" size="mini" :min="1" :max="100"></el-input-number>
|
||||
</span>
|
||||
</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>
|
||||
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
||||
<div class="el-upload__tip" slot="tip">文件大小限制:{{curComType.maxSizeName}},支持的文件类型:{{curComType.fileTypes.join(',')}}</div>
|
||||
</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 v-else style="text-align: center;">
|
||||
<div style="padding: 20px;">{{courseFile.fileName}} <span style="color: green;">上传成功</span></div>
|
||||
@@ -90,7 +101,7 @@
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
successParams: {},
|
||||
courseWare: {},
|
||||
uploadFileUrl: process.env.VUE_APP_BASE_API + "/xboe/sys/xuploader/file/upload", // 上传的图片服务器地址
|
||||
data:{
|
||||
dir:'course'
|
||||
@@ -119,6 +130,7 @@
|
||||
},
|
||||
mounted() {
|
||||
this.courseFile={};
|
||||
this.courseWare = {};
|
||||
let $this=this;
|
||||
this.comTypes.some(ct=>{
|
||||
if(ct.resType==$this.resType){
|
||||
@@ -140,6 +152,9 @@
|
||||
}
|
||||
},
|
||||
methods:{
|
||||
handleExceed(){
|
||||
this.$message({message:`只允许一次性上传一个`,type:'error',offset:100})
|
||||
},
|
||||
handleBeforeUpload(file) {
|
||||
if(file.name.lastIndexOf(".") ==-1) {
|
||||
this.$message({message:`文件格式不正确!`,type:'error',offset:100})
|
||||
@@ -173,27 +188,28 @@
|
||||
},
|
||||
// 上传成功回调
|
||||
handleUploadSuccess(res, file) {
|
||||
console.log(res,file,'resfile')
|
||||
// console.log(res,file,'xixixixiix');
|
||||
if(res.status == 200) {
|
||||
//上传到课件库
|
||||
//console.log(res.result);
|
||||
let courseWare={
|
||||
this.courseWare={
|
||||
fileName:res.result.displayName,
|
||||
fileType:res.result.fileType,
|
||||
filePath:res.result.filePath,
|
||||
resType:this.resType,
|
||||
orgId:this.orgId,
|
||||
orgName:this.orgName,
|
||||
duration:this.duration,
|
||||
duration:res.result.duration||this.duration,
|
||||
remark:'课程中直接上传'
|
||||
}
|
||||
if(res.result.fileType == 'mp4'||res.result.fileType == 'mp3'){
|
||||
this.successParams = courseWare
|
||||
this.courseFile = {fileName:res.result.displayName,id: '1',resType:'10'}
|
||||
this.$message({message:"上传成功",type:'success',offset:100});
|
||||
return
|
||||
this.$message({message:"上传成功",type:'success',offset:100});
|
||||
this.courseFile = {
|
||||
id: res.result.filePath,
|
||||
fileName:res.result.displayName.replace(/\.[^/.]+$/, ""),
|
||||
duration:res.result.duration,
|
||||
}
|
||||
apiCourseFile.saveUpload(courseWare).then(rs=>{
|
||||
return
|
||||
apiCourseFile.saveUpload(this.courseWare).then(rs=>{
|
||||
if(rs.status==200){
|
||||
this.courseFile=rs.result;
|
||||
this.$message({message:"上传成功",type:'success',offset:100});
|
||||
@@ -212,7 +228,8 @@
|
||||
},
|
||||
// 删除文件
|
||||
handleDelete(index) {
|
||||
this.fileList.splice(index, 1);
|
||||
this.courseFile = {};
|
||||
// this.fileList.splice(index, 1);
|
||||
//注意删除处理
|
||||
//this.$emit("remove", '');
|
||||
},
|
||||
@@ -255,24 +272,58 @@
|
||||
})
|
||||
|
||||
},
|
||||
chooseCourseFile(ccfile,val=false){
|
||||
if(ccfile.resType == 10&&val){
|
||||
apiCourseFile.saveUpload(this.successParams).then(rs=>{
|
||||
if(rs.status==200){
|
||||
this.$emit('choose', rs.result);
|
||||
}else{
|
||||
this.$message.error(rs.message);
|
||||
}
|
||||
chooseCourseFile(ccfile,isUpload){
|
||||
if(isUpload){
|
||||
if(this.resType == 10||this.resType == 20){
|
||||
if(!this.courseFile.fileName){
|
||||
this.$message({message:`${this.resType == 10?'视频':'音频'}名称不能为空`,type:'error',offset:100});
|
||||
return
|
||||
}
|
||||
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=>{
|
||||
console.log(err,'errrrrr')
|
||||
this.$message.error(err.message);
|
||||
})
|
||||
}else{
|
||||
this.$emit('choose', ccfile);
|
||||
return
|
||||
}
|
||||
this.$emit('choose', ccfile);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<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>
|
||||
|
||||
@@ -75,9 +75,6 @@
|
||||
秒</el-radio> -->
|
||||
</el-radio-group>
|
||||
</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>
|
||||
@@ -105,9 +102,6 @@
|
||||
</el-radio-group>
|
||||
<br/>
|
||||
</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 style="margin-top:35px;text-align: center;"> <el-button :loading="loading" type="primary" @click="saveContent(1)" size="mini">保存</el-button> </div>
|
||||
</div>
|
||||
@@ -663,7 +657,6 @@
|
||||
completeSetup:0,
|
||||
second:5,
|
||||
setupTage:0,
|
||||
duration: 0,
|
||||
},
|
||||
},
|
||||
pdfTip:'',//pdf文件的提示
|
||||
@@ -842,13 +835,10 @@
|
||||
}
|
||||
}
|
||||
if(con.contentType==10 || con.contentType==20){
|
||||
console.log(con.content,'con.content')
|
||||
if(con.content.startsWith('\{')){
|
||||
$this.cware.curriculumData=JSON.parse(con.content);
|
||||
$this.cware.curriculumData.duration = Math.round($this.cware.curriculumData.duration/60);
|
||||
}else{
|
||||
$this.cware.curriculumData.url=con.content;
|
||||
$this.cware.curriculumData.duration = Math.round(con.duration/60);
|
||||
}
|
||||
}
|
||||
$this.cwareChange = deepClone($this.cware);
|
||||
@@ -996,7 +986,6 @@
|
||||
this.cware.content.contentName=row.name;
|
||||
this.cware.content.content=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.findShow=false;
|
||||
if(this.cware.content.contentType==40){
|
||||
@@ -1078,13 +1067,6 @@
|
||||
this.$message.error("请选择课件");
|
||||
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);
|
||||
this.cwareChange.curriculumData = deepClone(this.cware.curriculumData)
|
||||
}
|
||||
@@ -1151,7 +1133,6 @@
|
||||
if(res.status==200){
|
||||
if(index==1){
|
||||
$this.cware.content=res.result.content;
|
||||
this.cware.curriculumData.duration = Math.round(this.cware.curriculumData.duration/60);
|
||||
}else if(index==2){
|
||||
$this.homework.content=res.result.content;
|
||||
$this.homework.info=res.result.homework;
|
||||
@@ -1169,6 +1150,7 @@
|
||||
//if(res.result.homework)
|
||||
this.$message.success('保存成功');
|
||||
//保存成功的统一处理
|
||||
|
||||
}else{
|
||||
this.$message.error(res.message);
|
||||
}
|
||||
@@ -1234,7 +1216,6 @@
|
||||
this.cware.curriculumData.url = cfile.filePath;
|
||||
}
|
||||
}
|
||||
this.cware.curriculumData.duration=Math.round(cfile.duration/60);
|
||||
|
||||
this.cware.content.duration=cfile.duration;//时长
|
||||
this.saveContent(1);
|
||||
|
||||
Reference in New Issue
Block a user