From a921c64f6b22e9c112a26b19f6edd4572195bc3b Mon Sep 17 00:00:00 2001 From: Xu Zhimeng Date: Thu, 21 Sep 2023 19:41:16 +0800 Subject: [PATCH 1/8] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E9=83=A8=E5=88=86?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E5=8F=8A=E5=8A=9F=E8=83=BD,=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0Gamma=E7=9A=84Save=20to=20DB=20=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=8C=E5=AE=8C=E6=88=90Gamma=20Calibration?= =?UTF-8?q?=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 2/8] =?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 3/8] =?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 4/8] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=EF=BC=8C=E8=A7=A3=E5=86=B3scatterGL=E4=B8=8D=E5=8F=97=E8=BD=B4?= =?UTF-8?q?=E7=BA=BF=E6=9C=80=E5=A4=A7/=E6=9C=80=E5=B0=8F=E5=80=BC?= =?UTF-8?q?=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 5/8] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3scatterGL=E5=9C=A8?= =?UTF-8?q?=E5=90=84=E7=A7=8D=E6=83=85=E5=86=B5=E4=B8=8B=E5=8F=96=E5=80=BC?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E7=9A=84=E6=B8=B2=E6=9F=93=E9=97=AE=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 6/8] =?UTF-8?q?feat:=20=E5=AF=B9=E6=8E=A5Comments=20->=20A?= =?UTF-8?q?dd?= 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 7/8] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E5=9B=BE=E8=A1=A8?= =?UTF-8?q?=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 8/8] =?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 },