From a921c64f6b22e9c112a26b19f6edd4572195bc3b Mon Sep 17 00:00:00 2001 From: Xu Zhimeng Date: Thu, 21 Sep 2023 19:41:16 +0800 Subject: [PATCH 01/13] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E9=83=A8?= =?UTF-8?q?=E5=88=86=E6=A0=B7=E5=BC=8F=E5=8F=8A=E5=8A=9F=E8=83=BD,?= =?UTF-8?q?=EF=BC=8C=E5=A2=9E=E5=8A=A0Gamma=E7=9A=84Save=20to=20DB=20?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=8C=E5=AE=8C=E6=88=90Gamma=20Calibratio?= =?UTF-8?q?n=E5=BC=B9=E7=AA=97=E4=B8=AD=E7=9A=84Call=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/CustomChart/index.vue | 2 +- src/utils/number.js | 10 ++++ .../spectrumAnalysis/beta-gamma-analysis.vue | 20 ++++++-- .../components/Modals/ArrRrrModal.vue | 4 +- .../Modals/EfficiencyCalibrationModal.vue | 49 ++++++++++++++++++- .../Modals/EnergyCalibrationModal.vue | 49 ++++++++++++++++++- .../components/Modals/LoadFromDBModal.vue | 10 ++-- .../components/Modals/NuclideLibraryModal.vue | 37 +++++++++----- .../Modals/ResolutionCalibrationModal.vue | 49 ++++++++++++++++++- .../Modals/SampleInfomationModal.vue | 47 +++++++++--------- src/views/spectrumAnalysis/gamma-analysis.vue | 10 +++- src/views/spectrumAnalysis/index.vue | 49 +++++++++++-------- 12 files changed, 268 insertions(+), 68 deletions(-) create mode 100644 src/utils/number.js diff --git a/src/components/CustomChart/index.vue b/src/components/CustomChart/index.vue index d568449..bc36294 100644 --- a/src/components/CustomChart/index.vue +++ b/src/components/CustomChart/index.vue @@ -6,7 +6,7 @@ import * as echarts from 'echarts' import 'echarts-gl' const events = ['click', 'brushEnd'] -const zrEvents = ['mousemove', 'mousedown', 'mouseup', 'click'] +const zrEvents = ['mousemove', 'mousedown', 'mouseup', 'click', 'dblclick'] export default { props: { option: { diff --git a/src/utils/number.js b/src/utils/number.js new file mode 100644 index 0000000..19df3b6 --- /dev/null +++ b/src/utils/number.js @@ -0,0 +1,10 @@ +import { isNullOrUndefined } from './util' + +/** + * 保留小数 + * @param { string | number } num 数字 + * @param { number } digit 保留位数 + */ +export const toFixed = (num, digit) => { + return isNullOrUndefined(num) ? '' : Number(num).toFixed(digit) +} diff --git a/src/views/spectrumAnalysis/beta-gamma-analysis.vue b/src/views/spectrumAnalysis/beta-gamma-analysis.vue index 6932644..072e3dc 100644 --- a/src/views/spectrumAnalysis/beta-gamma-analysis.vue +++ b/src/views/spectrumAnalysis/beta-gamma-analysis.vue @@ -11,7 +11,13 @@ QC Flags - + @@ -353,12 +359,11 @@ export default { // 重新分析,设置右侧折线图的Energy reanalyse([type, data]) { const energy = data.map(item => [item.y]) - if(type == 'gamma') { + if (type == 'gamma') { this.gammaEnergyData = energy } else { this.betaEnergyData = energy } - } }, watch: { @@ -386,6 +391,15 @@ export default { } } + .sample-select { + ::v-deep { + .ant-select-selection { + background-color: transparent !important; + color: #ade6ee; + } + } + } + &-main { height: calc(100% - 51px); display: flex; diff --git a/src/views/spectrumAnalysis/components/Modals/ArrRrrModal.vue b/src/views/spectrumAnalysis/components/Modals/ArrRrrModal.vue index 46d0c17..cf4f1b5 100644 --- a/src/views/spectrumAnalysis/components/Modals/ArrRrrModal.vue +++ b/src/views/spectrumAnalysis/components/Modals/ArrRrrModal.vue @@ -1,5 +1,5 @@ @@ -235,6 +223,7 @@ import BetaGammaEnergyCalibrationModal from './components/Modals/BetaGammaModals import StripModal from './components/Modals/StripModal.vue' import AutomaticAnalysisLogModal from './components/Modals/BetaGammaModals/AutomaticAnalysisLogModal.vue' import BetaGammaExtrapolationModal from './components/Modals/BetaGammaModals/BetaGammaExtrapolationModal.vue' +import { getAction } from '@/api/manage' // 分析类型 const ANALYZE_TYPE = { @@ -384,10 +373,10 @@ export default { }, handleLoadSampleFromFile(sampleList) { let arr = sampleList.filter(item => { - return Object.keys(item).length>4 + return Object.keys(item).length > 4 }) arr.forEach(item => { - item.sampleId = "" + item.sampleId = '' item.inputFileName = item.sampleFileName item.sampleType = item.sampleSystemType }) @@ -424,8 +413,28 @@ export default { * 保存结果到数据库 * @param { 'all' | 'current' } type */ - handleSaveResultsToDB(type) { + async handleSaveResultsToDB(type) { console.log('%c [ saveResultsToDB ]-157', 'font-size:13px; background:pink; color:#bf2c9f;', type) + if (this.isBetaGamma) { + } else if (this.isGamma) { + if (type == 'current') { + const hideLoading = this.$message.loading('Saving...', 0) + try { + const { success, message } = await getAction('/gamma/saveToDB', { + fileName: this.sampleData.inputFileName + }) + if (success) { + this.$message.success('Save Success') + } else { + this.$message.error(message) + } + } catch (error) { + console.error(error) + } finally { + hideLoading() + } + } + } }, /** @@ -906,7 +915,7 @@ export default { type: 'a-menu-item', title: 'Automatic Analysis Log', handler: () => { - this.autoAnalysisMogModalType = this.isGamma?1:this.isBetaGamma?2:1 + this.autoAnalysisMogModalType = this.isGamma ? 1 : this.isBetaGamma ? 2 : 1 this.autoAnalysisMogModalVisible = true } }, From 3aedc2445d6ea5306e84469935be96ed730617b2 Mon Sep 17 00:00:00 2001 From: Xu Zhimeng Date: Mon, 25 Sep 2023 14:55:51 +0800 Subject: [PATCH 02/13] =?UTF-8?q?fix:=20Compare=E5=8A=9F=E8=83=BD=EF=BC=8C?= =?UTF-8?q?=E5=92=8CConfigure=E7=9A=84Save=E5=AF=B9=E6=8E=A5=EF=BC=8C?= =?UTF-8?q?=E5=8F=8A=E9=83=A8=E5=88=86=E4=B8=BB=E9=A1=B5=E9=9D=A2=E7=9A=84?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AnalyzeInteractiveToolModal/index.vue | 34 +++-- .../components/Modals/AnalyzeSettingModal.vue | 116 +++++++++++---- .../Modals/CompareFileListModal.vue | 138 ++++++++++++++++++ src/views/spectrumAnalysis/gamma-analysis.vue | 93 ++++++++++-- src/views/spectrumAnalysis/index.vue | 10 +- 5 files changed, 339 insertions(+), 52 deletions(-) create mode 100644 src/views/spectrumAnalysis/components/Modals/CompareFileListModal.vue diff --git a/src/views/spectrumAnalysis/components/Modals/AnalyzeInteractiveToolModal/index.vue b/src/views/spectrumAnalysis/components/Modals/AnalyzeInteractiveToolModal/index.vue index 40e8b85..88d85dd 100644 --- a/src/views/spectrumAnalysis/components/Modals/AnalyzeInteractiveToolModal/index.vue +++ b/src/views/spectrumAnalysis/components/Modals/AnalyzeInteractiveToolModal/index.vue @@ -407,6 +407,12 @@ const thumbnailOption = { series: null } +const nuclideIdentifyModal = { + possibleNuclide: '', + tolerance: 0.5, + identifiedNuclide: '' +} + // 操作类型 export const Operators = { ADD: 1, // 新增 @@ -442,6 +448,7 @@ export default { energy: [], list: [], BaseCtrls: {}, + FitBaseLine: '#fff', sampleId: -1, peakCommentModalVisible: false, // Comment 弹窗是否显示 @@ -454,11 +461,7 @@ export default { fitPeaksAndBaselineModalVisible: false, // Fit Peaks And Base Line 弹窗 nuclideReviewModalVisible: false, // Nuclide Review 弹窗 - model: { - possibleNuclide: '', - tolerance: 0.5, - identifiedNuclide: '' - }, + model: cloneDeep(nuclideIdentifyModal), currChannel: undefined, // 当currChannel前选中的channel selectedTableItem: undefined, // 当前选中的表格项 @@ -483,6 +486,9 @@ export default { try { this.isLoading = true this.option.series = [] + this.thumbnailOption.series = [] + this.list = [] + this.model = cloneDeep(nuclideIdentifyModal) const { success, result, message } = await getAction('/gamma/InteractiveTool', { sampleId: this.sampleId, @@ -501,7 +507,8 @@ export default { channelPeakChart, energy, table, - BaseCtrls + BaseCtrls, + FitBaseLine } = result console.log('%c [ ]-374', 'font-size:13px; background:pink; color:#bf2c9f;', result) @@ -512,6 +519,7 @@ export default { this.channelPeakChart = channelPeakChart this.energy = energy this.BaseCtrls = BaseCtrls + this.FitBaseLine = FitBaseLine const series = [] @@ -1246,7 +1254,7 @@ export default { const baseLineEditSeries = buildLineSeries( 'BaseLine_Edit', this._channelBaseLineChart.pointlist.map(({ x, y }) => [x, y]), - '#fff', + this.FitBaseLine, { zlevel: 21 } @@ -1296,6 +1304,8 @@ export default { buildGraphicRect(xAxis, yAxis) { const chart = this.$refs.chartRef.getChartInstance() const [xPix, yPix] = chart.convertToPixel('grid', [xAxis, yAxis]) + const that = this + return { type: 'rect', id: Math.random().toString(), @@ -1312,12 +1322,12 @@ export default { fill: 'transparent', lineWidth: 2 }, - draggable: false, + draggable: this.isModifying, ondrag: function() { const [xPixel] = chart.convertToPixel('grid', [xAxis, yAxis]) // 保持x轴不变 this.position[0] = xPixel - this.redrawBaseLine() + that.redrawBaseLine() }, ondragend: ({ offsetY }) => { this.setGraphicDraggable(false) @@ -1351,7 +1361,7 @@ export default { // 重新生成基线 redrawBaseLine() { - console.log('%c [ 重新生成基线 ]-1355', 'font-size:13px; background:pink; color:#bf2c9f;', ) + console.log('%c [ 重新生成基线 ]-1355', 'font-size:13px; background:pink; color:#bf2c9f;') }, // 根据数据绘制 + 号 @@ -1472,7 +1482,7 @@ export default { // 修改控制点 handleModifyCP() { - this.setGraphicDraggable(true) + this.setGraphicDraggable(!this.isModifying) }, // 编辑斜率 @@ -1560,7 +1570,7 @@ export default { this.channelBaseCPChart = this._channelBaseCPChart this.handleSwitchOperation() - + this.$bus.$emit('accept') }, diff --git a/src/views/spectrumAnalysis/components/Modals/AnalyzeSettingModal.vue b/src/views/spectrumAnalysis/components/Modals/AnalyzeSettingModal.vue index dca474c..a855d14 100644 --- a/src/views/spectrumAnalysis/components/Modals/AnalyzeSettingModal.vue +++ b/src/views/spectrumAnalysis/components/Modals/AnalyzeSettingModal.vue @@ -13,44 +13,40 @@
- + KeV
- + KeV
- + KeV
- +
- + - + - - Update Calibration - + Update Calibration - - Keep Calibration Peak Search Peaks - + Keep Calibration Peak Search Peaks @@ -61,13 +57,13 @@ - + - + - + @@ -75,12 +71,12 @@ - + - + @@ -90,10 +86,20 @@
- + - +
@@ -106,10 +112,11 @@ @@ -198,7 +256,7 @@ export default { display: flex; align-items: center; - .ant-input-number { + .ant-input { margin-right: 10px; } } diff --git a/src/views/spectrumAnalysis/components/Modals/CompareFileListModal.vue b/src/views/spectrumAnalysis/components/Modals/CompareFileListModal.vue new file mode 100644 index 0000000..b49e6ec --- /dev/null +++ b/src/views/spectrumAnalysis/components/Modals/CompareFileListModal.vue @@ -0,0 +1,138 @@ + + + + + diff --git a/src/views/spectrumAnalysis/gamma-analysis.vue b/src/views/spectrumAnalysis/gamma-analysis.vue index d302b1e..bce2a30 100644 --- a/src/views/spectrumAnalysis/gamma-analysis.vue +++ b/src/views/spectrumAnalysis/gamma-analysis.vue @@ -88,6 +88,8 @@ :channel="currChannel" :nuclide="nuclideReview.nuclide" /> + + @@ -105,6 +107,7 @@ import { buildLineSeries, findSeriesByName, getXAxisAndYAxisByPosition, rangeNum import { cloneDeep } from 'lodash' import axios from 'axios' import NuclideReviewModal from './components/Modals/AnalyzeInteractiveToolModal/components/NuclideReviewModal.vue' +import CompareFileListModal from './components/Modals/CompareFileListModal.vue' // 初始配置 const initialOption = { @@ -269,6 +272,7 @@ export default { NuclideLibrary, ButtonWithSwitchIcon, NuclideReviewModal, + CompareFileListModal, }, data() { return { @@ -302,6 +306,8 @@ export default { nuclide: '', }, currChannel: -1, + + compareFileListModalVisible: false, // Compare 弹窗 } }, created() { @@ -359,8 +365,7 @@ export default { const { inputFileName: fileName } = this.sample try { this.isLoading = true - this.option.series = [] - this.thumbnailOption.series = [] + this.reset() // const { success, result, message } = Response const { success, result, message } = await getAction('/gamma/gammaByFile', { fileName, @@ -439,11 +444,8 @@ export default { this.shapeChannelData = shapeChannelData this.shapeEnergyData = shapeEnergyData - this.option.yAxis.max = - shadowChannelChart.pointlist && Math.ceil(Math.max(...shadowChannelChart.pointlist.map((item) => item.y)) * 1.1) - this.thumbnailOption.yAxis.max = - shadowChannelChart.pointlist && Math.ceil(Math.max(...shadowChannelChart.pointlist.map((item) => item.y)) * 1.1) - + this.option.yAxis.max = 'dataMax' + this.resetThumbnailChartDataMax() const series = [] // 推入Spectrum Line @@ -566,6 +568,13 @@ export default { ) }) series.push(...peakLines) + + series.push( + buildLineSeries('Compare', [], '#fff', { + symbolSize: 2, + }) + ) + this.option.series = series this.option.tooltip.formatter = this.tooltipFormatter @@ -590,6 +599,8 @@ export default { // Graph Assistance 操作 handleGraphAssistanceChange({ type, label, value }) { + const compareLineSeries = findSeriesByName(this.option.series, 'Compare') + // 类型变化 if (type == 'labelChange') { switch (label) { @@ -629,6 +640,8 @@ export default { this.redrawPeakLine() this.redrawThumbnailChart() + + this.redrawLineBySeriesName('Compare', this.energyCompareLine, this.channelCompareLine) break case 'Lines': this.option.series[0].type = 'line' @@ -636,6 +649,9 @@ export default { this.thumbnailOption.series[0].type = 'line' this.thumbnailOption.series[0].symbol = 'none' + + compareLineSeries.type = 'line' + compareLineSeries.symbol = 'none' break case 'Scatter': this.option.series[0].type = 'scatterGL' @@ -643,6 +659,9 @@ export default { this.thumbnailOption.series[0].type = 'scatterGL' this.thumbnailOption.series[0].symbol = 'circle' + + compareLineSeries.type = 'scatterGL' + compareLineSeries.symbol = 'circle' break } } @@ -677,7 +696,7 @@ export default { }, // 根据seriesName重绘线 - redrawLineBySeriesName(seriesName, energyData, channelData, isShow = true) { + redrawLineBySeriesName(seriesName, energyData, channelData, isShow = true, color) { const series = findSeriesByName(this.option.series, seriesName) if (isShow) { const data = this.isEnergy() ? energyData : channelData @@ -685,6 +704,9 @@ export default { } else { series.data = [] } + if (color) { + series.itemStyle.color = color + } }, // 重绘控制点 @@ -1055,7 +1077,7 @@ export default { this.option.xAxis.min = 1 this.option.xAxis.max = 'dataMax' this.option.yAxis.min = 1 - this.option.yAxis.max = Math.ceil(Math.max(...this.shadowChannelChart.pointlist.map((item) => item.y)) * 1.1) + this.option.yAxis.max = 'dataMax' this.thumbnailOption.series[0].markLine.data = [] this.thumbnailChartRect = [] @@ -1115,6 +1137,9 @@ export default { this.redrawLineBySeriesName('Spectrum', this.shadowEnergyChart, this.shadowChannelChart) this.redrawThumbnailChart() + + this.clearCompareLine() + this.$nextTick(() => { this.resetChartOpts() }) @@ -1123,6 +1148,50 @@ export default { // 分析工具Accept时刷新部分数据 handleAccept() { console.log('%c [ 分析工具Accept时刷新部分数据 ]-1046', 'font-size:13px; background:pink; color:#bf2c9f;') + this.clearCompareLine() + }, + + // 显示比较弹窗 + showCompareModal() { + if (this.isLoading) { + this.$message.warn('Sample is Loading') + return + } + this.clearCompareLine() + this.compareFileListModalVisible = true + }, + + // 文件之间对比 + handleCompareWithFile([channelData, energyData]) { + this.channelCompareLine = channelData + this.energyCompareLine = energyData + this.redrawLineBySeriesName('Compare', energyData, channelData, true, channelData.color) + + if (this.option.series[0].type == 'scatterGL') { + lineSeries.type = 'scatterGL' + } + + this.$nextTick(() => { + const chart = this.$refs.chartRef.getChartInstance() + const yAxisMax = chart.getModel().getComponent('yAxis').axis.scale._extent[1] + this.thumbnailOption.yAxis.max = yAxisMax + }) + }, + + // 移除 Compare 线 + clearCompareLine() { + const compareLine = findSeriesByName(this.option.series, 'Compare') + if (compareLine) { + compareLine.data = [] + this.resetThumbnailChartDataMax() + } + this.channelCompareLine = [] + this.energyCompareLine = [] + }, + + // 重置缩略图表y轴最大值 + resetThumbnailChartDataMax() { + this.thumbnailOption.yAxis.max = 'dataMax' }, // 重置图表配置 @@ -1220,11 +1289,17 @@ export default { this.channelScacLine.color = Color_Scac this.energyScacLine.color = Color_Scac + if (this.channelCompareLine) { + this.channelCompareLine.color = Color_Compare + this.energyCompareLine.color = Color_Compare + } + this.changeColorBySeriesName('Spectrum', Color_Spec) this.changePeakLineColor(Color_Peak) this.changeColorBySeriesName('LcLine', Color_Lc) this.changeColorBySeriesName('BaseLine', Color_Base) this.changeColorBySeriesName('ScacLine', Color_Scac) + this.changeColorBySeriesName('Compare', Color_Compare) const thumbnailChartSeries = findSeriesByName(this.thumbnailOption.series, 'Spectrum') thumbnailChartSeries.itemStyle.color = Color_Spec diff --git a/src/views/spectrumAnalysis/index.vue b/src/views/spectrumAnalysis/index.vue index 1c521df..9490742 100644 --- a/src/views/spectrumAnalysis/index.vue +++ b/src/views/spectrumAnalysis/index.vue @@ -643,8 +643,9 @@ export default { }, { type: 'a-menu-item', - title: 'Clean All', - handler: this.handleCleanAll, + title: 'Compare', + show: this.isGamma, + handler: () => this.$refs.gammaAnalysisRef.showCompareModal(), }, { type: 'a-menu-item', @@ -658,6 +659,11 @@ export default { show: this.isGamma, handler: () => (this.ftransltModalVisible = true), }, + { + type: 'a-menu-item', + title: 'Clean All', + handler: this.handleCleanAll, + }, ], }, { From 7d29399802313dbb8ed1e8439f99cd30abd8f781 Mon Sep 17 00:00:00 2001 From: Xu Zhimeng Date: Mon, 25 Sep 2023 16:58:46 +0800 Subject: [PATCH 03/13] =?UTF-8?q?feat:=20Reprocessing=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=EF=BC=8C=E5=8F=8A=E4=B8=89=E4=B8=AACalibration=E4=B8=AD?= =?UTF-8?q?=E7=9A=84Set=20to=20Current=E6=8E=A5=E5=8F=A3=E5=AF=B9=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/CustomModal/index.vue | 6 +- .../components/Modals/AnalyzeSettingModal.vue | 2 +- .../Modals/EfficiencyCalibrationModal.vue | 22 +++- .../Modals/EnergyCalibrationModal.vue | 22 +++- .../Modals/ResolutionCalibrationModal.vue | 22 +++- src/views/spectrumAnalysis/gamma-analysis.vue | 103 ++++++++---------- src/views/spectrumAnalysis/index.vue | 11 +- 7 files changed, 103 insertions(+), 85 deletions(-) diff --git a/src/components/CustomModal/index.vue b/src/components/CustomModal/index.vue index 6927dc4..a463199 100644 --- a/src/components/CustomModal/index.vue +++ b/src/components/CustomModal/index.vue @@ -63,8 +63,10 @@ export default { if (this.okHandler instanceof Function) { try { this.confirmLoading = true - await this.okHandler() - this.visible = false + const success = await this.okHandler() + if(success !== false) { + this.visible = false + } } catch (error) { console.error(error) } finally { diff --git a/src/views/spectrumAnalysis/components/Modals/AnalyzeSettingModal.vue b/src/views/spectrumAnalysis/components/Modals/AnalyzeSettingModal.vue index a855d14..cc39cab 100644 --- a/src/views/spectrumAnalysis/components/Modals/AnalyzeSettingModal.vue +++ b/src/views/spectrumAnalysis/components/Modals/AnalyzeSettingModal.vue @@ -203,7 +203,7 @@ export default { } catch (error) { console.error(error) } finally { - throw new Error('Not Close') + return false } }, }, diff --git a/src/views/spectrumAnalysis/components/Modals/EfficiencyCalibrationModal.vue b/src/views/spectrumAnalysis/components/Modals/EfficiencyCalibrationModal.vue index 614d4bc..8b94e10 100644 --- a/src/views/spectrumAnalysis/components/Modals/EfficiencyCalibrationModal.vue +++ b/src/views/spectrumAnalysis/components/Modals/EfficiencyCalibrationModal.vue @@ -44,7 +44,7 @@ :pagination="false" size="small" :class="list.length ? 'has-data' : ''" - :scroll="{ y: 182 }" + :scroll="{ y: 193 }" :selectedRowKeys.sync="selectedRowKeys" :canDeselect="false" @rowClick="handleRowClick" @@ -116,7 +116,7 @@ import ModalMixin from '@/mixins/ModalMixin' import TitleOverBorder from '../TitleOverBorder.vue' import CustomChart from '@/components/CustomChart/index.vue' -import { getAction, postAction } from '@/api/manage' +import { getAction, postAction, putAction } from '@/api/manage' import { cloneDeep } from 'lodash' import { buildLineSeries } from '@/utils/chartHelper' import SampleDataMixin from '../../SampleDataMixin' @@ -573,8 +573,20 @@ export default { this.getData(item) }, - handleSetToCurrent() { + async handleSetToCurrent() { this.appliedDataSource = this.currSelectedDataSource + try { + const { inputFileName: fileName } = this.sampleData + + const { success, message } = await putAction( + `/gamma/setCurrentEfficiency?fileName=${fileName}¤tName=${this.currSelectedDataSource}` + ) + if (!success) { + this.$message.error(message) + } + } catch (error) { + console.error(error) + } } } } @@ -621,7 +633,7 @@ export default { &.has-data { ::v-deep { .ant-table-body { - height: 182px; + height: 193px; background-color: #06282a; } } @@ -629,7 +641,7 @@ export default { ::v-deep { .ant-table-placeholder { - height: 183px; + height: 194px; display: flex; justify-content: center; align-items: center; diff --git a/src/views/spectrumAnalysis/components/Modals/EnergyCalibrationModal.vue b/src/views/spectrumAnalysis/components/Modals/EnergyCalibrationModal.vue index fd35e5d..0da4f10 100644 --- a/src/views/spectrumAnalysis/components/Modals/EnergyCalibrationModal.vue +++ b/src/views/spectrumAnalysis/components/Modals/EnergyCalibrationModal.vue @@ -44,7 +44,7 @@ :pagination="false" size="small" :class="list.length ? 'has-data' : ''" - :scroll="{ y: 182 }" + :scroll="{ y: 193 }" :selectedRowKeys.sync="selectedRowKeys" :canDeselect="false" @rowClick="handleRowClick" @@ -111,7 +111,7 @@ import ModalMixin from '@/mixins/ModalMixin' import TitleOverBorder from '../TitleOverBorder.vue' import CustomChart from '@/components/CustomChart/index.vue' -import { getAction, postAction } from '@/api/manage' +import { getAction, postAction, putAction } from '@/api/manage' import { cloneDeep } from 'lodash' import { buildLineSeries } from '@/utils/chartHelper' import SampleDataMixin from '../../SampleDataMixin' @@ -532,8 +532,20 @@ export default { this.getData(item) }, - handleSetToCurrent() { + async handleSetToCurrent() { this.appliedDataSource = this.currSelectedDataSource + try { + const { inputFileName: fileName } = this.sampleData + + const { success, message } = await putAction( + `/gamma/setCurrentEnergy?fileName=${fileName}¤tName=${this.currSelectedDataSource}` + ) + if (!success) { + this.$message.error(message) + } + } catch (error) { + console.error(error) + } } } } @@ -580,7 +592,7 @@ export default { &.has-data { ::v-deep { .ant-table-body { - height: 182px; + height: 193px; background-color: #06282a; } } @@ -588,7 +600,7 @@ export default { ::v-deep { .ant-table-placeholder { - height: 183px; + height: 194px; display: flex; justify-content: center; align-items: center; diff --git a/src/views/spectrumAnalysis/components/Modals/ResolutionCalibrationModal.vue b/src/views/spectrumAnalysis/components/Modals/ResolutionCalibrationModal.vue index ca12e79..a092112 100644 --- a/src/views/spectrumAnalysis/components/Modals/ResolutionCalibrationModal.vue +++ b/src/views/spectrumAnalysis/components/Modals/ResolutionCalibrationModal.vue @@ -44,7 +44,7 @@ :pagination="false" size="small" :class="list.length ? 'has-data' : ''" - :scroll="{ y: 182 }" + :scroll="{ y: 193 }" :selectedRowKeys.sync="selectedRowKeys" :canDeselect="false" @rowClick="handleRowClick" @@ -111,7 +111,7 @@ import ModalMixin from '@/mixins/ModalMixin' import TitleOverBorder from '../TitleOverBorder.vue' import CustomChart from '@/components/CustomChart/index.vue' -import { getAction, postAction } from '@/api/manage' +import { getAction, postAction, putAction } from '@/api/manage' import { cloneDeep } from 'lodash' import { buildLineSeries } from '@/utils/chartHelper' import SampleDataMixin from '../../SampleDataMixin' @@ -530,8 +530,20 @@ export default { this.getData(item) }, - handleSetToCurrent() { + async handleSetToCurrent() { this.appliedDataSource = this.currSelectedDataSource + try { + const { inputFileName: fileName } = this.sampleData + + const { success, message } = await putAction( + `/gamma/setCurrentResolution?fileName=${fileName}¤tName=${this.currSelectedDataSource}` + ) + if (!success) { + this.$message.error(message) + } + } catch (error) { + console.error(error) + } } } } @@ -578,7 +590,7 @@ export default { &.has-data { ::v-deep { .ant-table-body { - height: 182px; + height: 193px; background-color: #06282a; } } @@ -586,7 +598,7 @@ export default { ::v-deep { .ant-table-placeholder { - height: 183px; + height: 194px; display: flex; justify-content: center; align-items: center; diff --git a/src/views/spectrumAnalysis/gamma-analysis.vue b/src/views/spectrumAnalysis/gamma-analysis.vue index bce2a30..b2a957c 100644 --- a/src/views/spectrumAnalysis/gamma-analysis.vue +++ b/src/views/spectrumAnalysis/gamma-analysis.vue @@ -90,6 +90,9 @@ /> + + + @@ -101,13 +104,14 @@ import QcFlags from './components/SubOperators/QcFlags.vue' import GraphAssistance from './components/SubOperators/GraphAssistance.vue' import NuclideLibrary from './components/SubOperators/NuclideLibrary.vue' import ButtonWithSwitchIcon from './components/SubOperators/ButtonWithSwitchIcon.vue' -import { getAction } from '@/api/manage' +import { getAction, postAction } from '@/api/manage' import Response from './response.json' import { buildLineSeries, findSeriesByName, getXAxisAndYAxisByPosition, rangeNumber } from '@/utils/chartHelper' import { cloneDeep } from 'lodash' import axios from 'axios' import NuclideReviewModal from './components/Modals/AnalyzeInteractiveToolModal/components/NuclideReviewModal.vue' import CompareFileListModal from './components/Modals/CompareFileListModal.vue' +import ReProcessingModal from './components/Modals/ReProcessingModal/index.vue' // 初始配置 const initialOption = { @@ -273,6 +277,7 @@ export default { ButtonWithSwitchIcon, NuclideReviewModal, CompareFileListModal, + ReProcessingModal, }, data() { return { @@ -308,6 +313,8 @@ export default { currChannel: -1, compareFileListModalVisible: false, // Compare 弹窗 + reprocessingModalVisible: false, // 重新分析弹窗 + isProcessing: false, // 正在处理 } }, created() { @@ -1086,63 +1093,9 @@ export default { // 从分析工具刷新部分数据 handleRefresh(data) { - const { allData, shadowChannelChart, shadowEnergyChart, shapeChannelData, shapeEnergyData } = data - - const channelPeakGroup = allData.filter((item) => item.name == 'Peak' && item.group == 'channel') - const energyPeakGroup = allData.filter((item) => item.name == 'Peak' && item.group == 'energy') - - const channelBaseLine = allData.find((item) => item.name == 'BaseLine' && item.group == 'channel') - const energyBaseLine = allData.find((item) => item.name == 'BaseLine' && item.group == 'energy') - - const channelLcLine = allData.find((item) => item.name == 'Lc' && item.group == 'channel') - const energyLcLine = allData.find((item) => item.name == 'Lc' && item.group == 'energy') - - const channelScacLine = allData.find((item) => item.name == 'Scac' && item.group == 'channel') - const energyScacLine = allData.find((item) => item.name == 'Scac' && item.group == 'energy') - - this.allEnergy = allData.find((item) => item.name == 'Energy' && item.group == 'energy') - this.allChannel = allData.find((item) => item.name == 'Count' && item.group == 'channel') - - // 保存Peak Line - this.channelPeakGroup = channelPeakGroup - this.energyPeakGroup = energyPeakGroup - - // 保存 Spectrum Line - this.shadowChannelChart = shadowChannelChart - this.shadowEnergyChart = shadowEnergyChart - - // 保存基线 - this.channelBaseLine = channelBaseLine - this.energyBaseLine = energyBaseLine - - // 保存Lc - this.channelLcLine = channelLcLine - this.energyLcLine = energyLcLine - - // 保存Scac - this.channelScacLine = channelScacLine - this.energyScacLine = energyScacLine - - // 保存 基线控制点 - this.shapeChannelData = shapeChannelData - this.shapeEnergyData = shapeEnergyData - - this.opts.notMerge = true - this.redrawPeakLine() - this.redrawCtrlPointBySeriesName() - - this.redrawLineBySeriesName('BaseLine', this.energyBaseLine, this.channelBaseLine, this.graphAssistance.Baseline) - this.redrawLineBySeriesName('LcLine', this.energyLcLine, this.channelLcLine, this.graphAssistance.Lc) - this.redrawLineBySeriesName('ScacLine', this.energyScacLine, this.channelScacLine, this.graphAssistance.SCAC) - this.redrawLineBySeriesName('Spectrum', this.shadowEnergyChart, this.shadowChannelChart) - - this.redrawThumbnailChart() - - this.clearCompareLine() - - this.$nextTick(() => { - this.resetChartOpts() - }) + this.reset() + data.DetailedInformation = this.detailedInfomation + this.dataProsess(data) }, // 分析工具Accept时刷新部分数据 @@ -1189,6 +1142,40 @@ export default { this.energyCompareLine = [] }, + // 重新分析 + async reProcessing() { + if (this.isProcessing) { + return + } + + if (this.isLoading) { + this.$message.warn('Sample is Loading') + return + } + + try { + this.isLoading = true + this.reset() + + const { inputFileName: fileName } = this.sample + const { success, result, message } = await postAction(`/gamma/Reprocessing?fileName=${fileName}`) + if (success) { + result.DetailedInformation = this.detailedInfomation + this.dataProsess(result) + } else { + this.isLoading = false + const arr = message.split('\n') + this.$warning({ + title: 'Warning', + content: () => arr.map((text) =>
{text}
), + }) + } + } catch (error) { + console.error(error) + } + // this.reprocessingModalVisible = true + }, + // 重置缩略图表y轴最大值 resetThumbnailChartDataMax() { this.thumbnailOption.yAxis.max = 'dataMax' diff --git a/src/views/spectrumAnalysis/index.vue b/src/views/spectrumAnalysis/index.vue index 9490742..ea7de82 100644 --- a/src/views/spectrumAnalysis/index.vue +++ b/src/views/spectrumAnalysis/index.vue @@ -89,10 +89,6 @@ - - - - @@ -209,7 +205,6 @@ import SaveSettingModal from './components/Modals/SaveSettingModal.vue' import AnalyzeSettingModal from './components/Modals/AnalyzeSettingModal.vue' import AnalyzeInteractiveToolModal from './components/Modals/AnalyzeInteractiveToolModal/index.vue' import KorsumModal from './components/Modals/KorsumModal.vue' -import ReProcessingModal from './components/Modals/ReProcessingModal/index.vue' import ZeroTimeModal from './components/Modals/ZeroTimeModal.vue' import EfficiencyCalibrationModal from './components/Modals/EfficiencyCalibrationModal.vue' import EnergyCalibrationModal from './components/Modals/EnergyCalibrationModal.vue' @@ -256,7 +251,6 @@ export default { AnalyzeSettingModal, AnalyzeInteractiveToolModal, KorsumModal, - ReProcessingModal, ZeroTimeModal, EfficiencyCalibrationModal, EnergyCalibrationModal, @@ -314,7 +308,6 @@ export default { saveSettingModalVisible: false, // 保存设置弹窗 analyzeConfigureModalVisible: false, // 分析设置弹窗 - reprocessingModalVisible: false, // 重新分析弹窗 analyzeInteractiveToolModalVisible: false, // 分析工具弹窗 zeroTimeModalVisible: false, // Zero Time 弹窗 korsumModalShow: false, // Korsum 弹窗 @@ -762,9 +755,9 @@ export default { }, { type: 'a-menu-item', - title: 'ReProcessing', + title: 'Reprocessing', show: this.isGamma, - handler: () => (this.reprocessingModalVisible = true), + handler: () => this.$refs.gammaAnalysisRef.reProcessing(), }, { type: 'a-menu-item', From c81923e744834f20da0788abaaa92632f3ff5e29 Mon Sep 17 00:00:00 2001 From: Xu Zhimeng Date: Mon, 25 Sep 2023 19:42:31 +0800 Subject: [PATCH 04/13] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=EF=BC=8C=E8=A7=A3=E5=86=B3scatterGL=E4=B8=8D=E5=8F=97?= =?UTF-8?q?=E8=BD=B4=E7=BA=BF=E6=9C=80=E5=A4=A7/=E6=9C=80=E5=B0=8F?= =?UTF-8?q?=E5=80=BC=E6=8E=A7=E5=88=B6=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/utils/chartHelper.js | 10 + src/views/spectrumAnalysis/gamma-analysis.vue | 187 ++++++++++++++---- 2 files changed, 154 insertions(+), 43 deletions(-) diff --git a/src/utils/chartHelper.js b/src/utils/chartHelper.js index 6560aae..e6cb5f0 100644 --- a/src/utils/chartHelper.js +++ b/src/utils/chartHelper.js @@ -104,4 +104,14 @@ export function rangeNumber(min, max) { return num => { return num > max ? max : num < min ? min : num } +} + +/** + * 获取图表某条轴线的最大值 + * @param {import("echarts").ECharts} chartInstance + * @param {'xAxis' | 'yAxis'} axis + * @returns + */ +export function getAxisMax(chartInstance, axis) { + return chartInstance.getModel().getComponent(axis).axis.scale._extent[1] } \ No newline at end of file diff --git a/src/views/spectrumAnalysis/gamma-analysis.vue b/src/views/spectrumAnalysis/gamma-analysis.vue index b2a957c..dd7374b 100644 --- a/src/views/spectrumAnalysis/gamma-analysis.vue +++ b/src/views/spectrumAnalysis/gamma-analysis.vue @@ -106,7 +106,13 @@ import NuclideLibrary from './components/SubOperators/NuclideLibrary.vue' import ButtonWithSwitchIcon from './components/SubOperators/ButtonWithSwitchIcon.vue' import { getAction, postAction } from '@/api/manage' import Response from './response.json' -import { buildLineSeries, findSeriesByName, getXAxisAndYAxisByPosition, rangeNumber } from '@/utils/chartHelper' +import { + buildLineSeries, + findSeriesByName, + getAxisMax, + getXAxisAndYAxisByPosition, + rangeNumber, +} from '@/utils/chartHelper' import { cloneDeep } from 'lodash' import axios from 'axios' import NuclideReviewModal from './components/Modals/AnalyzeInteractiveToolModal/components/NuclideReviewModal.vue' @@ -256,6 +262,7 @@ const thumbnailOption = { const graphAssistance = { axisType: 'Channel', + spectrumType: 'Lines', Baseline: true, SCAC: true, Lc: true, @@ -462,6 +469,7 @@ export default { shadowChannelChart.pointlist && shadowChannelChart.pointlist.map(({ x, y }) => [x, y]), shadowChannelChart.color, { + symbolSize: 2, markLine: { silent: true, symbol: 'none', @@ -576,6 +584,7 @@ export default { }) series.push(...peakLines) + // 推入Compare Line series.push( buildLineSeries('Compare', [], '#fff', { symbolSize: 2, @@ -606,6 +615,8 @@ export default { // Graph Assistance 操作 handleGraphAssistanceChange({ type, label, value }) { + const spectrumLineSeries = findSeriesByName(this.option.series, 'Spectrum') + const thumbnailSpectrumLineSeries = findSeriesByName(this.thumbnailOption.series, 'Spectrum') const compareLineSeries = findSeriesByName(this.option.series, 'Compare') // 类型变化 @@ -651,24 +662,35 @@ export default { this.redrawLineBySeriesName('Compare', this.energyCompareLine, this.channelCompareLine) break case 'Lines': - this.option.series[0].type = 'line' - this.option.series[0].symbol = 'none' + this.graphAssistance.spectrumType = 'Lines' - this.thumbnailOption.series[0].type = 'line' - this.thumbnailOption.series[0].symbol = 'none' + spectrumLineSeries.type = 'line' + spectrumLineSeries.symbol = 'none' + + thumbnailSpectrumLineSeries.type = 'line' + thumbnailSpectrumLineSeries.symbol = 'none' compareLineSeries.type = 'line' compareLineSeries.symbol = 'none' + + this.redrawLineBySeriesName('Spectrum', this.shadowEnergyChart, this.shadowChannelChart) + this.redrawLineBySeriesName('Compare', this.energyCompareLine, this.channelCompareLine) break case 'Scatter': - this.option.series[0].type = 'scatterGL' - this.option.series[0].symbol = 'circle' + this.graphAssistance.spectrumType = 'Scatter' - this.thumbnailOption.series[0].type = 'scatterGL' - this.thumbnailOption.series[0].symbol = 'circle' + spectrumLineSeries.type = 'scatterGL' + spectrumLineSeries.symbol = 'circle' + + thumbnailSpectrumLineSeries.type = 'scatterGL' + thumbnailSpectrumLineSeries.symbol = 'circle' compareLineSeries.type = 'scatterGL' compareLineSeries.symbol = 'circle' + + this.$nextTick(() => { + this.rangeScatter() + }) break } } @@ -680,9 +702,9 @@ export default { case 'Cursor': // 显示红色竖线 if (value) { - this.option.series[0].markLine.lineStyle.width = 2 + spectrumLineSeries.markLine.lineStyle.width = 2 } else { - this.option.series[0].markLine.lineStyle.width = 0 + spectrumLineSeries.markLine.lineStyle.width = 0 } break case 'Baseline': @@ -758,7 +780,7 @@ export default { // 重绘右上角的缩略图 redrawThumbnailChart() { - const series = this.thumbnailOption.series[0] + const series = findSeriesByName(this.thumbnailOption.series, 'Spectrum') const data = this.isEnergy() ? this.shadowEnergyChart : this.shadowChannelChart series.data = data.pointlist.map(({ x, y }) => [x, y]) }, @@ -766,10 +788,11 @@ export default { // 点击图表,设置红线 handleChartClick(param) { const { offsetX, offsetY } = param - const point = getXAxisAndYAxisByPosition(this.$refs.chartRef.getChartInstance(), offsetX, offsetY) + const point = getXAxisAndYAxisByPosition(this.getChart(), offsetX, offsetY) if (point) { const xAxis = point[0] - this.option.series[0].markLine.data[0].xAxis = xAxis + const spectrumLineSeries = findSeriesByName(this.option.series, 'Spectrum') + spectrumLineSeries.markLine.data[0].xAxis = xAxis const channel = this.isEnergy() ? this.getChannelByEnergy(xAxis) : parseInt(xAxis.toFixed()) const energy = this.isEnergy() @@ -834,7 +857,8 @@ export default { // 触发Peak Infomation handleTogglePeak() { - const xAxis = this.option.series[0].markLine.data[0].xAxis + const spectrumLineSeries = findSeriesByName(this.option.series, 'Spectrum') + const xAxis = spectrumLineSeries.markLine.data[0].xAxis const channel = this.isEnergy() ? this.getChannelByEnergy(xAxis) : parseInt(xAxis.toFixed()) const index = this.channelPeakGroup.findIndex((peakItem) => { const allX = peakItem.pointlist.map((item) => item.x) @@ -864,9 +888,7 @@ export default { return prev && prev.y > curr.y ? prev : curr }) - const chart = this.$refs.chartRef.getChartInstance() - - const [xPix, yPix] = chart.convertToPixel({ seriesIndex: 0 }, [x, y]) + const [xPix, yPix] = this.getChart().convertToPixel({ seriesIndex: 0 }, [x, y]) this.peakInfomationTooltip.content = html this.peakInfomationTooltip.visible = true this.peakInfomationTooltip.left = xPix @@ -889,7 +911,8 @@ export default { * @param { 'left'| 'right' } direction */ moveMarkLine(direction) { - const prevAxis = this.option.series[0].markLine.data[0].xAxis + const spectrumLineSeries = findSeriesByName(this.option.series, 'Spectrum') + const prevAxis = spectrumLineSeries.markLine.data[0].xAxis // 获取每一段 Channel 中的最大值 const maxXAxises = this.channelPeakGroup.map((item) => { @@ -903,13 +926,13 @@ export default { // 找到第一个比prevAxis大的xAxis find = maxXAxises.find((xAxis) => xAxis > prevAxis) if (find) { - this.option.series[0].markLine.data[0].xAxis = find + spectrumLineSeries.markLine.data[0].xAxis = find } } else if (direction == 'left') { // 找到第一个比prevAxis小的xAxis find = maxXAxises.reverse().find((xAxis) => xAxis < prevAxis) if (find) { - this.option.series[0].markLine.data[0].xAxis = find + spectrumLineSeries.markLine.data[0].xAxis = find } } @@ -920,8 +943,7 @@ export default { // 鼠标按下时开启可刷选状态 handleMouseDown() { - const chart = this.$refs.chartRef.getChartInstance() - chart.dispatchAction({ + this.getChart().dispatchAction({ type: 'takeGlobalCursor', // 如果想变为“可刷选状态”,必须设置。不设置则会关闭“可刷选状态”。 key: 'brush', @@ -934,8 +956,7 @@ export default { handleMouseUp() { setTimeout(() => { - const chart = this.$refs.chartRef.getChartInstance() - this.clearBrush(chart) + this.clearBrush(this.getChart()) }, 0) }, @@ -965,7 +986,7 @@ export default { const point1 = chart.convertFromPixel({ seriesIndex: 0 }, [minX, minY]).map((num) => parseInt(num.toFixed())) const point2 = chart.convertFromPixel({ seriesIndex: 0 }, [maxX, maxY]).map((num) => parseInt(num.toFixed())) - const xAxisMax = chart.getModel().getComponent('xAxis').axis.scale._extent[1] + const xAxisMax = getAxisMax(chart, 'xAxis') const yAxisMax = this.option.yAxis.max let [x1, y2, x2, y1] = [...point1, ...point2] // 根据解析出的数据确定真实的范围 @@ -992,7 +1013,7 @@ export default { this.setThumbnailChartRect(x1, y2, x2, y1) } - const thumbnailChart = this.$refs.thumbnailChartRef.getChartInstance() + const thumbnailChart = this.getThumbnailChart() const [, maxYPixel] = thumbnailChart.convertToPixel({ seriesIndex: 0 }, [0, y1]) // 方框的上下两条边的yAxis转为pix const [, minYPixel] = thumbnailChart.convertToPixel({ seriesIndex: 0 }, [0, y2]) const rectHeightPixel = maxYPixel - minYPixel // 计算方框的左右边长(pix) @@ -1000,13 +1021,72 @@ export default { } this.clearBrush(chart) + + this.$nextTick(() => { + this.rangeScatter() + }) + }, + + /** + * 因scatterGL 不受axis中max和min的控制,手动处理溢出部分 + * @param {*} x1 xAxis min + * @param {*} x2 xAxis max + * @param {*} y1 yAxis min + * @param {*} y2 yAxis max + */ + rangeScatter() { + if (!this.isScatter()) { + return + } + + const { + xAxis: { min: x1 }, + yAxis: { min: y1 }, + } = this.option + + const chart = this.getChart() + const x2 = getAxisMax(chart, 'xAxis') + const y2 = getAxisMax(chart, 'yAxis') + + const channelSpectrumData = { + ...this.shadowChannelChart, + pointlist: this.pointlistLimit(this.shadowChannelChart.pointlist, x1, x2, y1, y2), + } + const energySpectrumData = { + ...this.shadowEnergyChart, + pointlist: this.pointlistLimit(this.shadowEnergyChart.pointlist, x1, x2, y1, y2), + } + this.redrawLineBySeriesName('Spectrum', energySpectrumData, channelSpectrumData) + + const channelCompareLine = { + ...this.channelCompareLine, + pointlist: this.pointlistLimit(this.channelCompareLine.pointlist, x1, x2, y1, y2), + } + const energyCompareLine = { + ...this.energyCompareLine, + pointlist: this.pointlistLimit(this.energyCompareLine.pointlist, x1, x2, y1, y2), + } + this.redrawLineBySeriesName('Compare', energyCompareLine, channelCompareLine) + }, + + /** + * 筛选范围内的点 + * @param {*} pointlist + * @param {*} x1 + * @param {*} x2 + * @param {*} y1 + * @param {*} y2 + */ + pointlistLimit(pointlist, x1, x2, y1, y2) { + return pointlist.filter(({ x, y }) => x >= x1 && x <= x2 && y >= y1 && y <= y2) }, // 在右上角缩略图中设置范围 setThumbnailChartRect(x1, y2, x2, y1) { this.thumbnailChartRect = [x1, y2, x2, y1] - const { markLine } = this.thumbnailOption.series[0] + const thumbnailSpectrumLineSeries = findSeriesByName(this.thumbnailOption.series, 'Spectrum') + const { markLine } = thumbnailSpectrumLineSeries const pointList = [ [ [x1, y1], @@ -1034,7 +1114,7 @@ export default { // 缩略图点击 handleThumbnailChartClick(param) { const { offsetX, offsetY } = param - const thumbnailChart = this.$refs.thumbnailChartRef.getChartInstance() + const thumbnailChart = this.getThumbnailChart() const point = getXAxisAndYAxisByPosition(thumbnailChart, offsetX, offsetY) if (point && this.thumbnailChartRect && this.thumbnailChartRect.length) { @@ -1046,7 +1126,7 @@ export default { let [xAxis, yAxis] = point - const xAxisMax = thumbnailChart.getModel().getComponent('xAxis').axis.scale._extent[1] + const xAxisMax = getAxisMax(thumbnailChart, 'xAxis') const xAxisLimit = rangeNumber(1 + halfWidth, xAxisMax - halfWidth) @@ -1081,14 +1161,22 @@ export default { // 重置 handleReset() { - this.option.xAxis.min = 1 - this.option.xAxis.max = 'dataMax' - this.option.yAxis.min = 1 - this.option.yAxis.max = 'dataMax' + const spectrumLineMaxX = Math.max(...this.shadowChannelChart.pointlist.map(({ x }) => x)) + const spectrumLineMaxY = Math.max(...this.shadowChannelChart.pointlist.map(({ y }) => y)) - this.thumbnailOption.series[0].markLine.data = [] + this.option.xAxis.min = 1 + this.option.xAxis.max = spectrumLineMaxX + this.option.yAxis.min = 1 + this.option.yAxis.max = spectrumLineMaxY + + const thumbnailSpectrumLineSeries = findSeriesByName(this.thumbnailOption.series, 'Spectrum') + thumbnailSpectrumLineSeries.markLine.data = [] this.thumbnailChartRect = [] this.closePeakInfomationTooltip() + + this.$nextTick(() => { + this.rangeScatter() + }) }, // 从分析工具刷新部分数据 @@ -1120,13 +1208,12 @@ export default { this.energyCompareLine = energyData this.redrawLineBySeriesName('Compare', energyData, channelData, true, channelData.color) - if (this.option.series[0].type == 'scatterGL') { + if (this.isScatter()) { lineSeries.type = 'scatterGL' } this.$nextTick(() => { - const chart = this.$refs.chartRef.getChartInstance() - const yAxisMax = chart.getModel().getComponent('yAxis').axis.scale._extent[1] + const yAxisMax = getAxisMax(this.getChart(), 'yAxis') this.thumbnailOption.yAxis.max = yAxisMax }) }, @@ -1231,14 +1318,16 @@ export default { this.option.yAxis.type = 'value' if (this.option.series.length) { - this.option.series[0].type = 'line' - this.option.series[0].symbol = 'none' - this.option.series[0].markLine.lineStyle.width = 2 + const spectrumLineSeries = findSeriesByName(this.option.series, 'Spectrum') + spectrumLineSeries.type = 'line' + spectrumLineSeries.symbol = 'none' + spectrumLineSeries.markLine.lineStyle.width = 2 } if (this.thumbnailOption.series.length) { - this.thumbnailOption.series[0].type = 'line' - this.thumbnailOption.series[0].symbol = 'none' + const thumbnailSpectrumLineSeries = findSeriesByName(this.thumbnailOption.series, 'Spectrum') + thumbnailSpectrumLineSeries.type = 'line' + thumbnailSpectrumLineSeries.symbol = 'none' } this.graphAssistance = cloneDeep(graphAssistance) }, @@ -1310,6 +1399,18 @@ export default { isEnergy() { return this.graphAssistance.axisType == 'Energy' }, + + isScatter() { + return this.graphAssistance.spectrumType == 'Scatter' + }, + + getChart() { + return this.$refs.chartRef.getChartInstance() + }, + + getThumbnailChart() { + return this.$refs.thumbnailChartRef.getChartInstance() + }, }, watch: { sample: { From 90017662ed81aef11e368f3c0c84540fdd17535c Mon Sep 17 00:00:00 2001 From: Xu Zhimeng Date: Tue, 26 Sep 2023 14:39:44 +0800 Subject: [PATCH 05/13] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3scatterGL?= =?UTF-8?q?=E5=9C=A8=E5=90=84=E7=A7=8D=E6=83=85=E5=86=B5=E4=B8=8B=E5=8F=96?= =?UTF-8?q?=E5=80=BC=E5=AF=BC=E8=87=B4=E7=9A=84=E6=B8=B2=E6=9F=93=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/spectrumAnalysis/gamma-analysis.vue | 124 +++++++++++------- 1 file changed, 76 insertions(+), 48 deletions(-) diff --git a/src/views/spectrumAnalysis/gamma-analysis.vue b/src/views/spectrumAnalysis/gamma-analysis.vue index dd7374b..90d01f4 100644 --- a/src/views/spectrumAnalysis/gamma-analysis.vue +++ b/src/views/spectrumAnalysis/gamma-analysis.vue @@ -17,7 +17,7 @@ v-if="!isLoading" slot="content" @change="handleGraphAssistanceChange" - @reset="handleReset" + @reset="handleResetChart" /> { - this.clearBrush(this.getChart()) + if (this.timer) { + window.clearTimeout(this.timer) + } + this.timer = setTimeout(() => { + this.clearBrush() }, 0) }, - clearBrush(chart) { + clearBrush() { + const chart = this.getChart() // 清理刷选的范围 chart.dispatchAction({ type: 'brush', @@ -970,6 +978,7 @@ export default { // 改为不可刷选状态 chart.dispatchAction({ type: 'takeGlobalCursor', + brushOption: false }) }, @@ -986,13 +995,18 @@ export default { const point1 = chart.convertFromPixel({ seriesIndex: 0 }, [minX, minY]).map((num) => parseInt(num.toFixed())) const point2 = chart.convertFromPixel({ seriesIndex: 0 }, [maxX, maxY]).map((num) => parseInt(num.toFixed())) + // 拿到之前的最大值 const xAxisMax = getAxisMax(chart, 'xAxis') - const yAxisMax = this.option.yAxis.max + const yAxisMax = getAxisMax(chart, 'yAxis') + + // 拿到之前的最小值 + const xAxisMin = this.option.xAxis.min + const yAxisMin = this.option.yAxis.min let [x1, y2, x2, y1] = [...point1, ...point2] // 根据解析出的数据确定真实的范围 - const xAxisLimit = rangeNumber(1, xAxisMax) - const yAxisLimit = rangeNumber(1, yAxisMax) + const xAxisLimit = rangeNumber(xAxisMin, xAxisMax) + const yAxisLimit = rangeNumber(yAxisMin, yAxisMax) x1 = xAxisLimit(x1) x2 = xAxisLimit(x2) @@ -1020,8 +1034,6 @@ export default { this.halfHeightPixel = rectHeightPixel / 2 } - this.clearBrush(chart) - this.$nextTick(() => { this.rangeScatter() }) @@ -1029,12 +1041,9 @@ export default { /** * 因scatterGL 不受axis中max和min的控制,手动处理溢出部分 - * @param {*} x1 xAxis min - * @param {*} x2 xAxis max - * @param {*} y1 yAxis min - * @param {*} y2 yAxis max + * @param {Boolean} isReset 是否重置到初始状态 */ - rangeScatter() { + rangeScatter(isReset) { if (!this.isScatter()) { return } @@ -1050,23 +1059,33 @@ export default { const channelSpectrumData = { ...this.shadowChannelChart, - pointlist: this.pointlistLimit(this.shadowChannelChart.pointlist, x1, x2, y1, y2), + pointlist: isReset + ? this.pointlistLimitY(this.shadowChannelChart.pointlist) + : this.pointlistLimit(this.shadowChannelChart.pointlist, x1, x2, y1, y2), } const energySpectrumData = { ...this.shadowEnergyChart, - pointlist: this.pointlistLimit(this.shadowEnergyChart.pointlist, x1, x2, y1, y2), + pointlist: isReset + ? this.pointlistLimitY(this.shadowEnergyChart.pointlist) + : this.pointlistLimit(this.shadowEnergyChart.pointlist, x1, x2, y1, y2), } this.redrawLineBySeriesName('Spectrum', energySpectrumData, channelSpectrumData) - const channelCompareLine = { - ...this.channelCompareLine, - pointlist: this.pointlistLimit(this.channelCompareLine.pointlist, x1, x2, y1, y2), + if (this.channelCompareLine) { + const channelCompareLine = { + ...this.channelCompareLine, + pointlist: isReset + ? this.pointlistLimitY(this.channelCompareLine.pointlist) + : this.pointlistLimit(this.channelCompareLine.pointlist, x1, x2, y1, y2), + } + const energyCompareLine = { + ...this.energyCompareLine, + pointlist: isReset + ? this.pointlistLimitY(this.energyCompareLine.pointlist) + : this.pointlistLimit(this.energyCompareLine.pointlist, x1, x2, y1, y2), + } + this.redrawLineBySeriesName('Compare', energyCompareLine, channelCompareLine) } - const energyCompareLine = { - ...this.energyCompareLine, - pointlist: this.pointlistLimit(this.energyCompareLine.pointlist, x1, x2, y1, y2), - } - this.redrawLineBySeriesName('Compare', energyCompareLine, channelCompareLine) }, /** @@ -1081,6 +1100,10 @@ export default { return pointlist.filter(({ x, y }) => x >= x1 && x <= x2 && y >= y1 && y <= y2) }, + pointlistLimitY(pointlist) { + return pointlist.filter(({ y }) => y >= 1) + }, + // 在右上角缩略图中设置范围 setThumbnailChartRect(x1, y2, x2, y1) { this.thumbnailChartRect = [x1, y2, x2, y1] @@ -1121,7 +1144,11 @@ export default { const [x1, y2, x2, y1] = this.thumbnailChartRect const halfWidth = Math.ceil((x2 - x1) / 2) - const [, maxYAxisPixel] = thumbnailChart.convertToPixel({ seriesIndex: 0 }, [0, this.thumbnailOption.yAxis.max]) // 缩略图最大值转为pix + // 缩略图最大值转为pix + const [, maxYAxisPixel] = thumbnailChart.convertToPixel({ seriesIndex: 0 }, [ + 0, + getAxisMax(thumbnailChart, 'yAxis'), + ]) const [, minYAxisPixel] = thumbnailChart.convertToPixel({ seriesIndex: 0 }, [0, 1]) let [xAxis, yAxis] = point @@ -1156,18 +1183,19 @@ export default { this.option.yAxis.min = minYAxis this.option.yAxis.max = maxYAxis + + this.$nextTick(() => { + this.rangeScatter() + }) } }, // 重置 - handleReset() { - const spectrumLineMaxX = Math.max(...this.shadowChannelChart.pointlist.map(({ x }) => x)) - const spectrumLineMaxY = Math.max(...this.shadowChannelChart.pointlist.map(({ y }) => y)) - + handleResetChart() { this.option.xAxis.min = 1 - this.option.xAxis.max = spectrumLineMaxX + this.option.xAxis.max = 'dataMax' this.option.yAxis.min = 1 - this.option.yAxis.max = spectrumLineMaxY + this.option.yAxis.max = 'dataMax' const thumbnailSpectrumLineSeries = findSeriesByName(this.thumbnailOption.series, 'Spectrum') thumbnailSpectrumLineSeries.markLine.data = [] @@ -1175,13 +1203,13 @@ export default { this.closePeakInfomationTooltip() this.$nextTick(() => { - this.rangeScatter() + this.rangeScatter(true) }) }, // 从分析工具刷新部分数据 handleRefresh(data) { - this.reset() + this.handleResetState() data.DetailedInformation = this.detailedInfomation this.dataProsess(data) }, @@ -1198,6 +1226,7 @@ export default { this.$message.warn('Sample is Loading') return } + this.handleResetChart() this.clearCompareLine() this.compareFileListModalVisible = true }, @@ -1213,8 +1242,7 @@ export default { } this.$nextTick(() => { - const yAxisMax = getAxisMax(this.getChart(), 'yAxis') - this.thumbnailOption.yAxis.max = yAxisMax + this.thumbnailOption.yAxis.max = getAxisMax(this.getChart(), 'yAxis') }) }, @@ -1225,8 +1253,8 @@ export default { compareLine.data = [] this.resetThumbnailChartDataMax() } - this.channelCompareLine = [] - this.energyCompareLine = [] + this.channelCompareLine = undefined + this.energyCompareLine = undefined }, // 重新分析 @@ -1242,7 +1270,7 @@ export default { try { this.isLoading = true - this.reset() + this.handleResetState() const { inputFileName: fileName } = this.sample const { success, result, message } = await postAction(`/gamma/Reprocessing?fileName=${fileName}`) @@ -1308,7 +1336,7 @@ export default { }, // 重置页面信息 - reset() { + handleResetState() { this.selectedChannel = -1 this.nuclideLibraryList = [] this.closePeakInfomationTooltip() From 2ffa1abbce03a093af92ca270e2322d05e5ddf80 Mon Sep 17 00:00:00 2001 From: Xu Zhimeng Date: Tue, 26 Sep 2023 14:40:08 +0800 Subject: [PATCH 06/13] =?UTF-8?q?feat:=20=E5=AF=B9=E6=8E=A5Comments=20->?= =?UTF-8?q?=20Add?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Modals/SpectrumCommentsModal.vue | 45 +++++++++++++++---- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/src/views/spectrumAnalysis/components/Modals/SpectrumCommentsModal.vue b/src/views/spectrumAnalysis/components/Modals/SpectrumCommentsModal.vue index ebcc89f..a75a422 100644 --- a/src/views/spectrumAnalysis/components/Modals/SpectrumCommentsModal.vue +++ b/src/views/spectrumAnalysis/components/Modals/SpectrumCommentsModal.vue @@ -7,7 +7,7 @@ From 164e98dad2f7e810bf75bf32a1b6f2d043d09c31 Mon Sep 17 00:00:00 2001 From: Xu Zhimeng Date: Tue, 26 Sep 2023 15:41:42 +0800 Subject: [PATCH 07/13] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E5=9B=BE?= =?UTF-8?q?=E8=A1=A8=E9=AB=98=E5=BA=A6=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/CustomChart/index.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/CustomChart/index.vue b/src/components/CustomChart/index.vue index bc36294..c38f28c 100644 --- a/src/components/CustomChart/index.vue +++ b/src/components/CustomChart/index.vue @@ -19,7 +19,7 @@ export default { }, height: { type: Number, - default: 0 + default: null } }, data() { @@ -83,6 +83,6 @@ export default { From ad2a550668913caa43a1f37f4d1621f598d12c83 Mon Sep 17 00:00:00 2001 From: Xu Zhimeng Date: Tue, 26 Sep 2023 15:42:49 +0800 Subject: [PATCH 08/13] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3Beta=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=20scatterGL=20=E5=9C=A8=E8=B6=85=E5=87=BA=E8=BD=B4?= =?UTF-8?q?=E7=BA=BF=E6=9C=80=E5=A4=A7=E6=9C=80=E5=B0=8F=E5=80=BC=E8=8C=83?= =?UTF-8?q?=E5=9B=B4=E6=97=B6=E4=BE=9D=E6=97=A7=E6=B8=B2=E6=9F=93=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/BetaGammaSpectrumChart.vue | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/views/spectrumAnalysis/components/BetaGammaSpectrumChart.vue b/src/views/spectrumAnalysis/components/BetaGammaSpectrumChart.vue index d00bc10..3dc5eff 100644 --- a/src/views/spectrumAnalysis/components/BetaGammaSpectrumChart.vue +++ b/src/views/spectrumAnalysis/components/BetaGammaSpectrumChart.vue @@ -358,6 +358,8 @@ export default { this.emitRangeChange([0, 256, 0, 256]) this.reDrawRect() + + this.rangeScatter() }, // 点击ROI @@ -409,7 +411,8 @@ export default { // 改为不可刷选状态 chart.dispatchAction({ - type: 'takeGlobalCursor' + type: 'takeGlobalCursor', + rushOption: false }) }, @@ -436,11 +439,29 @@ export default { this.emitRangeChange([x1, x2, y1, y2]) this.reDrawRect() + + this.rangeScatter() } this.clearBrush(chart) }, + /** + * 因scatterGL 不受axis中max和min的控制,手动处理溢出部分 + */ + rangeScatter() { + const { + xAxis: { min: minX, max: maxX }, + yAxis: { min: minY, max: maxY } + } = this.twoDOption + + const data = this.histogramDataList + .filter(({ b, g, c }) => c && b >= minX && b <= maxX && g >= minY && g <= maxY) + .map(({ b, g, c }) => [b, g, c]) + + this.twoDOption.series.data = data + }, + // 通知上层范围改变 emitRangeChange(range) { this.$emit('rangeChange', range) @@ -462,6 +483,7 @@ export default { } this.reDrawRect() + this.rangeScatter() }, // 重绘矩形框区域 @@ -705,6 +727,7 @@ export default { handler(newVal) { this.active = 0 this.twoDOption.series.data = newVal.filter(item => item.c).map(item => [item.b, item.g, item.c]) // 设置2D Scatter数据 + this.rangeScatter() }, immediate: true }, From bdaf65ca99a66b0bb2a77ea6567600ae2a6f1650 Mon Sep 17 00:00:00 2001 From: Xu Zhimeng Date: Wed, 27 Sep 2023 13:41:51 +0800 Subject: [PATCH 09/13] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96gamma=E4=B8=BB?= =?UTF-8?q?=E5=9B=BE=E8=A1=A8=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/chartHelper.js | 1 + src/views/spectrumAnalysis/gamma-analysis.vue | 552 +++++++----------- src/views/spectrumAnalysis/index.vue | 2 +- src/views/spectrumAnalysis/settings.js | 167 ++++++ 4 files changed, 391 insertions(+), 331 deletions(-) create mode 100644 src/views/spectrumAnalysis/settings.js diff --git a/src/utils/chartHelper.js b/src/utils/chartHelper.js index e6cb5f0..ab1bc3e 100644 --- a/src/utils/chartHelper.js +++ b/src/utils/chartHelper.js @@ -99,6 +99,7 @@ export function findSeriesByName(series, seriesName) { * 限定数字在一定范围 * @param {Number} min * @param {Number} max + * @returns {(num: number) => number } */ export function rangeNumber(min, max) { return num => { diff --git a/src/views/spectrumAnalysis/gamma-analysis.vue b/src/views/spectrumAnalysis/gamma-analysis.vue index 90d01f4..6e36352 100644 --- a/src/views/spectrumAnalysis/gamma-analysis.vue +++ b/src/views/spectrumAnalysis/gamma-analysis.vue @@ -119,154 +119,7 @@ import NuclideReviewModal from './components/Modals/AnalyzeInteractiveToolModal/ import CompareFileListModal from './components/Modals/CompareFileListModal.vue' import ReProcessingModal from './components/Modals/ReProcessingModal/index.vue' -// 初始配置 -const initialOption = { - grid: { - top: 40, - left: 60, - right: 50, - containLabel: true, - }, - title: { - text: '', - left: 'center', - bottom: 10, - textStyle: { - color: '#8FD4F8', - rich: { - a: { - padding: [0, 20, 0, 0], - fontSize: 16, - }, - }, - }, - }, - tooltip: { - trigger: 'axis', - axisPointer: { - lineStyle: { - color: '#3CAEBB', - width: 1, - type: 'solid', - }, - }, - formatter: undefined, - className: 'figure-chart-option-tooltip', - }, - xAxis: { - name: 'Channel', - nameTextStyle: { - color: '#8FD4F8', - fontSize: 16, - align: 'right', - verticalAlign: 'top', - padding: [30, 0, 0, 0], - }, - axisLine: { - lineStyle: { - color: '#ade6ee', - }, - }, - splitLine: { - show: false, - }, - axisLabel: { - textStyle: { - color: '#ade6ee', - }, - }, - min: 1, - max: 'dataMax', - animation: false, - axisLabel: { - formatter: (value) => { - return parseInt(value) - }, - }, - }, - yAxis: { - name: 'Counts', - type: 'value', - nameTextStyle: { - color: '#8FD4F8', - fontSize: 16, - }, - axisLine: { - show: true, - lineStyle: { - color: '#ade6ee', - }, - }, - splitLine: { - show: true, - lineStyle: { - color: 'rgba(173, 230, 238, .2)', - }, - }, - axisLabel: { - textStyle: { - color: '#ade6ee', - }, - }, - min: 1, - max: 'dataMax', - animation: false, - axisLabel: { - formatter: (value) => { - return value.toFixed(1) - }, - }, - }, - series: [], - brush: {}, -} - -// 缩略图配置 -const thumbnailOption = { - grid: { - top: 0, - left: 5, - right: 5, - bottom: 0, - }, - xAxis: { - type: 'category', - axisLine: { - show: false, - }, - splitLine: { - show: false, - }, - axisLabel: { - show: false, - }, - min: 1, - max: 'dataMax', - }, - yAxis: { - type: 'value', - axisLine: { - show: false, - }, - splitLine: { - show: false, - }, - axisLabel: { - show: false, - }, - min: 1, - max: 'dataMax', - }, - series: [], -} - -const graphAssistance = { - axisType: 'Channel', - spectrumType: 'Lines', - Baseline: true, - SCAC: true, - Lc: true, -} +import { GammaOptions, graphAssistance } from './settings' export default { props: { @@ -290,19 +143,35 @@ export default { return { isLoading: false, isLoadingNuclide: false, - option: cloneDeep(initialOption), + option: cloneDeep(GammaOptions.option), opts: { notMerge: false, }, - thumbnailOption: cloneDeep(thumbnailOption), + thumbnailOption: cloneDeep(GammaOptions.thumbnailOption), detailedInfomation: [], qcFlags: [], graphAssistance: cloneDeep(graphAssistance), nuclideLibraryVisible: false, - channelPeakGroup: [], - energyPeakGroup: [], + channelData: { + peakGroup: [], + spectrumLine: null, + baseLine: null, + lcLine: null, + scacLine: null, + all: null, + baseLineCP: [], + }, + energyData: { + peakGroup: [], + spectrumLine: null, + baseLine: null, + lcLine: null, + scacLine: null, + all: null, + baseLineCP: [], + }, nuclideLibraryList: [], // 当前鼠标点击选中的channel peakInfomationTooltip: { @@ -326,6 +195,8 @@ export default { }, created() { this.option.title.text = '{a|Channel:0} {a|Energy:0} {a|Counts:0} {a|Detectability:0}' + this.option.tooltip.formatter = this.tooltipFormatter + this.$bus.$on('colorChange', this.handleColorChange) this.$bus.$on('gammaRefresh', this.handleRefresh) this.$bus.$on('accept', this.handleAccept) @@ -339,6 +210,7 @@ export default { this.option.brush = { toolbox: [] } }, methods: { + // 获取样品详情 async getSampleDetail() { const { dbName, sampleId } = this.sample try { @@ -348,13 +220,7 @@ export default { // const { success, result, message } = Response - if (this._cancelToken && typeof this._cancelToken == 'function') { - this._cancelToken() - } - - const cancelToken = new axios.CancelToken((c) => { - this._cancelToken = c - }) + const cancelToken = this.cancelLastRequest() const { success, result, message } = await getAction( '/gamma/gammaByDB', @@ -381,9 +247,15 @@ export default { this.isLoading = true this.handleResetState() // const { success, result, message } = Response - const { success, result, message } = await getAction('/gamma/gammaByFile', { - fileName, - }) + const cancelToken = this.cancelLastRequest() + + const { success, result, message } = await getAction( + '/gamma/gammaByFile', + { + fileName, + }, + cancelToken + ) console.log('%c [ result ]-243', 'font-size:13px; background:pink; color:#bf2c9f;', result) if (success) { this.dataProsess(result) @@ -395,6 +267,16 @@ export default { } }, + cancelLastRequest() { + if (this._cancelToken && typeof this._cancelToken == 'function') { + this._cancelToken() + } + + return new axios.CancelToken((c) => { + this._cancelToken = c + }) + }, + dataProsess(result) { this.isLoading = false @@ -419,44 +301,40 @@ export default { this.detailedInfomation = DetailedInformation this.qcFlags = QCFlag - const channelPeakGroup = allData.filter((item) => item.name == 'Peak' && item.group == 'channel') - const energyPeakGroup = allData.filter((item) => item.name == 'Peak' && item.group == 'energy') + const channelPeakGroup = this.getLineData(allData, 'Peak', 'channel', true) + const energyPeakGroup = this.getLineData(allData, 'Peak', 'energy', true) - const channelBaseLine = allData.find((item) => item.name == 'BaseLine' && item.group == 'channel') || {} - const energyBaseLine = allData.find((item) => item.name == 'BaseLine' && item.group == 'energy') + const channelBaseLine = this.getLineData(allData, 'BaseLine', 'channel') + const energyBaseLine = this.getLineData(allData, 'BaseLine', 'energy') - const channelLcLine = allData.find((item) => item.name == 'Lc' && item.group == 'channel') || {} - const energyLcLine = allData.find((item) => item.name == 'Lc' && item.group == 'energy') + const channelLcLine = this.getLineData(allData, 'Lc', 'channel') + const energyLcLine = this.getLineData(allData, 'Lc', 'energy') - const channelScacLine = allData.find((item) => item.name == 'Scac' && item.group == 'channel') || {} - const energyScacLine = allData.find((item) => item.name == 'Scac' && item.group == 'energy') + const channelScacLine = this.getLineData(allData, 'Scac', 'channel') + const energyScacLine = this.getLineData(allData, 'Scac', 'energy') - this.allEnergy = allData.find((item) => item.name == 'Energy' && item.group == 'energy') || {} - this.allChannel = allData.find((item) => item.name == 'Count' && item.group == 'channel') + const allChannel = this.getLineData(allData, 'Count', 'channel') + const allEnergy = this.getLineData(allData, 'Energy', 'energy') - // 保存Peak Line - this.channelPeakGroup = channelPeakGroup - this.energyPeakGroup = energyPeakGroup + this.channelData = { + peakGroup: channelPeakGroup, + spectrumLine: shadowChannelChart, + baseLine: channelBaseLine, + lcLine: channelLcLine, + scacLine: channelScacLine, + all: allChannel, + baseLineCP: shapeChannelData, + } - // 保存 Spectrum Line - this.shadowChannelChart = shadowChannelChart - this.shadowEnergyChart = shadowEnergyChart - - // 保存基线 - this.channelBaseLine = channelBaseLine - this.energyBaseLine = energyBaseLine - - // 保存Lc - this.channelLcLine = channelLcLine - this.energyLcLine = energyLcLine - - // 保存Scac - this.channelScacLine = channelScacLine - this.energyScacLine = energyScacLine - - // 保存 基线控制点 - this.shapeChannelData = shapeChannelData - this.shapeEnergyData = shapeEnergyData + this.energyData = { + peakGroup: energyPeakGroup, + spectrumLine: shadowEnergyChart, + baseLine: energyBaseLine, + lcLine: energyLcLine, + scacLine: energyScacLine, + all: allEnergy, + baseLineCP: shapeEnergyData, + } this.resetThumbnailChartDataMax() const series = [] @@ -465,7 +343,7 @@ export default { series.push( buildLineSeries( 'Spectrum', - shadowChannelChart.pointlist && shadowChannelChart.pointlist.map(({ x, y }) => [x, y]), + this.transformPointListData(shadowChannelChart.pointlist), shadowChannelChart.color, { symbolSize: 2, @@ -485,65 +363,33 @@ export default { ) ) - // 右上角缩略图推入Spectrum Line - this.thumbnailOption.series.push( - buildLineSeries( - 'Spectrum', - shadowChannelChart.pointlist && shadowChannelChart.pointlist.map(({ x, y }) => [x, y]), - shadowChannelChart.color, - { - silent: true, - markLine: { - silent: true, - symbol: 'none', - label: { - show: false, - }, - lineStyle: { - type: 'solid', - color: '#1397a3', - width: 1, - }, - data: [], - }, - } - ) + // 右上角缩略图设置Spectrum Line 数据 + this.setSeriesData( + this.thumbnailOption.series, + 'Spectrum', + this.transformPointListData(shadowChannelChart.pointlist), + shadowChannelChart.color ) // 推入BaseLine series.push( - buildLineSeries( - 'BaseLine', - channelBaseLine.pointlist && channelBaseLine.pointlist.map(({ x, y }) => [x, y]), - channelBaseLine.color, - { - zlevel: 2, - } - ) + buildLineSeries('BaseLine', this.transformPointListData(channelBaseLine.pointlist), channelBaseLine.color, { + zlevel: 2, + }) ) // 推入LcLine线 series.push( - buildLineSeries( - 'LcLine', - channelLcLine.pointlist && channelLcLine.pointlist.map(({ x, y }) => [x, y]), - channelLcLine.color, - { - zlevel: 3, - } - ) + buildLineSeries('LcLine', this.transformPointListData(channelLcLine.pointlist), channelLcLine.color, { + zlevel: 3, + }) ) // 推入Scac线 series.push( - buildLineSeries( - 'ScacLine', - channelScacLine.pointlist && channelScacLine.pointlist.map(({ x, y }) => [x, y]), - channelScacLine.color, - { - zlevel: 4, - } - ) + buildLineSeries('ScacLine', this.transformPointListData(channelScacLine.pointlist), channelScacLine.color, { + zlevel: 4, + }) ) // 推入基线控制点 @@ -571,14 +417,9 @@ export default { const peakLines = [] channelPeakGroup.forEach((item, index) => { peakLines.push( - buildLineSeries( - `Peak_${index}`, - item.pointlist.map(({ x, y }) => [x, y]), - item.color, - { - zlevel: 6, - } - ) + buildLineSeries(`Peak_${index}`, this.transformPointListData(item.pointlist), item.color, { + zlevel: 6, + }) ) }) series.push(...peakLines) @@ -591,25 +432,26 @@ export default { ) this.option.series = series - - this.option.tooltip.formatter = this.tooltipFormatter }, + // chart 的 tooltip tooltipFormatter(params) { - if (this.isEnergy()) { - const energy = params[0].value[0] - const channel = this.getChannelByEnergy(energy) + let channel = 0 + let energy = 0 + const value = params[0].value[0] - return `
Channel: ${channel}
-
Energy: ${energy.toFixed(2)}
` + if (this.isEnergy()) { + energy = value.toFixed(2) + channel = this.getChannelByEnergy(energy) } else { - const channel = parseInt(params[0].value[0].toFixed()) - const energy = this.allEnergy.pointlist && this.allEnergy.pointlist[channel - 1] - return energy - ? `
Channel: ${channel}
-
Energy: ${energy.x.toFixed(2)}
` - : undefined + const allPointList = this.energyData.all.pointlist + channel = parseInt(value.toFixed()) + energy = allPointList && allPointList[channel - 1] + energy = energy ? energy.x.toFixed(2) : undefined } + + return `
Channel: ${channel}
+
Energy: ${energy}
` }, // Graph Assistance 操作 @@ -640,19 +482,24 @@ export default { this.redrawLineBySeriesName( 'BaseLine', - this.energyBaseLine, - this.channelBaseLine, + this.energyData.baseLine, + this.channelData.baseLine, this.graphAssistance.Baseline ) - this.redrawLineBySeriesName('LcLine', this.energyLcLine, this.channelLcLine, this.graphAssistance.Lc) + this.redrawLineBySeriesName( + 'LcLine', + this.energyData.lcLine, + this.channelData.lcLine, + this.graphAssistance.Lc + ) this.redrawLineBySeriesName( 'ScacLine', - this.energyScacLine, - this.channelScacLine, + this.energyData.scacLine, + this.channelData.scacLine, this.graphAssistance.SCAC ) - this.redrawLineBySeriesName('Spectrum', this.shadowEnergyChart, this.shadowChannelChart) + this.redrawLineBySeriesName('Spectrum', this.energyData.spectrumLine, this.channelData.spectrumLine) this.redrawCtrlPointBySeriesName() this.redrawPeakLine() @@ -674,7 +521,7 @@ export default { compareLineSeries.type = 'line' compareLineSeries.symbol = 'none' - this.redrawLineBySeriesName('Spectrum', this.shadowEnergyChart, this.shadowChannelChart) + this.redrawLineBySeriesName('Spectrum', this.energyData.spectrumLine, this.channelData.spectrumLine) if (this.channelCompareLine) { this.redrawLineBySeriesName('Compare', this.energyCompareLine, this.channelCompareLine) @@ -712,13 +559,13 @@ export default { } break case 'Baseline': - this.redrawLineBySeriesName('BaseLine', this.energyBaseLine, this.channelBaseLine, value) + this.redrawLineBySeriesName('BaseLine', this.energyData.baseLine, this.channelData.baseLine, value) break case 'Lc': - this.redrawLineBySeriesName('LcLine', this.energyLcLine, this.channelLcLine, value) + this.redrawLineBySeriesName('LcLine', this.energyData.lcLine, this.channelData.lcLine, value) break case 'SCAC': - this.redrawLineBySeriesName('ScacLine', this.energyScacLine, this.channelScacLine, value) + this.redrawLineBySeriesName('ScacLine', this.energyData.scacLine, this.channelData.scacLine, value) break } } @@ -730,22 +577,18 @@ export default { // 根据seriesName重绘线 redrawLineBySeriesName(seriesName, energyData, channelData, isShow = true, color) { - const series = findSeriesByName(this.option.series, seriesName) if (isShow) { const data = this.isEnergy() ? energyData : channelData - series.data = data.pointlist.map(({ x, y }) => [x, y]) + this.setSeriesData(this.option.series, seriesName, this.transformPointListData(data.pointlist), color) } else { - series.data = [] - } - if (color) { - series.itemStyle.color = color + this.setSeriesData(this.option.series, seriesName, []) } }, // 重绘控制点 redrawCtrlPointBySeriesName() { const series = findSeriesByName(this.option.series, 'BaseLine_Ctrl_Point') - const data = this.isEnergy() ? this.shapeEnergyData : this.shapeChannelData + const data = this.isEnergy() ? this.energyData.baseLineCP : this.channelData.baseLineCP series.data = data.map(({ size, color, point: { x, y } }) => { return { value: [x, y], @@ -764,18 +607,13 @@ export default { return !item.name.includes('Peak_') }) - const data = this.isEnergy() ? this.energyPeakGroup : this.channelPeakGroup + const data = this.isEnergy() ? this.energyData.peakGroup : this.channelData.peakGroup const peakLines = [] data.forEach((item, index) => { peakLines.push( - buildLineSeries( - `Peak_${index}`, - item.pointlist.map(({ x, y }) => [x, y]), - item.color, - { - zlevel: 6, - } - ) + buildLineSeries(`Peak_${index}`, this.transformPointListData(item.pointlist), item.color, { + zlevel: 6, + }) ) }) @@ -785,8 +623,8 @@ export default { // 重绘右上角的缩略图 redrawThumbnailChart() { const series = findSeriesByName(this.thumbnailOption.series, 'Spectrum') - const data = this.isEnergy() ? this.shadowEnergyChart : this.shadowChannelChart - series.data = data.pointlist.map(({ x, y }) => [x, y]) + const data = this.isEnergy() ? this.energyData.spectrumLine : this.channelData.spectrumLine + series.data = this.transformPointListData(data.pointlist) }, // 点击图表,设置红线 @@ -801,8 +639,10 @@ export default { const channel = this.isEnergy() ? this.getChannelByEnergy(xAxis) : parseInt(xAxis.toFixed()) const energy = this.isEnergy() ? xAxis.toFixed(2) - : this.allEnergy.pointlist && this.allEnergy.pointlist[channel - 1].x.toFixed(2) - const counts = this.isEnergy() ? this.allEnergy.pointlist[channel - 1] : this.allChannel.pointlist[channel - 1] + : this.energyData.all.pointlist && this.energyData.all.pointlist[channel - 1].x.toFixed(2) + const counts = this.isEnergy() + ? this.energyData.all.pointlist[channel - 1] + : this.channelData.all.pointlist[channel - 1] this.option.title.text = `{a|Channel:${channel}} {a|Energy:${energy}} {a|Counts:${counts.y}} {a|Detectability:0}` this.getSelPosNuclide(channel) @@ -864,7 +704,7 @@ export default { const spectrumLineSeries = findSeriesByName(this.option.series, 'Spectrum') const xAxis = spectrumLineSeries.markLine.data[0].xAxis const channel = this.isEnergy() ? this.getChannelByEnergy(xAxis) : parseInt(xAxis.toFixed()) - const index = this.channelPeakGroup.findIndex((peakItem) => { + const index = this.channelData.peakGroup.findIndex((peakItem) => { const allX = peakItem.pointlist.map((item) => item.x) const max = Math.max(...allX) const min = Math.min(...allX) @@ -887,7 +727,7 @@ export default { }) if (success) { const html = result.replaceAll('\n', '
') - const currPeak = this.channelPeakGroup[index] + const currPeak = this.channelData.peakGroup[index] const { x, y } = currPeak.pointlist.reduce((prev, curr) => { return prev && prev.y > curr.y ? prev : curr }) @@ -919,7 +759,7 @@ export default { const prevAxis = spectrumLineSeries.markLine.data[0].xAxis // 获取每一段 Channel 中的最大值 - const maxXAxises = this.channelPeakGroup.map((item) => { + const maxXAxises = this.channelData.peakGroup.map((item) => { const allY = item.pointlist.map((item) => item.y) const max = item.pointlist.find((point) => point.y == Math.max(...allY)) return max.x @@ -978,7 +818,6 @@ export default { // 改为不可刷选状态 chart.dispatchAction({ type: 'takeGlobalCursor', - brushOption: false }) }, @@ -1058,16 +897,16 @@ export default { const y2 = getAxisMax(chart, 'yAxis') const channelSpectrumData = { - ...this.shadowChannelChart, + ...this.channelData.spectrumLine, pointlist: isReset - ? this.pointlistLimitY(this.shadowChannelChart.pointlist) - : this.pointlistLimit(this.shadowChannelChart.pointlist, x1, x2, y1, y2), + ? this.pointlistLimitY(this.channelData.spectrumLine.pointlist) + : this.pointlistLimit(this.channelData.spectrumLine.pointlist, x1, x2, y1, y2), } const energySpectrumData = { - ...this.shadowEnergyChart, + ...this.energyData.spectrumLine, pointlist: isReset - ? this.pointlistLimitY(this.shadowEnergyChart.pointlist) - : this.pointlistLimit(this.shadowEnergyChart.pointlist, x1, x2, y1, y2), + ? this.pointlistLimitY(this.energyData.spectrumLine.pointlist) + : this.pointlistLimit(this.energyData.spectrumLine.pointlist, x1, x2, y1, y2), } this.redrawLineBySeriesName('Spectrum', energySpectrumData, channelSpectrumData) @@ -1171,8 +1010,8 @@ export default { this.setThumbnailChartRect(xAxis - halfWidth, maxYAxis, xAxis + halfWidth, minYAxis) if (this.isEnergy()) { - const x1 = parseInt(this.shadowEnergyChart.pointlist[xAxis - halfWidth].x) - const x2 = parseInt(this.shadowEnergyChart.pointlist[xAxis + halfWidth].x) + const x1 = parseInt(this.energyData.spectrumLine.pointlist[xAxis - halfWidth].x) + const x2 = parseInt(this.energyData.spectrumLine.pointlist[xAxis + halfWidth].x) this.option.xAxis.min = x1 this.option.xAxis.max = x2 @@ -1190,7 +1029,9 @@ export default { } }, - // 重置 + /** + * 重置图表 + */ handleResetChart() { this.option.xAxis.min = 1 this.option.xAxis.max = 'dataMax' @@ -1291,12 +1132,16 @@ export default { // this.reprocessingModalVisible = true }, - // 重置缩略图表y轴最大值 + /** + * 重置缩略图表y轴最大值 + */ resetThumbnailChartDataMax() { this.thumbnailOption.yAxis.max = 'dataMax' }, - // 重置图表配置 + /** + * 重置图表配置 + */ resetChartOpts() { this.opts.notMerge = false this.option.brush = { toolbox: [] } @@ -1318,12 +1163,17 @@ export default { ] }, + /** + * 根据energy获取channel + * @param {number} energy + */ getChannelByEnergy(energy) { let channel = 0 - for (let index = 1; index < this.allEnergy.pointlist.length; index++) { - const currEnergy = this.allEnergy.pointlist[index].x + const pointlist = this.energyData.all.pointlist + for (let index = 1; index < pointlist.length; index++) { + const currEnergy = pointlist[index].x if (currEnergy >= energy) { - const prevEnergy = this.allEnergy.pointlist[index - 1].x + const prevEnergy = pointlist[index - 1].x if (currEnergy - energy > energy - prevEnergy.x) { channel = index } else { @@ -1335,13 +1185,16 @@ export default { return channel }, - // 重置页面信息 + /** + * 重置页面信息 + */ handleResetState() { + this.handleResetChart() + this.selectedChannel = -1 this.nuclideLibraryList = [] this.closePeakInfomationTooltip() this.option.series = [] - this.thumbnailOption.series = [] this.option.xAxis.name = 'Channel' this.option.yAxis.type = 'value' @@ -1352,14 +1205,17 @@ export default { spectrumLineSeries.markLine.lineStyle.width = 2 } - if (this.thumbnailOption.series.length) { - const thumbnailSpectrumLineSeries = findSeriesByName(this.thumbnailOption.series, 'Spectrum') - thumbnailSpectrumLineSeries.type = 'line' - thumbnailSpectrumLineSeries.symbol = 'none' - } + const thumbnailSpectrumLineSeries = findSeriesByName(this.thumbnailOption.series, 'Spectrum') + thumbnailSpectrumLineSeries.type = 'line' + thumbnailSpectrumLineSeries.symbol = 'none' + this.graphAssistance = cloneDeep(graphAssistance) }, + /** + * 颜色改变 + * @param {*} colorConfig + */ handleColorChange(colorConfig) { // 如果还没加载完,加载新的 if (this.isLoading) { @@ -1376,22 +1232,22 @@ export default { const { Color_Spec, Color_Peak, Color_Lc, Color_Base, Color_Scac, Color_Compare, Color_Strip, Color_Fitbase } = colorConfig - this.shadowChannelChart.color = Color_Spec - this.shadowEnergyChart.color = Color_Spec + this.channelData.spectrumLine.color = Color_Spec + this.energyData.spectrumLine.color = Color_Spec - for (let i = 0; i < this.channelPeakGroup.length; i++) { - this.channelPeakGroup[i].color = Color_Peak - this.energyPeakGroup[i].color = Color_Peak + for (let i = 0; i < this.channelData.peakGroup.length; i++) { + this.channelData.peakGroup[i].color = Color_Peak + this.energyData.peakGroup[i].color = Color_Peak } - this.channelLcLine.color = Color_Lc - this.energyLcLine.color = Color_Lc + this.channelData.lcLine.color = Color_Lc + this.energyData.lcLine.color = Color_Lc - this.channelBaseLine.color = Color_Base - this.energyBaseLine.color = Color_Base + this.channelData.baseLine.color = Color_Base + this.energyData.baseLine.color = Color_Base - this.channelScacLine.color = Color_Scac - this.energyScacLine.color = Color_Scac + this.channelData.scacLine.color = Color_Scac + this.energyData.scacLine.color = Color_Scac if (this.channelCompareLine) { this.channelCompareLine.color = Color_Compare @@ -1409,7 +1265,11 @@ export default { thumbnailChartSeries.itemStyle.color = Color_Spec }, - // 根据series名修改颜色 + /** + * 根据series名修改颜色 + * @param {*} seriesName + * @param {*} color + */ changeColorBySeriesName(seriesName, color) { const series = findSeriesByName(this.option.series, seriesName) series.itemStyle.color = color @@ -1439,6 +1299,38 @@ export default { getThumbnailChart() { return this.$refs.thumbnailChartRef.getChartInstance() }, + + /** + * 设置图表数据和颜色 + */ + setSeriesData(series, seriesName, data, color) { + const find = findSeriesByName(series, seriesName) + find.data = data + if (color) { + find.itemStyle.color = color + } + }, + + /** + * 转换pointlist类型数据到series的data可用的数据 + */ + transformPointListData(pointlist) { + if (!pointlist) { + return [] + } + return pointlist.map(({ x, y }) => [x, y]) + }, + + /** + * 在返回的allData中查找指定的数据 + * @param {Array} allData + * @param {*} name + * @param {*} group + */ + getLineData(allData, name, group, isList = false) { + const arrFunc = isList ? Array.prototype.filter : Array.prototype.find + return arrFunc.call(allData, (item) => item.name == name && item.group == group) || {} + }, }, watch: { sample: { diff --git a/src/views/spectrumAnalysis/index.vue b/src/views/spectrumAnalysis/index.vue index ea7de82..a3ed212 100644 --- a/src/views/spectrumAnalysis/index.vue +++ b/src/views/spectrumAnalysis/index.vue @@ -432,7 +432,7 @@ export default { }) arr.forEach((item) => { item.dbName = '' - item.sampleId = '' + item.sampleId = null item.inputFileName = item.sampleFileName item.sampleType = item.sampleSystemType }) diff --git a/src/views/spectrumAnalysis/settings.js b/src/views/spectrumAnalysis/settings.js new file mode 100644 index 0000000..3a89271 --- /dev/null +++ b/src/views/spectrumAnalysis/settings.js @@ -0,0 +1,167 @@ +import { buildLineSeries } from "@/utils/chartHelper" + +export const GammaOptions = { + option: { + grid: { + top: 40, + left: 60, + right: 50, + containLabel: true + }, + title: { + text: '', + left: 'center', + bottom: 10, + textStyle: { + color: '#8FD4F8', + rich: { + a: { + padding: [0, 20, 0, 0], + fontSize: 16 + } + } + } + }, + tooltip: { + trigger: 'axis', + axisPointer: { + lineStyle: { + color: '#3CAEBB', + width: 1, + type: 'solid' + } + }, + formatter: undefined, + className: 'figure-chart-option-tooltip' + }, + xAxis: { + name: 'Channel', + nameTextStyle: { + color: '#8FD4F8', + fontSize: 16, + align: 'right', + verticalAlign: 'top', + padding: [30, 0, 0, 0] + }, + axisLine: { + lineStyle: { + color: '#ade6ee' + } + }, + splitLine: { + show: false + }, + axisLabel: { + textStyle: { + color: '#ade6ee' + } + }, + min: 1, + max: 'dataMax', + animation: false, + axisLabel: { + formatter: value => { + return parseInt(value) + } + } + }, + yAxis: { + name: 'Counts', + type: 'value', + nameTextStyle: { + color: '#8FD4F8', + fontSize: 16 + }, + axisLine: { + show: true, + lineStyle: { + color: '#ade6ee' + } + }, + splitLine: { + show: true, + lineStyle: { + color: 'rgba(173, 230, 238, .2)' + } + }, + axisLabel: { + textStyle: { + color: '#ade6ee' + } + }, + min: 1, + max: 'dataMax', + animation: false, + axisLabel: { + formatter: value => { + return value.toFixed(1) + } + } + }, + series: [], + brush: {} + }, + // 缩略图配置 + thumbnailOption: { + grid: { + top: 0, + left: 5, + right: 5, + bottom: 0 + }, + xAxis: { + type: 'category', + axisLine: { + show: false + }, + splitLine: { + show: false + }, + axisLabel: { + show: false + }, + min: 1, + max: 'dataMax' + }, + yAxis: { + type: 'value', + axisLine: { + show: false + }, + splitLine: { + show: false + }, + axisLabel: { + show: false + }, + min: 1, + max: 'dataMax' + }, + series: [ + buildLineSeries('Spectrum', [], '#fff', { + silent: true, + markLine: { + silent: true, + symbol: 'none', + label: { + show: false + }, + lineStyle: { + type: 'solid', + color: '#1397a3', + width: 1 + }, + data: [] + } + }) + ] + } +} + +export const graphAssistance = { + axisType: 'Channel', + spectrumType: 'Lines', + Baseline: true, + SCAC: true, + Lc: true, +} \ No newline at end of file From 0c06c5af79391317c63cb1dca27700ef379b8fb2 Mon Sep 17 00:00:00 2001 From: Xu Zhimeng Date: Wed, 27 Sep 2023 14:53:17 +0800 Subject: [PATCH 10/13] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E3=80=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9F=90=E4=BA=9B=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../spectrumAnalysis/beta-gamma-analysis.vue | 39 ++++++++++++-- .../components/BetaGammaSpectrumChart.vue | 3 +- .../components/Modals/ArrRrrModal.vue | 51 +++++++++++-------- .../BetaGammaExtrapolationModal.vue | 8 +++ src/views/spectrumAnalysis/gamma-analysis.vue | 24 ++++++--- 5 files changed, 88 insertions(+), 37 deletions(-) diff --git a/src/views/spectrumAnalysis/beta-gamma-analysis.vue b/src/views/spectrumAnalysis/beta-gamma-analysis.vue index 9eb80fb..7d5f098 100644 --- a/src/views/spectrumAnalysis/beta-gamma-analysis.vue +++ b/src/views/spectrumAnalysis/beta-gamma-analysis.vue @@ -133,6 +133,7 @@ import BetaGammaQcFlags from './components/SubOperators/BetaGammaQcFlags.vue' import PopOverWithIcon from './components/SubOperators/PopOverWithIcon.vue' import Spectra from './components/SubOperators/Spectra.vue' import CustomSelect from '@/components/CustomSelect/index.vue' +import axios from 'axios' const StatisticsType = { 'Collection Time': 'Colloc_Time', @@ -219,6 +220,9 @@ export default { currSample: {}, } }, + destroyed() { + this.cancelLastRequest() + }, methods: { handleGetFlag(val, obj) { this.resultDisplay.forEach((item) => { @@ -234,10 +238,16 @@ export default { const { dbName, sampleId } = this.sample try { this.isLoading = true - const { success, result, message } = await getAction('/spectrumAnalysis/getDBSpectrumChart', { - dbName, - sampleId, - }) + this.cancelLastRequest() + const cancelToken = this.createCancelToken() + const { success, result, message } = await getAction( + '/spectrumAnalysis/getDBSpectrumChart', + { + dbName, + sampleId, + }, + cancelToken + ) if (success) { this.sampleDetail = result this.changeChartByType('sample') @@ -264,7 +274,13 @@ export default { } try { this.isLoading = true - const { success, result, message } = await getAction('/spectrumAnalysis/getFileSpectrumChart', params) + this.cancelLastRequest() + const cancelToken = this.createCancelToken() + const { success, result, message } = await getAction( + '/spectrumAnalysis/getFileSpectrumChart', + params, + cancelToken + ) if (success) { this.sampleDetail = result this.changeChartByType('sample') @@ -277,6 +293,19 @@ export default { } }, + cancelLastRequest() { + if (this._cancelToken && typeof this._cancelToken == 'function') { + this._cancelToken() + } + }, + + createCancelToken() { + const cancelToken = new axios.CancelToken((c) => { + this._cancelToken = c + }) + return cancelToken + }, + changeChartByType(val) { if (val === 'qc' && !this.sample.qcFileStatus) { this.$message.warning('No qc spectrum file!') diff --git a/src/views/spectrumAnalysis/components/BetaGammaSpectrumChart.vue b/src/views/spectrumAnalysis/components/BetaGammaSpectrumChart.vue index 3dc5eff..0315866 100644 --- a/src/views/spectrumAnalysis/components/BetaGammaSpectrumChart.vue +++ b/src/views/spectrumAnalysis/components/BetaGammaSpectrumChart.vue @@ -411,8 +411,7 @@ export default { // 改为不可刷选状态 chart.dispatchAction({ - type: 'takeGlobalCursor', - rushOption: false + type: 'takeGlobalCursor' }) }, diff --git a/src/views/spectrumAnalysis/components/Modals/ArrRrrModal.vue b/src/views/spectrumAnalysis/components/Modals/ArrRrrModal.vue index bcda351..ba28f60 100644 --- a/src/views/spectrumAnalysis/components/Modals/ArrRrrModal.vue +++ b/src/views/spectrumAnalysis/components/Modals/ArrRrrModal.vue @@ -3,7 +3,7 @@
{{ content }}
-
+
Export Cancel @@ -14,25 +14,25 @@ diff --git a/src/views/spectrumAnalysis/components/Modals/BetaGammaModals/BetaGammaExtrapolationModal.vue b/src/views/spectrumAnalysis/components/Modals/BetaGammaModals/BetaGammaExtrapolationModal.vue index 819f7eb..4e4e193 100644 --- a/src/views/spectrumAnalysis/components/Modals/BetaGammaModals/BetaGammaExtrapolationModal.vue +++ b/src/views/spectrumAnalysis/components/Modals/BetaGammaModals/BetaGammaExtrapolationModal.vue @@ -451,6 +451,14 @@ export default { methods: { beforeModalOpen() { this.customToolTip.visible = false + const gammaSeries = this.gammaSpectrumChartOption.series + gammaSeries[0].data = [] + gammaSeries[1].data = [] + + const betaSeries = this.betaSpectrumChartOption.series + betaSeries[0].data = [] + betaSeries[1].data = [] + this.getDetail() }, diff --git a/src/views/spectrumAnalysis/gamma-analysis.vue b/src/views/spectrumAnalysis/gamma-analysis.vue index 6e36352..c6d48af 100644 --- a/src/views/spectrumAnalysis/gamma-analysis.vue +++ b/src/views/spectrumAnalysis/gamma-analysis.vue @@ -202,6 +202,8 @@ export default { this.$bus.$on('accept', this.handleAccept) }, destroyed() { + this.cancelLastRequest() + this.$bus.$off('colorChange', this.handleColorChange) this.$bus.$off('gammaRefresh', this.handleRefresh) this.$bus.$off('accept', this.handleAccept) @@ -219,8 +221,8 @@ export default { this.handleResetState() // const { success, result, message } = Response - - const cancelToken = this.cancelLastRequest() + this.cancelLastRequest() + const cancelToken = this.createCancelToken() const { success, result, message } = await getAction( '/gamma/gammaByDB', @@ -247,7 +249,9 @@ export default { this.isLoading = true this.handleResetState() // const { success, result, message } = Response - const cancelToken = this.cancelLastRequest() + + this.cancelLastRequest() + const cancelToken = this.createCancelToken() const { success, result, message } = await getAction( '/gamma/gammaByFile', @@ -271,10 +275,13 @@ export default { if (this._cancelToken && typeof this._cancelToken == 'function') { this._cancelToken() } + }, - return new axios.CancelToken((c) => { + createCancelToken() { + const cancelToken = new axios.CancelToken((c) => { this._cancelToken = c }) + return cancelToken }, dataProsess(result) { @@ -1165,7 +1172,7 @@ export default { /** * 根据energy获取channel - * @param {number} energy + * @param {number} energy */ getChannelByEnergy(energy) { let channel = 0 @@ -1197,6 +1204,7 @@ export default { this.option.series = [] this.option.xAxis.name = 'Channel' this.option.yAxis.type = 'value' + this.thumbnailOption.yAxis.type = 'value' if (this.option.series.length) { const spectrumLineSeries = findSeriesByName(this.option.series, 'Spectrum') @@ -1214,7 +1222,7 @@ export default { /** * 颜色改变 - * @param {*} colorConfig + * @param {*} colorConfig */ handleColorChange(colorConfig) { // 如果还没加载完,加载新的 @@ -1267,8 +1275,8 @@ export default { /** * 根据series名修改颜色 - * @param {*} seriesName - * @param {*} color + * @param {*} seriesName + * @param {*} color */ changeColorBySeriesName(seriesName, color) { const series = findSeriesByName(this.option.series, seriesName) From e7533a7fe2323c7aed10a7df6bc82f6c6cac174e Mon Sep 17 00:00:00 2001 From: Xu Zhimeng Date: Wed, 27 Sep 2023 15:38:36 +0800 Subject: [PATCH 11/13] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DSample=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E4=B8=8B=E7=9A=84Sample=E5=88=97=E8=A1=A8=E5=AD=98?= =?UTF-8?q?=E5=9C=A8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/Modals/LoadFromDBModal.vue | 3 ++- .../components/SpectraListInMenu.vue | 27 +++++++++++-------- src/views/spectrumAnalysis/index.vue | 15 +++++------ 3 files changed, 25 insertions(+), 20 deletions(-) diff --git a/src/views/spectrumAnalysis/components/Modals/LoadFromDBModal.vue b/src/views/spectrumAnalysis/components/Modals/LoadFromDBModal.vue index 9ce3d5c..ed97764 100644 --- a/src/views/spectrumAnalysis/components/Modals/LoadFromDBModal.vue +++ b/src/views/spectrumAnalysis/components/Modals/LoadFromDBModal.vue @@ -37,6 +37,7 @@ import { JeecgListMixin } from '@/mixins/JeecgListMixin' import { getAction } from '../../../../api/manage' import moment from 'moment' +import { cloneDeep } from 'lodash' const columns = [ { @@ -201,7 +202,7 @@ export default { } this.selectedRowKeys = [] this.visible = false - this.$emit('loadSample', this.selectionRows) + this.$emit('loadSample', cloneDeep(this.selectionRows)) }, // 获取台站和探测器列表 diff --git a/src/views/spectrumAnalysis/components/SpectraListInMenu.vue b/src/views/spectrumAnalysis/components/SpectraListInMenu.vue index 6969a05..f55065b 100644 --- a/src/views/spectrumAnalysis/components/SpectraListInMenu.vue +++ b/src/views/spectrumAnalysis/components/SpectraListInMenu.vue @@ -1,11 +1,16 @@ @@ -26,25 +31,25 @@ export default { this.$forceUpdate() }, - handleRemove(spectraItem) { - const index = this.list.findIndex(item => item == spectraItem) - this.list.splice(index, 1) + handleRemove(spectraItem, index) { // 如果删除了一个选中的 if (spectraItem.checked) { - if (index == 0) { - // 如果是第一个,则选中下一个 - this.handleClick(this.list[0]) - } else { - // 如果不是第一个,则选中上一个 + // // 如果是倒数第一个,则选中上一个 + if (index == this.list.length - 1) { this.handleClick(this.list[index - 1]) } + // 否则选中下一个 + else { + this.handleClick(this.list[index + 1]) + } } + this.list.splice(index, 1) this.$forceUpdate() } }, watch: { list(newVal) { - if (newVal.length) { + if (newVal.length && !newVal.find(item => item.checked)) { this.handleClick(newVal[0]) } } diff --git a/src/views/spectrumAnalysis/index.vue b/src/views/spectrumAnalysis/index.vue index a3ed212..8e985ef 100644 --- a/src/views/spectrumAnalysis/index.vue +++ b/src/views/spectrumAnalysis/index.vue @@ -382,12 +382,12 @@ export default { }, created() { this.$bus.$on('reanalyse', this.handleReanalyse) - this.loadSelectedSample({ - sampleId: 426530, - sampleType: 'G', - dbName: 'auto', - inputFileName: 'CAX05_001-20230731_1528_S_FULL_37563.6.PHD', - }) + // this.loadSelectedSample({ + // sampleId: 426530, + // sampleType: 'G', + // dbName: 'auto', + // inputFileName: 'CAX05_001-20230731_1528_S_FULL_37563.6.PHD', + // }) }, destroyed() { @@ -679,8 +679,7 @@ export default { if (spectra) { this.loadSelectedSample(spectra) } else { - this.analysisType = undefined - this.sampleData = {} + this.handleCleanAll() } }, }, From 47e6b19c8c8cc4a5ef816124af15d252166d19f5 Mon Sep 17 00:00:00 2001 From: Xu Zhimeng Date: Wed, 27 Sep 2023 15:55:48 +0800 Subject: [PATCH 12/13] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E9=A1=B6?= =?UTF-8?q?=E9=83=A8=E6=93=8D=E4=BD=9C=E6=A0=8F=E5=B1=95=E7=A4=BA=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/spectrumAnalysis/index.vue | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/views/spectrumAnalysis/index.vue b/src/views/spectrumAnalysis/index.vue index 8e985ef..2ff2db8 100644 --- a/src/views/spectrumAnalysis/index.vue +++ b/src/views/spectrumAnalysis/index.vue @@ -13,7 +13,7 @@ {{ operation.title }}