WIP: 增加 calibration 弹窗

This commit is contained in:
Xu Zhimeng 2024-07-09 17:12:57 +08:00
parent dc0b9065a5
commit eb2ab9416e
4 changed files with 2648 additions and 0 deletions

View File

@ -0,0 +1,282 @@
<template>
<custom-modal
v-model="visible"
:width="1200"
title="Tool of Calibration"
class="beta-gamma-tool-of-calibration"
:footer="null"
destroy-on-close
@cancel="handleExit"
>
<a-tabs :animated="false" v-model="currTab">
<a-tab-pane tab="Gamma Detector Calibration" key="gamma">
<gamma-detector-calibration @isFitting="getFittingFlag_gamma" :isFirstFitting="gammaEnergyValid" />
</a-tab-pane>
<a-tab-pane tab="Beta Detector Calibration" key="beta">
<beta-detector-calibration @isFitting="getFittingFlag_beta" :isFirstFitting="betaEnergyValid" />
</a-tab-pane>
</a-tabs>
<div class="footer">
<title-over-border title="New Calibration is Applied to">
<a-radio-group v-model="newCalibrationIsAppliedTo">
<p>
<a-radio value="AllSpectrum">All Spectra</a-radio>
</p>
<a-radio value="CurrentSpectrum">Current Spectrum</a-radio>
</a-radio-group>
</title-over-border>
<title-over-border title="Recalculate ROI Counts For">
<a-checkbox-group v-model="recalculateROICountsFor" @change="recalculateROICountsForChange">
<p>
<a-checkbox value="sample">Sample Data</a-checkbox>
<a-checkbox value="gasBg">GasBg Data</a-checkbox>
</p>
<a-checkbox value="detBg">DetBg Data</a-checkbox>
<a-checkbox value="qc">QC Data</a-checkbox>
</a-checkbox-group>
</title-over-border>
<div class="footer-btns">
<a-button type="primary" @click="handleReAnalyse">Reanalyse Spectrum Using New Calibration</a-button>
<a-button type="primary" class="exit" @click="handleExit">Exit</a-button>
</div>
</div>
</custom-modal>
</template>
<script>
import SampleDataMixin from '@/views/spectrumAnalysis/SampleDataMixin'
import { postAction } from '@/api/manage'
import BetaDetectorCalibration from './components/BetaDetectorCalibration.vue'
import GammaDetectorCalibration from './components/GammaDetectorCalibration.vue'
import TitleOverBorder from '@/views/spectrumAnalysis/components/TitleOverBorder.vue'
import { removeSampleData } from '@/utils/SampleStore'
export default {
components: { BetaDetectorCalibration, GammaDetectorCalibration, TitleOverBorder },
mixins: [SampleDataMixin],
props: {
sampleList: {
type: Array,
required: true,
},
},
data() {
return {
visible: false,
currTab: 'gamma',
newCalibrationIsAppliedTo: 'CurrentSpectrum',
recalculateROICountsFor: [],
checkFlag: {
checkSample: false,
checkGas: false,
checkDet: false,
},
betaEnergyValid: false,
gammaEnergyValid: false,
isReanlyze: false,
}
},
methods: {
show() {
this.currTab = 'gamma'
this.visible = true
},
recalculateROICountsForChange(checkedVal) {
this.recalculateROICountsFor = checkedVal
this.checkFlag.checkSample = checkedVal.includes('sample') ? true : false
this.checkFlag.checkGas = checkedVal.includes('gasBg') ? true : false
this.checkFlag.checkDet = checkedVal.includes('detBg') ? true : false
this.$emit('sendInfo', this.checkFlag)
},
getFittingFlag_beta(val) {
this.betaEnergyValid = val
console.log('betaEnergyValid>>>' + this.betaEnergyValid)
},
getFittingFlag_gamma(val) {
this.gammaEnergyValid = val
// 1. BetaGamma
// 2. Gammabeta
// if(!this.gammaEnergyValid){
// this.betaEnergyValid = val;
// console.log("Beta>>"+this.betaEnergyValid)
// }
console.log('gammaEnergyValid>>>' + this.gammaEnergyValid)
},
handleReAnalyse() {
// todo 1.fitting; 2.isReAnalyze
if (!this.gammaEnergyValid && !this.betaEnergyValid) {
return false
}
const regExp = /^([A-Z]{1,}\d{1,})_/
const regMatched = this.newSampleData.inputFileName.match(regExp)
const currStationName = regMatched[1]
const dbNames = [],
sampleIds = [],
sampleFileNames = [],
gasFileNames = [],
detFileNames = [],
qcFileNames = []
const matchedSampleList = this.sampleList.filter((item) => item.inputFileName.includes(currStationName))
matchedSampleList.forEach(
({ dbName, sampleId, inputFileName, sampleFileName, gasFileName, detFileName, qcFileName, qcFileStatus }) => {
dbNames.push(dbName || '')
sampleIds.push(sampleId || '')
sampleFileNames.push(sampleFileName || inputFileName || '')
gasFileNames.push(gasFileName || '')
detFileNames.push(detFileName || '')
qcFileNames.push(qcFileStatus ? qcFileName : '')
}
)
let params = {
applyType: this.newCalibrationIsAppliedTo,
sampleData: this.recalculateROICountsFor.includes('sample') ? true : false,
gasBgData: this.recalculateROICountsFor.includes('gasBg') ? true : false,
detBgData: this.recalculateROICountsFor.includes('detBg') ? true : false,
qcData: this.recalculateROICountsFor.includes('qc') ? true : false,
betaEnergyValid: this.betaEnergyValid,
gammaEnergyValid: this.gammaEnergyValid,
dbNames,
sampleIds,
sampleFileNames,
gasFileNames,
detFileNames,
qcFileNames,
currentFileName: this.newSampleData.inputFileName,
currentQCFileName: this.newSampleData.qcFileName,
}
postAction('/spectrumAnalysis/ReAnalyse', params).then((res) => {
if (res.success) {
res.result.XeData.forEach((item) => {
item.conc = parseFloat(item.conc.toPrecision(6))
item.concErr = parseFloat(item.concErr.toPrecision(6))
item.lc = parseFloat(item.lc.toPrecision(6))
item.mdc = parseFloat(item.mdc.toPrecision(6))
})
this.$emit('sendXeData', res.result.XeData)
this.$emit('reAnalyCurr', res.result.savedAnalysisResult, res.result.XeData)
this.isReanlyze = true
this.handleExit()
this.$bus.$emit('ReAnalyses', res.result)
if (res.result.bProcessed) {
this.$message.success(res.result.message)
} else {
this.$message.warning(res.result.message)
}
if (this.newCalibrationIsAppliedTo == 'AllSpectrum') {
let sameStation = matchedSampleList.filter(
(item) => item.inputFileName !== this.newSampleData.inputFileName
)
this.clearSameStationCache(sameStation)
this.setSameStationCalibarationCache(sameStation)
}
} else {
this.$message.warning(res.message)
}
})
},
//
clearSameStationCache(sampleList) {
sampleList.forEach(({ inputFileName }) => {
removeSampleData(inputFileName)
})
},
// Calibration 20231115xiao
setSameStationCalibarationCache(sampleList) {
sampleList.forEach(({ inputFileName }) => {
console.log('inputFileName:' + inputFileName)
// tab
if (this.currTab === 'gamma') {
this.$ls.set(
'CALIBRATION_GAMMA_' + inputFileName,
this.$ls.get('CALIBRATION_GAMMA_' + this.newSampleData.inputFileName)
)
}
if (this.currTab === 'beta') {
this.$ls.set(
'CALIBRATION_BETA_' + inputFileName,
this.$ls.get('CALIBRATION_BETA_' + this.newSampleData.inputFileName)
)
}
})
},
handleExit() {
console.log('this.currTab>>>' + this.currTab)
this.gammaEnergyValid = this.isReanlyze
if (!this.isReanlyze && (!this.gammaEnergyValid || !this.gammaEnergyValid)) {
// ReANalyzefitting 20231101:xiao
// 1. BetaGamma
// 2. reanalyzebeta
this.$ls.remove('CALIBRATION_GAMMA_' + this.newSampleData.inputFileName)
this.$ls.remove('CALIBRATION_BETA_' + this.newSampleData.inputFileName)
}
this.visible = false
},
},
}
</script>
<style lang="less">
.beta-gamma-tool-of-calibration {
.ant-modal-body {
padding-top: 0;
}
.ant-tabs-nav .ant-tabs-tab {
padding: 5px 10px;
margin: 0 !important;
}
}
</style>
<style lang="less" scoped>
::v-deep {
.ant-modal {
top: 5px;
padding-bottom: 15px;
}
.ant-form-item-label,
.ant-form-item-control {
line-height: 30px !important;
}
.title-over-border-content {
padding: 10px;
}
}
.footer {
margin-top: 10px;
display: flex;
gap: 10px;
.title-over-border {
&:first-child {
flex: 4;
}
&:nth-child(2) {
flex: 5;
.ant-checkbox-wrapper {
width: 145px;
}
}
}
&-btns {
flex: 6;
display: flex;
justify-content: flex-end;
gap: 20px;
align-items: center;
.exit {
width: 130px;
}
}
}
</style>

