From 64729f91dfd19e1227a92af87fb6b86477279ecd Mon Sep 17 00:00:00 2001 From: Xu Zhimeng Date: Fri, 26 Jul 2024 18:37:44 +0800 Subject: [PATCH] =?UTF-8?q?gamma=E4=BF=9D=E5=AD=98=E5=90=8E=E6=9C=AA?= =?UTF-8?q?=E6=9B=B4=E6=96=B0Sample=20Status=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/spectrumAnalysis/index.vue | 64 +++++++++++++++++----------- 1 file changed, 39 insertions(+), 25 deletions(-) diff --git a/src/views/spectrumAnalysis/index.vue b/src/views/spectrumAnalysis/index.vue index d814861..2f33e88 100644 --- a/src/views/spectrumAnalysis/index.vue +++ b/src/views/spectrumAnalysis/index.vue @@ -315,7 +315,7 @@ import BGLogViewer from './components/Modals/BetaGammaModals/BGLogViewer.vue' import { saveAs } from 'file-saver' import CompareFromDbModal from './components/Modals/CompareFromDBModal.vue' -import { clearSampleData, getSampleData, updateSampleDataAnaly } from '@/utils/SampleStore' +import { clearSampleData, getSampleData, updateSampleData, updateSampleDataAnaly } from '@/utils/SampleStore' import BetaAnalyzeInteractiveToolModal from './components/Modals/SelfStation/BetaAnalyzeInteractiveToolModal/index.vue' import SelfStationAnalyzeSettingModal from './components/Modals/SelfStation/SelfStationAnalyzeSettingModal.vue' @@ -497,8 +497,6 @@ export default { percentBar: 0, analysedFileName: '', //分析完成的文件名称 currSampleDet: [], // DetailedInformation - allSampleDet: {}, // DetailedInformation all - isComparing: false, isStriping: false, } @@ -694,7 +692,6 @@ export default { this.analysisType = ANALYZE_TYPE.GAMMA } this.sampleData = this.newSampleData = sample - this.currSampleDet = this.allSampleDet[sample.inputFileName] this.params_toDB.comment = '' }, @@ -725,7 +722,7 @@ export default { this.isSaving = false } } else { - let list = this.sampleList.filter((item) => item.sampleType !== 'B') + let list = this.sampleList.filter((item) => item.sampleType !== 'B' && item.sampleType !== 'C') if (list.length > 0) { list.forEach(async (item) => { const url = saveFormat == 'xls' ? '/gamma/saveToExcel' : saveFormat == 'txt' ? '/gamma/saveToTxt' : '' @@ -839,6 +836,13 @@ export default { if (success) { this.$message.success('Save Success') this.currSampleDet = [...result.DetailedInformation] + + // 更新缓存中的DetailedInfomation数据 + updateSampleData({ + inputFileName: this.sampleData.inputFileName, + key: 'DetailedInformation', + data: [...result.DetailedInformation], + }) } else { this.$message.error(message) } @@ -849,37 +853,47 @@ export default { this.isSaving = false } } else { - this.allSampleDet = [] - const { inputFileName } = this.sampleData - let gammaList = this.sampleList.filter(({ sampleType }) => sampleType !== 'B') - + const gammaList = this.sampleList.filter(({ sampleType }) => sampleType !== 'B' && sampleType !== 'C') const gammaInputFileNames = gammaList.map((item) => item.inputFileName) - if (gammaInputFileNames.length > 0) { - this.fatchSaveDbAll(gammaInputFileNames, inputFileName) + const saveToDbPromises = gammaInputFileNames.map((fileName) => this.gammaSaveToDBRequest(fileName)) + try { + this.isSaving = true + await Promise.all(saveToDbPromises) + } catch (error) { + console.log(error) + } finally { + this.isSaving = false } } } else { this.$message.warn('Please Analyse Spectrum First') } }, - async fatchSaveDbAll(fileNames, currFileName) { + + // 保存gamma谱到数据库 + async gammaSaveToDBRequest(fileName) { try { - const { result, success, message } = await getAction('/gamma/saveToDB', { fileName: fileNames[0] }) + const { result, success, message } = await getAction('/gamma/saveToDB', { fileName }) 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] + // 更新缓存中的DetailedInfomation数据 + updateSampleData({ + inputFileName: fileName, + key: 'DetailedInformation', + data: [...result.DetailedInformation], + }) + + console.log('%c [ 更更新缓存 ]-891', 'font-size:13px; background:pink; color:#bf2c9f;') + + if (this.sampleData.inputFileName == fileName) { + this.currSampleDet = [...result.DetailedInformation] + + console.log('%c [ 更新当前 ]-894', 'font-size:13px; background:pink; color:#bf2c9f;') } } else { - this.isSaving = false this.$message.error(message) } } catch (error) { - this.isSaving = false + console.error(error) } }, handleSaveResultsToDB_Cuurrent() { @@ -933,7 +947,7 @@ export default { fetchAndDownload('/gamma/saveToPHD', params, 'get') } else { this.sampleList - .filter(({ sampleType }) => sampleType !== 'B') + .filter(({ sampleType }) => sampleType !== 'B' && sampleType !== 'C') .forEach(({ inputFileName: fileName }) => { const params = { fileName, @@ -951,7 +965,7 @@ export default { this.analyzeAllModalVisible = true const { inputFileName, sampleType } = this.sampleData // 获取所有的gamma list - const gammaSampleList = this.sampleList.filter((sample) => sample.sampleType !== 'B') + const gammaSampleList = this.sampleList.filter((sample) => sample.sampleType !== 'B' && sample.sampleType !== 'C') this.gammaSampleNum = gammaSampleList.length const gammaInputFileNames = gammaSampleList.map((item) => item.inputFileName) @@ -960,7 +974,7 @@ export default { } }, async fetchReprocessing(fileNames, currFileName, sampleType) { - if (fileNames[0] == currFileName && sampleType !== 'B') { + if (fileNames[0] == currFileName && sampleType !== 'B' && sampleType !== 'C') { this.$refs.gammaAnalysisRef.reProcessing(false).then((res) => { if (res) { this.finishCont++