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

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)
}
},
// 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>

View File

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

View File

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