想要的效果是 用戶一次選擇的文件一個接口上傳完畢,但是element ui 里面是上傳了多次一次一個文件的形式上傳的
為4參數的接口調用了 多次執行的上傳,我想上傳一次 多個文件的 怎么實現呢?
因為element ui 里面的列表和我們的需求不一致 我重寫了一個列表
class="upload-demo"
ref="upload"
drag
:data="Aobject"
:on-success="handleAvatarSuccess"
:auto-upload="false"
:before-remove="beforeRemove"
:show-file-list="false"
:on-change="handleChange"
:on-remove="handleRemove"
:action="actionUrl"
multiple
:on-exceed="onExceed"
:limit="limit"
>
{{item.name}}
FileList 是用戶每次選擇文件的時候我push進去數據
handleChange(res, file){ //未上傳,但是選擇了文件觸發
let Status=null;
this.TitleNameDisplay=true;
this.TitleName=res.name;
this.Arraya=file;
Status=this.wenjian(res.name);
if(res.status == "ready"){ //剛剛添加文件
this.FileList.push({
name:res.name.substring(0, res.name.lastIndexOf(".")),
status:Status,
wait:false,
Success:false
})
}
if(this.Name == null ||this.Name == undefined){
this.Name=this.FileList[0].name;
}
},
當用戶提交的時候執行了
scuuse(){
this.Zhuan=true;
const _id=this.$route.query.id;
const _this=this;
for(var i=0;i
this.FileList[i].wait =true;
}
let promise = new Promise(function(resolve, reject) {
_this.actionUrl=`/chaoyang/api/dailyInfo/createDailyInfo/${_id}`;
_this.Aobject.name=_this.Name;//提交文件時候一并傳遞過 輸入的標題文字
resolve();
});
promise.then(function() {
_this.$refs.upload.submit();
});
}
請問用element ui 怎么實現 一個接口上傳多個文件呢?