diff --git a/src/components/UploadBankSlip/index.vue b/src/components/UploadBankSlip/index.vue index daf2bd80..f11ab463 100644 --- a/src/components/UploadBankSlip/index.vue +++ b/src/components/UploadBankSlip/index.vue @@ -8,6 +8,7 @@ :file-list="fileList" :on-change="onUploadChange" :before-upload="beforeFileUpload" + :on-error="handleUploadError" action="#" :accept="imgType" list-type="picture-card" @@ -161,12 +162,18 @@ export default { let FormDatas = new FormData(); FormDatas.append("multipartFile", file.raw); this.$modal.loading("正在上传,请稍候..."); - uploadBankSlipApi(FormDatas).then((res) => { - this.invoiceForm = res.data; - this.fileList.push({ name: file.name, url: res.data.fileUrl }); //成功过后手动将文件添加到展示列表里 - this.$emit("onConfirm", this.fileList); - this.$modal.closeLoading(); - }); + uploadBankSlipApi(FormDatas) + .then((res) => { + this.invoiceForm = res.data; + this.fileList.push({ name: file.name, url: res.data.fileUrl }); //成功过后手动将文件添加到展示列表里 + this.$emit("onConfirm", this.fileList); + this.$modal.closeLoading(); + }) + .catch(() => { + this.fileList = []; + this.$modal.closeLoading(); + this.$message.error("上传失败"); + }); }, closeImgViewer() { this.dialogVisible = false; @@ -181,6 +188,10 @@ export default { this.dialogVisible = true; } }, + handleUploadError() { + this.$modal.closeLoading(); + this.$message.error("上传失败"); + }, // 发票识别 handleScan() { if (this.fileList.length) { diff --git a/src/components/UploadInvoice/index.vue b/src/components/UploadInvoice/index.vue index 3d48e152..eea67420 100644 --- a/src/components/UploadInvoice/index.vue +++ b/src/components/UploadInvoice/index.vue @@ -164,12 +164,17 @@ export default { let FormDatas = new FormData(); FormDatas.append("multipartFile", file.raw); this.$modal.loading("正在上传,请稍候..."); - uploadInvoiceApi(FormDatas).then((res) => { - this.invoiceForm = res.data; - this.fileList.push({ name: file.name, url: res.data.fileUrl }); //成功过后手动将文件添加到展示列表里 - this.$emit("onConfirm", this.fileList); - this.$modal.closeLoading(); - }); + uploadInvoiceApi(FormDatas) + .then((res) => { + this.invoiceForm = res.data; + this.fileList.push({ name: file.name, url: res.data.fileUrl }); //成功过后手动将文件添加到展示列表里 + this.$emit("onConfirm", this.fileList); + this.$modal.closeLoading(); + }) + .catch(() => { + this.fileList = []; + this.$modal.closeLoading(); + }); }, closeImgViewer() { this.dialogVisible = false;