diff --git a/src/views/spectrumAnalysis/index.vue b/src/views/spectrumAnalysis/index.vue index ca711d8..b841bab 100644 --- a/src/views/spectrumAnalysis/index.vue +++ b/src/views/spectrumAnalysis/index.vue @@ -731,34 +731,38 @@ export default { } } else { this.allSampleDet = [] - let count = 0 + const { inputFileName } = this.sampleData let gammaList = this.sampleList.filter(({ sampleType }) => sampleType !== 'B') - let length = gammaList.length - for (let i = 0; i < gammaList; i++) { - const { inputFileName: fileName } = array[i] - const params = { - fileName, - } - const { result, success } = await getAction('/gamma/saveToDB', params) - if (success) { - this.$set(this.allSampleDet, fileName, [...result.DetailedInformation]) - count += 1 - if (count == length) { - this.isSaving = false - this.currSampleDet = this.allSampleDet[this.sampleData.inputFileName] - } - } else { - this.isSaving = false - this.$message.error(message) - break - } + const gammaInputFileNames = gammaList.map((item) => item.inputFileName) + if (gammaInputFileNames.length > 0) { + this.fatchSaveDbAll(gammaInputFileNames, inputFileName) } } } else { this.$message.warn('Please Analyse Spectrum First') } }, + async fatchSaveDbAll(fileNames, currFileName) { + try { + const { result, success, message } = await getAction('/gamma/saveToDB', { fileName: fileNames[0] }) + if (success) { + this.$set(this.allSampleDet, fileNames[0], [...result.DetailedInformation]) + fileNames.splice(0, 1) + if (fileNames.length > 0) { + this.fatchSaveDbAll(fileNames, currFileName) + } else { + this.isSaving = false + this.currSampleDet = this.allSampleDet[this.sampleData.inputFileName] + } + } else { + this.isSaving = false + this.$message.error(message) + } + } catch (error) { + this.isSaving = false + } + }, handleSaveResultsToDB_Cuurrent() { // xeflag params_toDB if (this.params_toDB.savedAnalysisResult) {