View File

@ -242,6 +242,8 @@
<statistics-paramer-history-modal v-model="statisticsParamerHistoryModalVisible" />
<!-- Beta-Gamma Statistics Paramer History 弹窗 结束 -->
<bg-log-viewer v-model="bgLogViewerVisible" />
<CalibrationModal :sampleList="sampleList" ref="newCalibrationModalRef" />
</div>
</template>
<script>
@ -289,6 +291,8 @@ import FtransltModal from './components/Modals/FtransltModal/index.vue'
import BetaGammaEnergyCalibrationModal from './components/Modals/BetaGammaModals/BetaGammaEnergyCalibrationModal/index.vue'
import AutomaticAnalysisLogModal from './components/Modals/BetaGammaModals/AutomaticAnalysisLogModal.vue'
import BetaGammaExtrapolationModal from './components/Modals/BetaGammaModals/BetaGammaExtrapolationModal.vue'
import CalibrationModal from './components/Modals/NewBetaModals/CalibrationModal/index.vue'
import { getAction } from '@/api/manage'
import { clearSampleCache } from './clearSampleCache'
import { fetchAndDownload } from '@/utils/file'
@ -352,6 +356,7 @@ export default {
BetaGammaExtrapolationModal,
BgLogViewer: BGLogViewer,
CompareFromDbModal,
CalibrationModal,
},
provide() {
@ -1028,6 +1033,11 @@ export default {
}
},
// beta
handleNewBetaEnergyCalib() {
this.$refs.newCalibrationModalRef.show()
},
//
async getColorConfig() {
try {
@ -1407,7 +1417,16 @@ export default {
if (this.isBeta) this.efficiencyCalibrationModalShow_beta = true
},
},
// beta
{
type: 'a-menu-item',
title: 'Energy Calibration',
show: this.isBeta,
handler: () => this.handleNewBetaEnergyCalib(),
},
{
// beta
type: 'a-menu-item',
title: 'Energy Calibration',
show: this.isBetaGamma,