From b214308e23d7e0d04ae5b9437be0df2cb04d403d Mon Sep 17 00:00:00 2001 From: Xu Zhimeng Date: Wed, 24 Jul 2024 17:45:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E6=8E=A5UpdateROI=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 | 96 +++++++++++++++++-- .../components/BetaGammaSpectrum.vue | 32 ------- .../RoiLimits/components/RoiLimitItem.vue | 1 + 3 files changed, 87 insertions(+), 42 deletions(-) diff --git a/src/views/spectrumAnalysis/beta-analysis.vue b/src/views/spectrumAnalysis/beta-analysis.vue index 4dbcedc..55d1ba3 100644 --- a/src/views/spectrumAnalysis/beta-analysis.vue +++ b/src/views/spectrumAnalysis/beta-analysis.vue @@ -34,7 +34,7 @@ /> -
Update
+
Update
@@ -51,7 +51,6 @@ :histogramDataList="histogramDataList" :boundary="boundaryList" :isLoading.sync="isLoading" - @refreshRoi="refreshRoi" @boundaryChange="handleBoundaryChange" /> @@ -98,7 +97,7 @@ import RoiLimits from './components/RoiLimits/RoiLimits.vue' import RoiParam from './components/RoiParam.vue' import axios from 'axios' import store from '@/store/' -import { getAction, postAction, deleteAction } from '../../api/manage' +import { getAction, postAction, putAction } from '../../api/manage' import { addSampleData, getSampleData, updateSampleData } from '@/utils/SampleStore' import { cloneDeep } from 'lodash' @@ -109,7 +108,11 @@ const SampleType = [ }, { label: 'DetBg Data', - value: 'detBg', + value: 'det', + }, + { + label: 'QC Data', + value: 'qc', }, ] @@ -204,6 +207,12 @@ export default { key: 'ROIAnalyzeLists', data: _result, }) + } else { + const arr = message.split('\n') + this.$warning({ + title: 'Warning', + content: () => arr.map((text) =>
{text}
), + }) } let XeData = [ { @@ -317,11 +326,71 @@ export default { this.resultDisplay = XeData // this.$emit('reAnalyCurr', true, XeData) }, - refreshRoi(data) { - console.log('%c [ 刷新 ]-303', 'font-size:13px; background:pink; color:#bf2c9f;', data) - }, - reDrawRectOri() { - // 更新 + // 点击Update + async handleUpdate() { + const hasEmpty = this.roiParamList.some( + ([startChannel, endChannel]) => (!startChannel && startChannel !== '0') || (!endChannel && endChannel !== '0') + ) + if (hasEmpty) { + this.$message.warning('Channel cannot be null') + return + } + + const hasNegative = this.roiParamList.some(([startChannel, endChannel]) => startChannel < 0 || endChannel < 0) + if (hasNegative) { + this.$message.warning('Channel cannot be negative') + return + } + + try { + this.isLoading = true + const { inputFileName } = this.sample + + const params = this.roiParamList.map(([startChannel, endChannel], index) => ({ + startChannel, + endChannel, + roiNum: index + 1, + })) + + const formData = new FormData() + formData.append('sampleFileName', inputFileName) + formData.append('roiParams', JSON.stringify(params)) + + const { success, result, message } = await putAction('/selfStation/updateROI', formData) + if (success) { + console.log('%c [ ]-353', 'font-size:13px; background:pink; color:#bf2c9f;', result) + const { + ROIOneList, + ROITwoList, + ROIThreeList, + ROIFourList, + ROIOneStart, + ROIOneStop, + ROITwoStart, + ROITwoStop, + ROIThreeStart, + ROIThreeStop, + ROIFourStart, + ROIFourStop, + } = result + + this.ROILists = [ROIOneList, ROITwoList, ROIThreeList, ROIFourList] + + this.boundaryList = [ + [ROIOneStart, ROIOneStop], + [ROITwoStart, ROITwoStop], + [ROIThreeStart, ROIThreeStop], + [ROIFourStart, ROIFourStop], + ] + } else { + this.isLoading = false + this.$message.error(message) + } + } catch (error) { + console.error(error) + } finally { + this.isLoading = false + } }, // async handleDetalSelfStationCache() { // const { inputFileName } = this.sample @@ -366,6 +435,12 @@ export default { } }, changeChartByType(val) { + const currSampleDetail = this.sampleDetail[this.spectraType] + if (!currSampleDetail) { + this.$message.warning(`No ${this.spectraType} spectrum file!`) + return + } + if (val == 'sample') this.currSpectrum = 'Sample' if (val == 'detBg') this.currSpectrum = 'Det' this.roiParamList = cloneDeep(InitialRoiParamList) @@ -388,7 +463,8 @@ export default { ROIThreeStop, ROIFourStart, ROIFourStop, - } = this.sampleDetail[this.spectraType] + } = currSampleDetail + this.spectrumData = spectrumData this.histogramDataList = histogramDataList this.gammaEnergyData = gammaEnergyData diff --git a/src/views/spectrumAnalysis/components/BetaGammaSpectrum.vue b/src/views/spectrumAnalysis/components/BetaGammaSpectrum.vue index 276fd62..31bf7c1 100644 --- a/src/views/spectrumAnalysis/components/BetaGammaSpectrum.vue +++ b/src/views/spectrumAnalysis/components/BetaGammaSpectrum.vue @@ -64,7 +64,6 @@