vue实现多行数据提交_vue+element 实现选取文件,提交上传全部表单信息(同步)...

68fb2552087ebadc6ec8ff0513f2c8ae.png

0c30dbe429ad0af9bd2f1b2385ac7dfd.png

代码如下:

<el-form-item label="Android客户端文件:" prop="file" ref="uploadpic">
<el-upload
class="upload-demo"
ref="upload"
:headers="headers"
:action="updateUrl"
:data="addData"
:before-upload="beforeUpload"
:on-exceed="handleExceed"
:on-remove="handleRemove"
:on-success="handleAvatarSuccess"
:on-change="fileChange"
:file-list="fileList"
:limit="1"
:multiple="false"
:auto-upload="false">
<el-button ref="upload" slot="trigger" size="small" type="primary" >选取文件</el-button>
<div slot="tip" class="el-upload__tip">支持扩展名:.apk</div>
</el-upload>
</el-form-item>

data中变量:

7a983f1928b752352af552e68c6dee23.png

接口地址:mounte

f9a294d4bd998e655d2309e6c6b38392.png

处理方法:

onAdd(formName,resetFields) {
if(resetFields=='resetFields'){
this.$refs[formName].resetFields();
this.fileList=[];
}else{
this.$refs[formName].validate((valid) => {
if (valid) {
this.isDisabled=true;
setTimeout(()=>{
this.isDisabled=false;// 上传包文件
this.$refs.upload.submit();
},2000)
} else {
return false;
}
})
}
},//上传成功
handleAvatarSuccess(resp, file, fileList) {
console.log('创建版本~~',resp)
this.$refs['upload'].clearFiles();
if(resp.retCode=="2000"){
}else{
this.tip.successTip=true;
this.tip.tipContent='添加失败';
this.$bus.$emit("tip",this.tip);
}
this.fileList=[];
},
onReset(formName){
this.visible = false;
this.$bus.$emit("visible",this.visible);
this.$refs[formName].resetFields();
this.$refs['upload'].clearFiles();
},
fileChange(file, fileList, name){
console.log(fileList)
this.fileList["file"] = fileList;// 如果上传了就不显示提示图片警告
if (typeof this.fileList.file != "undefined") {
if (this.fileList.file.length > 0) {
this.$refs["uploadpic"].clearValidate();
}
}
},// 文件上传前的钩子(这里可以对文件上传时的后缀进行限制)
beforeUpload(file) {
console.log(file)var FileExt = file.name.replace(/.+./, '')
if (['apk'].indexOf(FileExt) === -1) {
this.$message.warning("请上传后缀名为 apk 的文件!", 2);
return false
}
},
handleExceed(files, fileList) {
this.$message.warning(`当前限制选择 1 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`);
},
handleRemove(file, fileList) {
console.log(file, fileList);
},

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值