From 26e1504d2b30c9284190340c8f8bc001174a90fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=BB=E7=8F=AE=E5=AE=87?= Date: Mon, 27 Nov 2023 18:02:15 +0800 Subject: [PATCH] =?UTF-8?q?Save=20all=20to=20db=20=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E9=87=8D=E5=86=99=EF=BC=8C=E5=8E=BB=E6=8E=89?= =?UTF-8?q?=E5=BC=82=E6=AD=A5=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/spectrumAnalysis/index.vue | 44 +++++++++++++++------------- 1 file changed, 24 insertions(+), 20 deletions(-) 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) {