diff --git a/src/components/CustomChart/index.vue b/src/components/CustomChart/index.vue index 6fea3e9..c38f28c 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/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/utils/chartHelper.js b/src/utils/chartHelper.js index 6560aae..ab1bc3e 100644 --- a/src/utils/chartHelper.js +++ b/src/utils/chartHelper.js @@ -99,9 +99,20 @@ export function findSeriesByName(series, seriesName) { * 限定数字在一定范围 * @param {Number} min * @param {Number} max + * @returns {(num: number) => number } */ 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/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 b34e983..7d5f098 100644 --- a/src/views/spectrumAnalysis/beta-gamma-analysis.vue +++ b/src/views/spectrumAnalysis/beta-gamma-analysis.vue @@ -16,6 +16,7 @@ :options="SampleType" @change="changeChartByType" style="width: 246px" + class="sample-select" > @@ -132,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', @@ -218,6 +220,9 @@ export default { currSample: {}, } }, + destroyed() { + this.cancelLastRequest() + }, methods: { handleGetFlag(val, obj) { this.resultDisplay.forEach((item) => { @@ -233,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') @@ -263,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') @@ -276,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!') @@ -437,6 +467,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/BetaGammaSpectrumChart.vue b/src/views/spectrumAnalysis/components/BetaGammaSpectrumChart.vue index d00bc10..0315866 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 @@ -436,11 +438,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 +482,7 @@ export default { } this.reDrawRect() + this.rangeScatter() }, // 重绘矩形框区域 @@ -705,6 +726,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 }, 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..cc39cab 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/ArrRrrModal.vue b/src/views/spectrumAnalysis/components/Modals/ArrRrrModal.vue index bdff574..ba28f60 100644 --- a/src/views/spectrumAnalysis/components/Modals/ArrRrrModal.vue +++ b/src/views/spectrumAnalysis/components/Modals/ArrRrrModal.vue @@ -1,9 +1,9 @@