Commit 9f615480 authored by zhangyanni's avatar zhangyanni

Merge remote-tracking branch 'origin/master'

parents fb8b4ed6 edf1940c
This diff is collapsed.
<template>
<div>
<el-upload
:class="{hide:imagesIf}"
class="uploadImgCircle imgwidth"
name="fileUpload"
list-type="picture-card"
:action=uploadHostHeader
:multiple="false"
:limit="1"
:file-list="fileList"
:on-success="uploadComplete"
:before-upload="handleBeforeFile"
:on-remove="handleRemove"
>
<i class="iconfont icon-jiahao"></i>
<p class="uploadImgTitle">{{$t("personalAuth.businessCardimg")}}</p>
</el-upload>
</div>
</template>
<script>
export default {
name : "upimg",
props:[
'upmax'
],
data(){
return {
fileList:[],//上传存放路径
dialogImageUrl:"",//上传存放图片
imagesIf:false,//禁止上传
uploadHostHeader: '/base/upload/uploadPicture',//图片上传地址
}
},
methods:{
//附件上传之前判断文件格式
handleBeforeFile(file) {
var nameArr = file.name.split('.');
const isPng = nameArr[nameArr.length - 1] === 'png';
const isJpg = nameArr[nameArr.length - 1] === 'jpg';
const isPNG = nameArr[nameArr.length - 1] === 'PNG';
const isJPG = nameArr[nameArr.length - 1] === 'JPG';
const isLt2M = file.size / 1024 / 1024 <= this.upmax;
if (!isPNG && !isJPG && !isPng && !isJpg ) {
this.$message.error(this.$t('releasejson.compantype'));
}else if(!isLt2M){
if(this.upmax == 5){
this.$message.error('上传图片大小不能超过 5MB')
}else{
this.$message.error(this.$t('releasejson.compansize'));
}
}
return (isPNG || isJPG || isPng || isJpg) && isLt2M;
},
//删除上传文件
handleRemove(){
this.fileList = [];
this.imagesIf = false;
this.$emit('dataEvent','');
// this.formData.companyLogoUrl = '';
},
//上传文件成功回调
uploadComplete(res,file){
this.$emit('dataEvent',res.result.fileUpload);
// this.formData.companyLogoUrl = res.result.fileUpload;
this.imagesIf = true;
// this.$refs.formimg.clearValidate();
},
},
}
</script>
<style scoped>
</style>
\ No newline at end of file
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