From 2e4a58c95ac123b89e72c33fea794bc98222310d Mon Sep 17 00:00:00 2001 From: Xu Zhimeng Date: Wed, 31 Jul 2024 16:05:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BF=9D=E5=AD=98=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E5=8F=B0=E7=AB=99=E5=88=B0=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/spectrumAnalysis/beta-analysis.vue | 22 +++ .../components/BetaGammaSpectrum.vue | 1 + src/views/spectrumAnalysis/index.vue | 133 ++++++++++++------ 3 files changed, 111 insertions(+), 45 deletions(-) diff --git a/src/views/spectrumAnalysis/beta-analysis.vue b/src/views/spectrumAnalysis/beta-analysis.vue index 7ef947d..146e936 100644 --- a/src/views/spectrumAnalysis/beta-analysis.vue +++ b/src/views/spectrumAnalysis/beta-analysis.vue @@ -594,6 +594,28 @@ export default { this.$refs.betaModalRef.open(currSampleDetail.bSpectrum, currSampleDetail.betaEnergyData) } }, + + // 保存当前谱到db + async saveCurrentToDB() { + if (!this.ROIAnalyzeLists || !this.ROIAnalyzeLists.length) { + throw new Error('Please Analyse Spectrum First') + } + const { inputFileName: fileName } = this.sample + const { success, message, result } = await getAction('/selfStation/saveToDB', { + fileName, + }) + if (success) { + this.$message.success('Save Success') + // 更新缓存中的DetailedInfomation数据 + updateSampleData({ + inputFileName: fileName, + key: 'DetailedInformation', + data: [...result.DetailedInformation], + }) + } else { + this.$message.error(message) + } + }, }, } diff --git a/src/views/spectrumAnalysis/components/BetaGammaSpectrum.vue b/src/views/spectrumAnalysis/components/BetaGammaSpectrum.vue index a208ab2..8460d10 100644 --- a/src/views/spectrumAnalysis/components/BetaGammaSpectrum.vue +++ b/src/views/spectrumAnalysis/components/BetaGammaSpectrum.vue @@ -600,6 +600,7 @@ export default { position: absolute; border: 1px solid transparent; overflow: visible; + will-change: left, width; &-left, &-right { diff --git a/src/views/spectrumAnalysis/index.vue b/src/views/spectrumAnalysis/index.vue index af48934..3300b74 100644 --- a/src/views/spectrumAnalysis/index.vue +++ b/src/views/spectrumAnalysis/index.vue @@ -825,49 +825,76 @@ export default { * @param { 'all' | 'current' } type */ async handleSaveResultsToDB(type) { - if (this.isReAnalyed_gamma) { - this.isSaving = true - if (type == 'current') { - const hideLoading = this.$message.loading('Saving...', 0) - try { - const { success, message, result } = await getAction('/gamma/saveToDB', { - fileName: this.sampleData.inputFileName, - }) - if (success) { - this.$message.success('Save Success') - this.currSampleDet = [...result.DetailedInformation] - - // 更新缓存中的DetailedInfomation数据 - updateSampleData({ - inputFileName: this.sampleData.inputFileName, - key: 'DetailedInformation', - data: [...result.DetailedInformation], + // 如果是gamma + if (this.isGamma) { + if (this.isReAnalyed_gamma) { + this.isSaving = true + if (type == 'current') { + const hideLoading = this.$message.loading('Saving...', 0) + try { + const { success, message, result } = await getAction('/gamma/saveToDB', { + fileName: this.sampleData.inputFileName, }) - } else { - this.$message.error(message) + 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) + } + } catch (error) { + console.error(error) + } finally { + hideLoading() + this.isSaving = false + } + } else { + const gammaList = this.sampleList.filter(({ sampleType }) => sampleType !== 'B' && sampleType !== 'C') + const gammaInputFileNames = gammaList.map((item) => item.inputFileName) + try { + this.isSaving = true + for (const fileName of gammaInputFileNames) { + await this.gammaSaveToDBRequest(fileName) + } + } catch (error) { + console.log(error) + } finally { + this.isSaving = false } - } catch (error) { - console.error(error) - } finally { - hideLoading() - this.isSaving = false } } else { - const gammaList = this.sampleList.filter(({ sampleType }) => sampleType !== 'B' && sampleType !== 'C') - const gammaInputFileNames = gammaList.map((item) => item.inputFileName) - try { - this.isSaving = true - for (const fileName of gammaInputFileNames) { - await this.gammaSaveToDBRequest(fileName) - } - } catch (error) { - console.log(error) - } finally { - this.isSaving = false - } + this.$message.warn('Please Analyse Spectrum First') + } + } + // 如果是beta,也就是自建台站 + else if (this.isBeta) { + this.isSaving = true + const hideLoading = this.$message.loading('Saving...', 0) + + try { + // 保存当前 + await this.$refs.betaAnalysisRef.saveCurrentToDB() + if (type == 'all') { + const selfSampleLists = this.sampleList.filter( + ({ sampleType, inputFileName }) => sampleType == 'C' && inputFileName !== this.sampleData.inputFileName + ) + const selfSampleInputFileNames = selfSampleLists.map((item) => item.inputFileName) + for (const fileName of selfSampleInputFileNames) { + await this.saveSelfStationToDBRequest(fileName) + } + } + } catch (error) { + this.$message.error(error && (error.message || error)) + } finally { + hideLoading() + this.isSaving = false } - } else { - this.$message.warn('Please Analyse Spectrum First') } }, @@ -893,6 +920,25 @@ export default { console.error(error) } }, + + // 保存自建台站谱到数据库 + async saveSelfStationToDBRequest(fileName) { + try { + const { result, success, message } = await getAction('/selfStation/saveToDB', { fileName }) + if (success) { + // 更新缓存中的DetailedInfomation数据 + // updateSampleData({ + // inputFileName: fileName, + // key: 'DetailedInformation', + // data: [...result.DetailedInformation], + // }) + } else { + this.$message.error(message) + } + } catch (error) { + console.error(error) + } + }, handleSaveResultsToDB_Cuurrent() { // xeflag params_toDB if (this.params_toDB.savedAnalysisResult) { @@ -1055,7 +1101,6 @@ export default { handleResize() { this.$refs.gammaAnalysisRef && this.$refs.gammaAnalysisRef.resize() this.$refs.betaGammaAnalysisRef && this.$refs.betaGammaAnalysisRef.resize() - this.$refs.betaAnalysisRef && this.$refs.betaAnalysisRef.resize() }, // Beta-Gamma Energy Calibration 的重新分析 @@ -1273,7 +1318,7 @@ export default { children: [ { type: 'MultiLevelMenu', - show: this.isBetaGamma || this.isGamma, + show: this.isBetaGamma || this.isGamma || this.isBeta, attrs: { children: [ { @@ -1282,20 +1327,18 @@ export default { { title: 'Save Txt', key: 'saveTxt', - show: this.isBetaGamma, }, { title: 'Save Excel', key: 'saveExcel', - show: this.isBetaGamma, }, { title: 'Save Html', key: 'saveHtml', - show: this.isBetaGamma, }, ], key: 'resultsToFile', + show: this.isBetaGamma, }, { title: 'Save Results to DB', @@ -1303,12 +1346,12 @@ export default { { title: 'Save Current', key: 'current', - show: this.isGamma, + show: this.isGamma || this.isBeta, }, { title: 'Save All', key: 'all', - show: this.isGamma, + show: this.isGamma || this.isBeta, }, ], key: 'resultsToDB',