From 4b703c79133569cc91112f1d2bfc8d26974d5afd Mon Sep 17 00:00:00 2001 From: limingyu Date: Sat, 3 Feb 2024 16:09:25 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=91=E7=AE=A1=E7=AB=AFbug=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=EF=BC=9A13984?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../inspection/components/edit.vue | 62 +++++++++++-------- 1 file changed, 35 insertions(+), 27 deletions(-) diff --git a/src/views/safetyenvironmental/inspection/components/edit.vue b/src/views/safetyenvironmental/inspection/components/edit.vue index 0f550ff..ab4e2a1 100644 --- a/src/views/safetyenvironmental/inspection/components/edit.vue +++ b/src/views/safetyenvironmental/inspection/components/edit.vue @@ -908,10 +908,10 @@ export default { requestFN( '/safetyenvironmental/' + this.dialogType, { ...this.form } - ).then((data) => { + ).then(async(data) => { for (let i = 0; i < data.pd.hiddenList.length; i++) { - this.uploadImg(this.hdFile[i]['fileHdImgList'], data.pd.hiddenList[i].HIDDEN_ID) - this.uploadVideo(this.hdFile[i]['fileVideoList'], data.pd.hiddenList[i].HIDDEN_ID) + await this.uploadImg(this.hdFile[i]['fileHdImgList'], data.pd.hiddenList[i].HIDDEN_ID) + await this.uploadVideo(this.hdFile[i]['fileVideoList'], data.pd.hiddenList[i].HIDDEN_ID) } this.$message({ message: '保存成功', @@ -923,6 +923,7 @@ export default { }).catch((e) => { this.listLoading = false loading.close() + this.goBack() }) } else { return false @@ -931,35 +932,42 @@ export default { }, // 上传隐患视频 uploadVideo(list, HIDDEN_ID) { - const formData = new FormData() - for (var i = 0; i < list.length; i++) { - formData.append('FFILE', list[i]) - } - formData.append('FOREIGN_KEY', HIDDEN_ID) - formData.append('TYPE', 102) - upload( - '/imgfiles/addVideo', - formData - ).then((data) => { - }).catch((e) => { - this.listLoading = false + return new Promise((resolve, reject) => { + const formData = new FormData() + for (var i = 0; i < list.length; i++) { + formData.append('FFILE', list[i]) + } + formData.append('FOREIGN_KEY', HIDDEN_ID) + formData.append('TYPE', 102) + upload( + '/imgfiles/addVideo', + formData + ).then((data) => { + resolve() + }).catch((e) => { + this.listLoading = false + }) }) }, // 上传隐患照片 uploadImg(list, HIDDEN_ID) { - const formData = new FormData() - for (var i = 0; i < list.length; i++) { - formData.append('FFILE', list[i]) - } - formData.append('FOREIGN_KEY', HIDDEN_ID) - formData.append('TYPE', 3) - upload( - '/imgfiles/add', - formData - ).then((data) => { - }).catch((e) => { - this.listLoading = false + return new Promise((resolve, reject) => { + const formData = new FormData() + for (var i = 0; i < list.length; i++) { + formData.append('FFILE', list[i]) + } + formData.append('FOREIGN_KEY', HIDDEN_ID) + formData.append('TYPE', 3) + upload( + '/imgfiles/add', + formData + ).then((data) => { + resolve() + }).catch((e) => { + this.listLoading = false + }) }) + }, goBack() {