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

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

View File

@ -731,32 +731,36 @@ export default {
} }
} else { } else {
this.allSampleDet = [] this.allSampleDet = []
let count = 0 const { inputFileName } = this.sampleData
let gammaList = this.sampleList.filter(({ sampleType }) => sampleType !== 'B') 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 = { const gammaInputFileNames = gammaList.map((item) => item.inputFileName)
fileName, if (gammaInputFileNames.length > 0) {
this.fatchSaveDbAll(gammaInputFileNames, inputFileName)
} }
const { result, success } = await getAction('/gamma/saveToDB', params) }
} 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) { if (success) {
this.$set(this.allSampleDet, fileName, [...result.DetailedInformation]) this.$set(this.allSampleDet, fileNames[0], [...result.DetailedInformation])
count += 1 fileNames.splice(0, 1)
if (count == length) { if (fileNames.length > 0) {
this.fatchSaveDbAll(fileNames, currFileName)
} else {
this.isSaving = false this.isSaving = false
this.currSampleDet = this.allSampleDet[this.sampleData.inputFileName] this.currSampleDet = this.allSampleDet[this.sampleData.inputFileName]
} }
} else { } else {
this.isSaving = false this.isSaving = false
this.$message.error(message) this.$message.error(message)
break
} }
} } catch (error) {
} this.isSaving = false
} else {
this.$message.warn('Please Analyse Spectrum First')
} }
}, },
handleSaveResultsToDB_Cuurrent() { handleSaveResultsToDB_Cuurrent() {