//上传
<input type="file" ref="filElem" @change="uploadFile" v-if="showing" style="display:none;"/>
uploadFile(e) { // 上传文件
const that = this;
const file = e.target.files[0];
const reg = ".*\\.(doc|docx|xlsx|xls|jpg|png|pdf|wps)"; // 允许的文件后缀名
if(!file.name.match(reg)){ // 校验文件后缀名
this.$message.error('仅支持doc|docx|xlsx|xls|jpg|png|pdf|wps格式')
return
}
const url = this.fileUrl;
this.$api.post2('/commons/getUniqueIdentification').then(async res => {
this.uuid = res.data
this.$api.upload(file,{busId:this.busId, busType: this.typeName, officeId: this.officeId, pkOrg: this.officeId, uuid: this.uuid},url).then(res => {
this.showing = false;
if (res.code == 200) {
this.$emit("uploadSuccess",Object.assign({}, res.data));
}
}).catch(res => {
this.showing = false;
})
}).catch(err => {})
},
上传文件校验后缀名
最新推荐文章于 2024-05-06 17:10:19 发布