对接UpdateROI功能

This commit is contained in:
Xu Zhimeng 2024-07-24 17:45:45 +08:00
parent 93a2f3ed16
commit b214308e23
3 changed files with 87 additions and 42 deletions

View File

@ -34,7 +34,7 @@
/>
</a-input-group>
</div>
<div class="spectrum-analysis-sub-operators-button" @click="reDrawRectOri">Update</div>
<div class="spectrum-analysis-sub-operators-button" @click="handleUpdate">Update</div>
</div>
<!-- 二级交互栏结束 -->
@ -51,7 +51,6 @@
:histogramDataList="histogramDataList"
:boundary="boundaryList"
:isLoading.sync="isLoading"
@refreshRoi="refreshRoi"
@boundaryChange="handleBoundaryChange"
/>
</beta-gamma-chart-container>
@ -98,7 +97,7 @@ import RoiLimits from './components/RoiLimits/RoiLimits.vue'
import RoiParam from './components/RoiParam.vue'
import axios from 'axios'
import store from '@/store/'
import { getAction, postAction, deleteAction } from '../../api/manage'
import { getAction, postAction, putAction } from '../../api/manage'
import { addSampleData, getSampleData, updateSampleData } from '@/utils/SampleStore'
import { cloneDeep } from 'lodash'
@ -109,7 +108,11 @@ const SampleType = [
},
{
label: 'DetBg Data',
value: 'detBg',
value: 'det',
},
{
label: 'QC Data',
value: 'qc',
},
]
@ -204,6 +207,12 @@ export default {
key: 'ROIAnalyzeLists',
data: _result,
})
} else {
const arr = message.split('\n')
this.$warning({
title: 'Warning',
content: () => arr.map((text) => <div>{text}</div>),
})
}
let XeData = [
{
@ -317,11 +326,71 @@ export default {
this.resultDisplay = XeData
// this.$emit('reAnalyCurr', true, XeData)
},
refreshRoi(data) {
console.log('%c [ 刷新 ]-303', 'font-size:13px; background:pink; color:#bf2c9f;', data)
},
reDrawRectOri() {
//
// Update
async handleUpdate() {
const hasEmpty = this.roiParamList.some(
([startChannel, endChannel]) => (!startChannel && startChannel !== '0') || (!endChannel && endChannel !== '0')
)
if (hasEmpty) {
this.$message.warning('Channel cannot be null')
return
}
const hasNegative = this.roiParamList.some(([startChannel, endChannel]) => startChannel < 0 || endChannel < 0)
if (hasNegative) {
this.$message.warning('Channel cannot be negative')
return
}
try {
this.isLoading = true
const { inputFileName } = this.sample
const params = this.roiParamList.map(([startChannel, endChannel], index) => ({
startChannel,
endChannel,
roiNum: index + 1,
}))
const formData = new FormData()
formData.append('sampleFileName', inputFileName)
formData.append('roiParams', JSON.stringify(params))
const { success, result, message } = await putAction('/selfStation/updateROI', formData)
if (success) {
console.log('%c [ ]-353', 'font-size:13px; background:pink; color:#bf2c9f;', result)
const {
ROIOneList,
ROITwoList,
ROIThreeList,
ROIFourList,
ROIOneStart,
ROIOneStop,
ROITwoStart,
ROITwoStop,
ROIThreeStart,
ROIThreeStop,
ROIFourStart,
ROIFourStop,
} = result
this.ROILists = [ROIOneList, ROITwoList, ROIThreeList, ROIFourList]
this.boundaryList = [
[ROIOneStart, ROIOneStop],
[ROITwoStart, ROITwoStop],
[ROIThreeStart, ROIThreeStop],
[ROIFourStart, ROIFourStop],
]
} else {
this.isLoading = false
this.$message.error(message)
}
} catch (error) {
console.error(error)
} finally {
this.isLoading = false
}
},
// async handleDetalSelfStationCache() {
// const { inputFileName } = this.sample
@ -366,6 +435,12 @@ export default {
}
},
changeChartByType(val) {
const currSampleDetail = this.sampleDetail[this.spectraType]
if (!currSampleDetail) {
this.$message.warning(`No ${this.spectraType} spectrum file!`)
return
}
if (val == 'sample') this.currSpectrum = 'Sample'
if (val == 'detBg') this.currSpectrum = 'Det'
this.roiParamList = cloneDeep(InitialRoiParamList)
@ -388,7 +463,8 @@ export default {
ROIThreeStop,
ROIFourStart,
ROIFourStop,
} = this.sampleDetail[this.spectraType]
} = currSampleDetail
this.spectrumData = spectrumData
this.histogramDataList = histogramDataList
this.gammaEnergyData = gammaEnergyData

View File

@ -64,7 +64,6 @@
<script>
import CustomChart from '@/components/CustomChart/index.vue'
import { getXAxisAndYAxisByPosition, rangeNumber } from '@/utils/chartHelper.js'
import { putAction } from '../../../api/manage'
import SampleDataMixin from '../SampleDataMixin'
const buttons = ['Gamma', 'Beta']
// Beta-Gamma
@ -439,37 +438,6 @@ export default {
this.showROI = !this.showROI
this.reDrawRect()
},
// Update
async handleUpdate() {
this.$emit('update:isLoading', true)
const { inputFileName } = this.sampleData
try {
const { success, result, message } = await putAction(
`/selfStation/updateROI?sampleFileName=${inputFileName}&startChannel=${this.startChannel}&endChannel=${this.endChannel}&ROINum=1`
)
if (success) {
this.$emit('update:isLoading', false)
let obj = {}
for (const key in result) {
if (Object.hasOwnProperty.call(result, key)) {
const element = result[key]
if (key.includes('List')) {
obj.list = element
} else if (key.includes('Start')) {
obj.start = element
} else {
obj.stop = element
}
}
}
this.$emit('refreshRoi', obj)
} else {
this.$emit('update:isLoading', false)
}
} catch (error) {
console.error(error)
}
},
//
handleBorderMouseDown(boundaryItem, direction, index) {

View File

@ -159,6 +159,7 @@ export default {
},
created() {
this.option.tooltip.formatter = this.handleTooltipFormat
this.option.series[0].itemStyle.color = 'yellow'
this.$bus.$on('changeROILimitsYAxisType', this.changeYAxisType)
},
beforeDestroy() {