<el-upload v-show="item.icon== 0" ref="tranferRef" class="upload-demo" :headers="headers" :auto-upload='false' :action="tranactionurl" accept='.xlsx,.csv'
:multiple='false' :on-change='(file,fileList)=>changefile(0,file,fileList)' :http-request="(params)=>fileUploads(0,params)" :file-list='filetranList'
:on-error='uploaderror' :on-remove="(file,fileList)=>handleRemove(0,file,fileList)">
<div class="fileexpot addIcon"></div>
</el-upload>
changefile(val,file,fileList){
if (fileList.length > 1) {
fileList.splice(0, 1);
}
this.limitframNum(val,file)
if(val == 0){
this.tranrequired = fileList
}else{
this.reasrequired = fileList
}
},
limitframNum(val,file){
this.tolfrom.fileName = file.name
const isLt1M = file.size / 1024 / 1024 < 10
var userAgent = navigator.userAgent
let isJPG
if (userAgent.indexOf("Safari") > -1) {
var index= file.name.lastIndexOf(".");
var ext = file.name.substr(index+1)
isJPG = ext == 'xlsx' || ext == 'xls' || ext == 'csv'
}else{
isJPG = file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' || file.type === 'application/vnd.ms-excel'
}
if(!isJPG){
this.$message.error('请上传Excel、csv格式的文件!')
if(val == 0){
this.filetranList =[]
}else{
this.filerealList =[]
}
return false
}
if (!isLt1M) {
if(val == 0){
this.filetranList =[]
}else{
this.filerealList =[]
}
this.$message({
message: "上传文件大小不能超过 10MB!",
type: "error"
});
return false
}
},