From 44881935e30272d91e13686d9f439f5ae93729f5 Mon Sep 17 00:00:00 2001 From: MO <448233645@qq.com> Date: Fri, 13 Oct 2023 09:39:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=A4=B1=E8=B4=A5=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/UploadBankSlip/index.vue | 23 +++++++++++++++++------ src/components/UploadInvoice/index.vue | 17 +++++++++++------ 2 files changed, 28 insertions(+), 12 deletions(-) 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;