


解决方案
把以前的代码
let images= []
this.formInline.fileList.forEach((item,index)=>{
this.BlobToBase64(item.raw).then(res => {
images.push({
fileName: item.name,
docType: item.formTypeCode,
imageNo: this.formInline.fileList.length + index + 1 + "",
msg: res.split(";base64,")[1]
});
})
if (index+1==this.formInline.fileList.length) {
query.imageList=images
}
});
console.log('准备发起',{query});
const res = await startPolicyInvestigate(query)
console.log('保单调查发起',res);
if (res.success) {
this.$message.success('发起成功')
this.clearFN()
this.showserveypage=false
}
改成这个格式promise.all 方法使用
// 使用Promise.all等待所有图片转换完成
const imagePromises = this.formInline.fileList.map((item, index) => {
return this.BlobToBase64(item.raw).then(res => {
return {
fileName: item.name,
docType: item.formTypeCode,
imageNo: this.formInline.fileList.length + index + 1 + "",
msg: res.split(";base64,")[1]
};
})
});
// 等待所有图片转换完成后再继续
Promise.all(imagePromises).then(images => {
query.imageList = images;
console.log('准备发起', {query});
// 在Promise.all的then中调用接口
startPolicyInvestigate(query).then(res => {
console.log('保单调查发起', res);
if (res.success) {
this.$message.success('发起成功')
this.clearFN()
this.showserveypage = false
}
}).catch(error => {
console.error('发起失败', error);
});
}).catch(error => {
console.error('图片转换失败', error);
});
880

被折叠的 条评论
为什么被折叠?



