增加保存自定义台站到数据库功能

This commit is contained in:
Xu Zhimeng 2024-07-31 16:05:50 +08:00
parent d0a75dabc5
commit 2e4a58c95a
3 changed files with 111 additions and 45 deletions

View File

@ -594,6 +594,28 @@ export default {
this.$refs.betaModalRef.open(currSampleDetail.bSpectrum, currSampleDetail.betaEnergyData) this.$refs.betaModalRef.open(currSampleDetail.bSpectrum, currSampleDetail.betaEnergyData)
} }
}, },
// db
async saveCurrentToDB() {
if (!this.ROIAnalyzeLists || !this.ROIAnalyzeLists.length) {
throw new Error('Please Analyse Spectrum First')
}
const { inputFileName: fileName } = this.sample
const { success, message, result } = await getAction('/selfStation/saveToDB', {
fileName,
})
if (success) {
this.$message.success('Save Success')
// DetailedInfomation
updateSampleData({
inputFileName: fileName,
key: 'DetailedInformation',
data: [...result.DetailedInformation],
})
} else {
this.$message.error(message)
}
},
}, },
} }
</script> </script>

View File

@ -600,6 +600,7 @@ export default {
position: absolute; position: absolute;
border: 1px solid transparent; border: 1px solid transparent;
overflow: visible; overflow: visible;
will-change: left, width;
&-left, &-left,
&-right { &-right {

View File

@ -825,6 +825,8 @@ export default {
* @param { 'all' | 'current' } type * @param { 'all' | 'current' } type
*/ */
async handleSaveResultsToDB(type) { async handleSaveResultsToDB(type) {
// gamma
if (this.isGamma) {
if (this.isReAnalyed_gamma) { if (this.isReAnalyed_gamma) {
this.isSaving = true this.isSaving = true
if (type == 'current') { if (type == 'current') {
@ -869,6 +871,31 @@ export default {
} else { } else {
this.$message.warn('Please Analyse Spectrum First') this.$message.warn('Please Analyse Spectrum First')
} }
}
// beta
else if (this.isBeta) {
this.isSaving = true
const hideLoading = this.$message.loading('Saving...', 0)
try {
//
await this.$refs.betaAnalysisRef.saveCurrentToDB()
if (type == 'all') {
const selfSampleLists = this.sampleList.filter(
({ sampleType, inputFileName }) => sampleType == 'C' && inputFileName !== this.sampleData.inputFileName
)
const selfSampleInputFileNames = selfSampleLists.map((item) => item.inputFileName)
for (const fileName of selfSampleInputFileNames) {
await this.saveSelfStationToDBRequest(fileName)
}
}
} catch (error) {
this.$message.error(error && (error.message || error))
} finally {
hideLoading()
this.isSaving = false
}
}
}, },
// gamma // gamma
@ -893,6 +920,25 @@ export default {
console.error(error) console.error(error)
} }
}, },
//
async saveSelfStationToDBRequest(fileName) {
try {
const { result, success, message } = await getAction('/selfStation/saveToDB', { fileName })
if (success) {
// DetailedInfomation
// updateSampleData({
// inputFileName: fileName,
// key: 'DetailedInformation',
// data: [...result.DetailedInformation],
// })
} else {
this.$message.error(message)
}
} catch (error) {
console.error(error)
}
},
handleSaveResultsToDB_Cuurrent() { handleSaveResultsToDB_Cuurrent() {
// xeflag params_toDB // xeflag params_toDB
if (this.params_toDB.savedAnalysisResult) { if (this.params_toDB.savedAnalysisResult) {
@ -1055,7 +1101,6 @@ export default {
handleResize() { handleResize() {
this.$refs.gammaAnalysisRef && this.$refs.gammaAnalysisRef.resize() this.$refs.gammaAnalysisRef && this.$refs.gammaAnalysisRef.resize()
this.$refs.betaGammaAnalysisRef && this.$refs.betaGammaAnalysisRef.resize() this.$refs.betaGammaAnalysisRef && this.$refs.betaGammaAnalysisRef.resize()
this.$refs.betaAnalysisRef && this.$refs.betaAnalysisRef.resize()
}, },
// Beta-Gamma Energy Calibration // Beta-Gamma Energy Calibration
@ -1273,7 +1318,7 @@ export default {
children: [ children: [
{ {
type: 'MultiLevelMenu', type: 'MultiLevelMenu',
show: this.isBetaGamma || this.isGamma, show: this.isBetaGamma || this.isGamma || this.isBeta,
attrs: { attrs: {
children: [ children: [
{ {
@ -1282,20 +1327,18 @@ export default {
{ {
title: 'Save Txt', title: 'Save Txt',
key: 'saveTxt', key: 'saveTxt',
show: this.isBetaGamma,
}, },
{ {
title: 'Save Excel', title: 'Save Excel',
key: 'saveExcel', key: 'saveExcel',
show: this.isBetaGamma,
}, },
{ {
title: 'Save Html', title: 'Save Html',
key: 'saveHtml', key: 'saveHtml',
show: this.isBetaGamma,
}, },
], ],
key: 'resultsToFile', key: 'resultsToFile',
show: this.isBetaGamma,
}, },
{ {
title: 'Save Results to DB', title: 'Save Results to DB',
@ -1303,12 +1346,12 @@ export default {
{ {
title: 'Save Current', title: 'Save Current',
key: 'current', key: 'current',
show: this.isGamma, show: this.isGamma || this.isBeta,
}, },
{ {
title: 'Save All', title: 'Save All',
key: 'all', key: 'all',
show: this.isGamma, show: this.isGamma || this.isBeta,
}, },
], ],
key: 'resultsToDB', key: 'resultsToDB',