Commit de38f620 authored by anxixi's avatar anxixi

活动项目征集上传视频

parent 08e3d558
......@@ -261,6 +261,21 @@
</el-upload>
<span class="errorTextproject" v-if="isShowErrorText">{{$t("workPlace.sendRequireForm.uploadingAccessory")}}</span>
</div>
<div v-if="item.fieldType==11" @click="currentdatas(item,moduleIndex,2)">
<el-upload
class="upload-demo"
:action=uploadVideo
:multiple="false"
name="fileUpload"
:limit="1"
:headers="publicFun.getHeadersFunc()"
:file-list="fileListvideo"
:on-success="uploadComplete"
:before-upload="handleBeforeFile"
:on-remove="handleRemoveview">
<el-button size="small" type="primary">{{$t("newprojecttext.toupload")}}</el-button>
</el-upload>
</div>
<div v-if="item.fieldType==0&&item.fieldValue=='companyAddress'">
<el-row :gutter="10" style=" margin: 20px 0;margin-top: 0;">
<!--<el-col style="width: 100%;">-->
......@@ -511,6 +526,8 @@
filecurrentdata:{},
filecurrentindex:'',
filecurrentstate:'',
uploadVideo: '/base/upload/uploadVideo',//视频上传地址
fileListvideo:[],
}
},
props:{
......@@ -539,6 +556,75 @@
},
methods:{
//视频上传之前判断文件格式
handleBeforeFile(file) {
var nameArr = file.name.split('.');
const isMp4 = nameArr[nameArr.length - 1] === 'mp4';
const isLt200M = file.size / 1024 / 1024 <= 200;
var isMac = function() {
return /macintosh|mac os x/i.test(navigator.userAgent);
}();
if ( !isMp4 ) {
this.$message.error(this.$t('newprojecttext.ismp4'));
}else if(!isLt200M){
this.$message.error('上传文件大小不能超过 200MB');
}
this.isflag = 1;
return ( isMp4) && isLt200M;
},
s_to_hs(s){
//计算分钟
//算法:将秒数除以60,然后下舍入,既得到分钟数
var h;
h = Math.floor(s/60);
//计算秒
//算法:取得秒%60的余数,既得到秒数
s = s%60;
//将变量转换为字符串
h += '';
s += '';
//如果只有一位数,前面增加一个0
h = (h.length==1)?'0'+h:h;
// s = (s.length==1)?'0'+s:s;
var stys = Math.round(s)+'';
var ssen = (stys.length == 1)?'0'+stys:stys;
return h+':'+ssen;
},
//上传视频成功回调
uploadComplete(res,file){
if(res.code == 0){
let url = URL.createObjectURL(file.raw);
var audioElement = new Audio(url);
var _this = this;
audioElement.addEventListener('loadedmetadata',function(){
let playTime = audioElement.duration; //playTime就是当前视频长度
_this.s_to_hs(playTime);
_this.secondRuleForm.videoLength = _this.s_to_hs(playTime);
});
this.secondRuleForm[this.filecurrentdata.fieldValue+this.filecurrentindex] = this.secondRuleForm[this.filecurrentdata.fieldValue+this.filecurrentindex]?this.secondRuleForm[this.filecurrentdata.fieldValue+this.filecurrentindex]:[];
this.secondRuleForm[this.filecurrentdata.fieldValue+this.filecurrentindex].push(res.result.fileUpload);
this.isflag = 0;
}else{
this.$message.error(this.$t('newprojecttext.uploadfailed'));
}
},
//删除上传视频
handleRemoveview(data){
if(this.filecurrentstate==2){
this.secondRuleForm[this.filecurrentdata.fieldValue+this.filecurrentindex].forEach((item,ind)=>{
if(item.uid==data.uid){
this.secondRuleForm[this.filecurrentdata.fieldValue+this.filecurrentindex].splice(ind,1);
}
});
}else{
this.ruleForm[this.filecurrentdata.fieldValue].forEach((item,ind)=>{
if(item==data.url){
this.ruleForm[this.filecurrentdata.fieldValue].splice(ind,1);
}
});
}
this.isflag = 0;
},
//附件上传之前判断文件格式
handleFile(file){
var nameArr = file.name.split('.');
......@@ -986,6 +1072,10 @@
//提交
submitForm(formName) {
if(this.isflag == 1){
this.$message.error(this.$t("sendRequireForm.uploadingAccessory"))
return
}
var that = this;
if (this.disabledFlag == 0 && this.basicInfoObj.basicInfoList) {
this.disabledFlag++;
......@@ -1175,11 +1265,11 @@
this.$set(resultObj.baseModuleEnterList,index-1,{'moduleId':data.moduleId,activityId:this.secondStepInfoObj.aid})
}
data.fieldList.forEach((item,itemInd)=>{
if(item.fieldType==1||item.fieldType==8||item.fieldType==10){
if(item.fieldType==1||item.fieldType==8||item.fieldType==10||item.fieldType==11){
if(item.fieldValue.charAt(0)=='a'){
if(index==0){
resultObj[item.fieldValue] = this.secondRuleForm[item.fieldValue+index].length>1?this.secondRuleForm[item.fieldValue+index].join(','):this.secondRuleForm[item.fieldValue+index].join('');
resultObj[item.fieldValue] = this.secondRuleForm[item.fieldValue+index]?(this.secondRuleForm[item.fieldValue+index].length>1?this.secondRuleForm[item.fieldValue+index].join(','):this.secondRuleForm[item.fieldValue+index].join('')):null;
}else{
resultObj.baseModuleEnterList[index-1][item.fieldValue] = this.secondRuleForm[item.fieldValue+index].length>1?this.secondRuleForm[item.fieldValue+index].join(','):this.secondRuleForm[item.fieldValue+index].join('');
}
......
......@@ -417,8 +417,8 @@
<el-dialog :title="editVisible?$t('pubactivities.editfield'):$t('pubactivities.newfield')" :visible.sync="addVisible" :append-to-body="true" :close-on-click-modal="false" @close="closeSensor" class="dialogWrap">
<el-form :inline="true" label-width="210px" :model="contactsform" :rules="rules" ref="contactsform">
<el-form-item :label="$t('pubactivities.fieldName')+':'" prop="fieldName" ref="formfieldName">
<el-input @input="$forceUpdate()" :disabled="contactsform.fieldType == 10" style="width:370px;" maxlength="36" v-model="contactsform.fieldName" :placeholder="$t('pubactivities.plfieldName')"></el-input>
<el-checkbox :disabled="contactsform.fieldType == 9 || contactsform.fieldType == 10" style="margin-left: 15px" v-model="isCheck">{{$t('pubactivities.required')}}</el-checkbox>
<el-input @input="$forceUpdate()" :disabled="contactsform.fieldType == 10 || contactsform.fieldType == 11" style="width:370px;" maxlength="36" v-model="contactsform.fieldName" :placeholder="$t('pubactivities.plfieldName')"></el-input>
<el-checkbox :disabled="contactsform.fieldType == 9 || contactsform.fieldType == 10 || contactsform.fieldType == 11" style="margin-left: 15px" v-model="isCheck">{{$t('pubactivities.required')}}</el-checkbox>
</el-form-item>
<el-form-item :label="$t('pubactivities.fieldType')+':'" prop="fieldType" style="width: 100%;">
<el-select style="width:370px;" v-model="contactsform.fieldType" @change="fieldTypechange" :placeholder="$t('pubactivities.plfieldType')">
......@@ -433,8 +433,8 @@
</div>
<el-button @click="addvalue" v-if="contactsform.fieldType == 0 || contactsform.fieldType == 1" type="primary" plain style="width: 100px;height: 40px;margin-top: 25px">{{$t('pubactivities.addone')}}</el-button>
</el-form-item>
<el-form-item v-if="contactsform.fieldType == 10" :label="$t('pubactivities.maximumlimit')+':'" style="padding-bottom: 30px;">
<el-input @input="numberarr(4)" type="number" style="width:370px;" v-model="contactsform.fieldLength" :placeholder="$t('activityInfo.enterTitle')"></el-input>M
<el-form-item v-if="contactsform.fieldType == 10||contactsform.fieldType == 11" :label="$t('pubactivities.maximumlimit')+':'" style="padding-bottom: 30px;">
<el-input @input="numberarr(contactsform.fieldType == 10?4:3)" type="number" style="width:370px;" v-model="contactsform.fieldLength" :placeholder="$t('activityInfo.enterTitle')"></el-input>M
</el-form-item>
</el-form>
<el-row style="padding-top: 20px;border-top: 1px solid #E4E6F2;text-align: center">
......@@ -990,8 +990,8 @@
fieldTypechange(val){
if(val == 0 || val == 1){
this.valuelist = [{},{}];
}else if(val == 10){
this.contactsform.fieldName = this.$t('releasejson.addbp');
}else if(val == 10 || val == 11){
this.contactsform.fieldName = val == 10?this.$t('releasejson.addbp'):this.$t('newprojecttext.uploadvideo');
var _this = this;
setTimeout(function () {
_this.$refs.formfieldName.clearValidate();
......@@ -1012,6 +1012,12 @@
return;
}
}
if(this.contactsform.fieldType == 11){
if(this.contactsform.fieldLength == '' || this.contactsform.fieldLength < 1 || this.contactsform.fieldLength > 200){
this.$message.error(this.$t('pubactivities.sizeincorrectly'));
return;
}
}
this.$refs.contactsform.validate((valid) => {
if(valid) {
let num = [];
......@@ -1428,6 +1434,7 @@
this.getTimeZoneList();
if(this.$route.query.type == 2){
this.contactslist.push({key:10,value:this.$t('releasejson.addbp')});
this.contactslist.push({key:11,value:this.$t('newprojecttext.uploadvideo')});
}
if(this.$route.query.channelId){
api.activityDetail(this.$route.query.channelId).then(response => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment