上传失败处理

main
mo 1 year ago
parent 1b083f322c
commit 44881935e3

@ -8,6 +8,7 @@
:file-list="fileList" :file-list="fileList"
:on-change="onUploadChange" :on-change="onUploadChange"
:before-upload="beforeFileUpload" :before-upload="beforeFileUpload"
:on-error="handleUploadError"
action="#" action="#"
:accept="imgType" :accept="imgType"
list-type="picture-card" list-type="picture-card"
@ -161,11 +162,17 @@ export default {
let FormDatas = new FormData(); let FormDatas = new FormData();
FormDatas.append("multipartFile", file.raw); FormDatas.append("multipartFile", file.raw);
this.$modal.loading("正在上传,请稍候..."); this.$modal.loading("正在上传,请稍候...");
uploadBankSlipApi(FormDatas).then((res) => { uploadBankSlipApi(FormDatas)
.then((res) => {
this.invoiceForm = res.data; this.invoiceForm = res.data;
this.fileList.push({ name: file.name, url: res.data.fileUrl }); // this.fileList.push({ name: file.name, url: res.data.fileUrl }); //
this.$emit("onConfirm", this.fileList); this.$emit("onConfirm", this.fileList);
this.$modal.closeLoading(); this.$modal.closeLoading();
})
.catch(() => {
this.fileList = [];
this.$modal.closeLoading();
this.$message.error("上传失败");
}); });
}, },
closeImgViewer() { closeImgViewer() {
@ -181,6 +188,10 @@ export default {
this.dialogVisible = true; this.dialogVisible = true;
} }
}, },
handleUploadError() {
this.$modal.closeLoading();
this.$message.error("上传失败");
},
// //
handleScan() { handleScan() {
if (this.fileList.length) { if (this.fileList.length) {

@ -164,11 +164,16 @@ export default {
let FormDatas = new FormData(); let FormDatas = new FormData();
FormDatas.append("multipartFile", file.raw); FormDatas.append("multipartFile", file.raw);
this.$modal.loading("正在上传,请稍候..."); this.$modal.loading("正在上传,请稍候...");
uploadInvoiceApi(FormDatas).then((res) => { uploadInvoiceApi(FormDatas)
.then((res) => {
this.invoiceForm = res.data; this.invoiceForm = res.data;
this.fileList.push({ name: file.name, url: res.data.fileUrl }); // this.fileList.push({ name: file.name, url: res.data.fileUrl }); //
this.$emit("onConfirm", this.fileList); this.$emit("onConfirm", this.fileList);
this.$modal.closeLoading(); this.$modal.closeLoading();
})
.catch(() => {
this.fileList = [];
this.$modal.closeLoading();
}); });
}, },
closeImgViewer() { closeImgViewer() {

Loading…
Cancel
Save