diff --git a/src/components/uploadImage/components/upload-list.vue b/src/components/uploadImage/components/upload-list.vue index 2aece1d2..944e73ac 100644 --- a/src/components/uploadImage/components/upload-list.vue +++ b/src/components/uploadImage/components/upload-list.vue @@ -257,14 +257,56 @@ export default { }, watch: { isLoad() { + console.log(this.isLoad); if (!this.isLoad) { this.$refs.file.value = null; if (this.dicomList.some((item) => item.isUpload === 3)) { + this.$confirm(this.$t("trials:uploadImage:confirm:failUpload"), { + type: "warning", + distinguishCancelAndClose: true, + confirmButtonText: this.$t("common:button:confirm"), + cancelButtonText: this.$t("common:button:cancel"), + }) + .then(() => { + this.againUpload(); + }) + .catch((err) => { + console.log(err); + }); } } }, }, methods: { + // 失败重传 + againUpload() { + for (let i = 0; i < this.uploadList.length; i++) { + let item = this.uploadList[i]; + if (item.status > 2) continue; + item.status = 0; + item.failCount = 0; + item.schedule = Math.floor( + ((item.successCount + item.failCount) / item.count) * 100 + ); + let arr = this.dicomList.filter( + (dicom) => + dicom.StudyInstanceUid === item.StudyInstanceUid && + dicom.isUpload === 3 + ); + arr.forEach((item) => (item.isUpload = 0)); + this.setUploadTask(arr); + } + }, + async setUploadTask(arr) { + let num = arr.length > this.requestNum ? this.requestNum : arr.length; + let funArr = []; + for (let i = 0; i < num; i++) { + funArr.push(this.handleUploadTask(arr, i)); + } + if (funArr.length > 0) { + let res = await Promise.all(funArr); + } + }, // 预上传 async preArchiveDicomStudy(post, index) { try { @@ -275,14 +317,7 @@ export default { let arr = this.dicomList.filter( (dicom) => dicom.StudyInstanceUid === item.StudyInstanceUid ); - let num = arr.length > this.requestNum ? this.requestNum : arr.length; - let funArr = []; - for (let i = 0; i < num; i++) { - funArr.push(this.handleUploadTask(arr, i)); - } - if (funArr.length > 0) { - let res = await Promise.all(funArr); - } + this.setUploadTask(arr); } else { return false; } @@ -333,7 +368,6 @@ export default { uploadData.schedule = 0; uploadData.status = 0; uploadData.FileSize = dicom.file.size; - uploadData.IsDicomReUpload = false; uploadData.SeriesInstanceUidList = [ dicom.SeriesInstanceUid, ]; @@ -461,7 +495,7 @@ export default { (item) => item.StudyInstanceUid === arr[index].StudyInstanceUid )[0]; let res = await dicomToOSS(arr[index].file, path); - if (res) { + if (res && index < 20) { arr[index].path = res; uploadDicom.successCount++; arr[index].isUpload = 2; @@ -475,15 +509,16 @@ export default { uploadDicom.count) * 100 ); - if ( - uploadDicom.schedule >= 100 && - uploadDicom.successCount === uploadDicom.count - ) { - uploadDicom.status = 1; - let res = await this.formatDicom(arr, arr[index].StudyInstanceUid); - if (res) { - uploadDicom.Study = res[arr[index].StudyId]; - uploadDicom.status = 3; + if (uploadDicom.schedule >= 100) { + if (uploadDicom.successCount === uploadDicom.count) { + uploadDicom.status = 1; + if (!uploadDicom.Study) { + let res = await this.formatDicom(arr, arr[index].StudyInstanceUid); + if (res) { + uploadDicom.Study = res[arr[index].StudyId]; + uploadDicom.status = 3; + } + } try { res = await addOrUpdateArchiveTaskStudy(uploadDicom); if (res.IsSuccess) { @@ -496,13 +531,19 @@ export default { } else { uploadDicom.status = 5; } - let flag = this.uploadList.every((item) => item.status > 3); + let flag = this.dicomList.every((item) => item.isUpload > 1); if (flag) this.isLoad = false; } catch (err) { uploadDicom.status = 5; - let flag = this.uploadList.every((item) => item.status > 3); + let flag = this.dicomList.every((item) => item.isUpload > 1); if (flag) this.isLoad = false; } + } else if ( + uploadDicom.count === + uploadDicom.successCount + uploadDicom.failCount + ) { + let flag = this.dicomList.every((item) => item.isUpload > 1); + if (flag) this.isLoad = false; } } let ind = arr.findIndex((item) => !item.isUpload);