fix: 修改Save to Txt调的接口
This commit is contained in:
parent
8459081c5c
commit
88348f4f78
|
@ -255,6 +255,8 @@ import { clearSampleCache } from './clearSampleCache'
|
||||||
import { fetchAndDownload } from '@/utils/file'
|
import { fetchAndDownload } from '@/utils/file'
|
||||||
import BGLogViewer from './components/Modals/BetaGammaModals/BGLogViewer.vue'
|
import BGLogViewer from './components/Modals/BetaGammaModals/BGLogViewer.vue'
|
||||||
|
|
||||||
|
import { saveAs } from 'file-saver'
|
||||||
|
|
||||||
// 分析类型
|
// 分析类型
|
||||||
const ANALYZE_TYPE = {
|
const ANALYZE_TYPE = {
|
||||||
GAMMA: 'gammaAnalysis',
|
GAMMA: 'gammaAnalysis',
|
||||||
|
@ -586,34 +588,81 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.isBetaGamma) {
|
if (this.isBetaGamma) {
|
||||||
const url =
|
if(!this.isReAnalyed_beta) {
|
||||||
saveFormat == 'xls'
|
this.$message.warning('Please analyze the spectrum first!')
|
||||||
? '/spectrumAnalysis/saveToExcel'
|
this.isSaving = false
|
||||||
: saveFormat == 'txt'
|
|
||||||
? '/spectrumAnalysis/saveToTxt'
|
|
||||||
: saveFormat == 'html'
|
|
||||||
? '/spectrumAnalysis/saveToHTML'
|
|
||||||
: ''
|
|
||||||
if (!this.resultDisplayFlag) {
|
|
||||||
this.$message.warn('Please Analyse Spectrum First')
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if (saveFormat == 'txt') {
|
||||||
|
try {
|
||||||
|
const {
|
||||||
|
sampleId,
|
||||||
|
inputFileName: fileName,
|
||||||
|
dbName,
|
||||||
|
detFileName,
|
||||||
|
gasFileName,
|
||||||
|
qcFileName,
|
||||||
|
} = this.newSampleData
|
||||||
|
|
||||||
this.resultDisplayFlag.forEach((item) => {
|
const params = {
|
||||||
this.params_toDB[`${item.nuclideName.toLowerCase()}Flag`] = item.nidFlag
|
dbName,
|
||||||
})
|
sampleId,
|
||||||
|
sampleData: false,
|
||||||
|
gasBgData: false,
|
||||||
|
detBgData: false,
|
||||||
|
qcData: false,
|
||||||
|
sampleFileName: fileName,
|
||||||
|
gasFileName,
|
||||||
|
detFileName,
|
||||||
|
qcFileName,
|
||||||
|
}
|
||||||
|
const txtFileName = `${fileName.split('.')[0]}.txt`
|
||||||
|
const res = await postAction('/spectrumAnalysis/viewRRR', params)
|
||||||
|
if (typeof res == 'string') {
|
||||||
|
const data = new Blob([res], { type: 'text/plain;charset=utf-8' })
|
||||||
|
saveAs(data, txtFileName)
|
||||||
|
} else {
|
||||||
|
const { success, result, message } = res
|
||||||
|
if (success) {
|
||||||
|
const data = new Blob([result], { type: 'text/plain;charset=utf-8' })
|
||||||
|
saveAs(data, txtFileName)
|
||||||
|
} else {
|
||||||
|
this.$message.error(message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error)
|
||||||
|
} finally {
|
||||||
|
this.isSaving = false
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const url =
|
||||||
|
saveFormat == 'xls'
|
||||||
|
? '/spectrumAnalysis/saveToExcel'
|
||||||
|
: saveFormat == 'html'
|
||||||
|
? '/spectrumAnalysis/saveToHTML'
|
||||||
|
: ''
|
||||||
|
if (!this.resultDisplayFlag) {
|
||||||
|
this.$message.warn('Please Analyse Spectrum First')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
this.params_toDB.sampleFileName = this.newSampleData.inputFileName
|
this.resultDisplayFlag.forEach((item) => {
|
||||||
this.params_toDB.gasFileName = this.newSampleData.gasFileName
|
this.params_toDB[`${item.nuclideName.toLowerCase()}Flag`] = item.nidFlag
|
||||||
this.params_toDB.detFileName = this.newSampleData.detFileName
|
})
|
||||||
this.params_toDB.qcFileName = this.newSampleData.qcFileName
|
|
||||||
this.params_toDB.dbName = this.newSampleData.dbName
|
this.params_toDB.sampleFileName = this.newSampleData.inputFileName
|
||||||
try {
|
this.params_toDB.gasFileName = this.newSampleData.gasFileName
|
||||||
await fetchAndDownload(url, this.params_toDB)
|
this.params_toDB.detFileName = this.newSampleData.detFileName
|
||||||
} catch (error) {
|
this.params_toDB.qcFileName = this.newSampleData.qcFileName
|
||||||
console.error(error)
|
this.params_toDB.dbName = this.newSampleData.dbName
|
||||||
} finally {
|
try {
|
||||||
this.isSaving = false
|
await fetchAndDownload(url, this.params_toDB)
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error)
|
||||||
|
} finally {
|
||||||
|
this.isSaving = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue
Block a user