Save all to db 逻辑方法重写,去掉异步的逻辑

This commit is contained in:
任珮宇 2023-11-27 18:02:15 +08:00
parent 0ff3f3a003
commit 26e1504d2b

View File

@ -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) {