feat: 增加谱切换时本地保存功能,修复extrapolation 和 Spectrum中的问题
This commit is contained in:
parent
ad19436f82
commit
0f0b3eac14
|
@ -1,6 +1,6 @@
|
|||
const sample = {
|
||||
state: {
|
||||
sampleList: []
|
||||
sampleList: [] // [{ inputFileName: String; data: Object; }]
|
||||
},
|
||||
mutations: {
|
||||
SET_SAMPLE_LIST: (state, sampleList) => {
|
||||
|
@ -8,12 +8,12 @@ const sample = {
|
|||
},
|
||||
|
||||
ADD_SAMPLE_DATA: (state, sampleData) => {
|
||||
const find = state.sampleList.find(item => item.inputFileName == sampleData.inputFileName)
|
||||
if(find) {
|
||||
find.data = sampleData.data
|
||||
} else {
|
||||
state.sampleList.push(sampleData)
|
||||
},
|
||||
|
||||
GET_SAMPLE_DATA: (state, inputFileName) => {
|
||||
const find = state.sampleList.find(item => item.inputFileName == inputFileName)
|
||||
return find
|
||||
}
|
||||
},
|
||||
|
||||
REMOVE_SAMPLE_DATA: (state, inputFileName) => {
|
||||
|
@ -24,6 +24,12 @@ const sample = {
|
|||
CLEAR_SAMPLE_DATA: () => {
|
||||
state.sampleList = []
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
GET_SAMPLE_DATA: ({ state }, inputFileName) => {
|
||||
const find = state.sampleList.find(item => item.inputFileName == inputFileName)
|
||||
return find ? find : null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -235,7 +235,7 @@ export default {
|
|||
async getSampleDetail() {
|
||||
this.spectraType = this.SampleType[0].value
|
||||
|
||||
const { dbName, sampleId } = this.sample
|
||||
const { dbName, sampleId, inputFileName } = this.sample
|
||||
try {
|
||||
this.isLoading = true
|
||||
this.cancelLastRequest()
|
||||
|
@ -251,11 +251,14 @@ export default {
|
|||
if (success) {
|
||||
this.sampleDetail = result
|
||||
this.changeChartByType('sample')
|
||||
this.$emit('getFiles', {
|
||||
detFileName: result.detBg.fileName,
|
||||
gasFileName: result.gasBg.fileName,
|
||||
qcFileName: (result.qc && result.qc.fileName) || '',
|
||||
this.emitGetFiles(result)
|
||||
|
||||
this.$store.commit('ADD_SAMPLE_DATA', {
|
||||
inputFileName,
|
||||
data: result,
|
||||
from: 'db'
|
||||
})
|
||||
|
||||
} else {
|
||||
this.$message.error(message)
|
||||
}
|
||||
|
@ -265,6 +268,15 @@ export default {
|
|||
this.isLoading = false
|
||||
}
|
||||
},
|
||||
|
||||
emitGetFiles(result) {
|
||||
this.$emit('getFiles', {
|
||||
detFileName: result.detBg.fileName,
|
||||
gasFileName: result.gasBg.fileName,
|
||||
qcFileName: result.qc ? result.qc.fileName : ''
|
||||
})
|
||||
},
|
||||
|
||||
async getSampleDetail_file() {
|
||||
this.spectraType = this.SampleType[0].value
|
||||
let params = {
|
||||
|
@ -285,6 +297,12 @@ export default {
|
|||
if (success) {
|
||||
this.sampleDetail = result
|
||||
this.changeChartByType('sample')
|
||||
|
||||
this.$store.commit('ADD_SAMPLE_DATA', {
|
||||
inputFileName,
|
||||
data: result,
|
||||
from: 'file'
|
||||
})
|
||||
this.isLoading = false
|
||||
} else {
|
||||
this.$message.error(message)
|
||||
|
@ -435,13 +453,24 @@ export default {
|
|||
},
|
||||
watch: {
|
||||
sample: {
|
||||
handler(newVal, oldVal) {
|
||||
async handler(newVal, oldVal) {
|
||||
this.resultDisplay = []
|
||||
const sampleData = await this.$store.dispatch('GET_SAMPLE_DATA', newVal.inputFileName)
|
||||
if(sampleData) {
|
||||
const { data, from } = sampleData
|
||||
this.sampleDetail = data
|
||||
this.changeChartByType('sample')
|
||||
if(from == 'db') {
|
||||
this.sampleDetail = data
|
||||
this.emitGetFiles(data)
|
||||
}
|
||||
} else {
|
||||
if (newVal.sampleId) {
|
||||
this.getSampleDetail()
|
||||
} else {
|
||||
this.getSampleDetail_file()
|
||||
}
|
||||
}
|
||||
},
|
||||
immediate: true,
|
||||
deep: true,
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { deleteAction } from '@/api/manage'
|
||||
import store from '@/store'
|
||||
/**
|
||||
* 发起请求清理后端对sample的缓存
|
||||
* @param {Array<any>} sampleList
|
||||
|
@ -13,5 +14,6 @@ export const clearSampleCache = (sampleList) => {
|
|||
params = { sampleFileName , qcFileName }
|
||||
}
|
||||
deleteAction(url, params)
|
||||
store.commit('REMOVE_SAMPLE_DATA', fileName)
|
||||
})
|
||||
}
|
|
@ -706,7 +706,7 @@ export default {
|
|||
return
|
||||
}
|
||||
|
||||
const { sampleId, dbName, sampleFileName, detFileName } = this.sampleData
|
||||
const { sampleId, dbName, inputFileName: sampleFileName, detFileName } = this.newSampleData
|
||||
try {
|
||||
const params = {
|
||||
sampleId,
|
||||
|
|
|
@ -3,16 +3,16 @@
|
|||
<a-spin :spinning="isLoading">
|
||||
<a-tabs :animated="false" @change="handleTabChange">
|
||||
<a-tab-pane tab="Sample Spectrum" :key="1">
|
||||
<pre>{{ content.sample.join('\n') }}</pre>
|
||||
<pre>{{ content.sample && content.sample.join('\n') }}</pre>
|
||||
</a-tab-pane>
|
||||
<a-tab-pane tab="GasBg Spectrum" :key="2">
|
||||
<pre>{{ content.gasBg.join('\n') }}</pre>
|
||||
<pre>{{ content.gasBg && content.gasBg.join('\n') }}</pre>
|
||||
</a-tab-pane>
|
||||
<a-tab-pane tab="DetBg Spectrum" :key="3">
|
||||
<pre>{{ content.detBg.join('\n') }}</pre>
|
||||
<pre>{{ content.detBg && content.detBg.join('\n') }}</pre>
|
||||
</a-tab-pane>
|
||||
<a-tab-pane tab="QC Spectrum" :key="4">
|
||||
<pre>{{ content.qc.join('\n') }}</pre>
|
||||
<pre>{{ content.qc && content.qc.join('\n') }}</pre>
|
||||
</a-tab-pane>
|
||||
</a-tabs>
|
||||
</a-spin>
|
||||
|
@ -28,13 +28,9 @@
|
|||
<script>
|
||||
import ModalMixin from '@/mixins/ModalMixin'
|
||||
import { getAction } from '../../../../../api/manage'
|
||||
import SampleDataMixin from '@/views/spectrumAnalysis/SampleDataMixin'
|
||||
export default {
|
||||
mixins: [ModalMixin],
|
||||
props: {
|
||||
sampleId: {
|
||||
type: Number
|
||||
}
|
||||
},
|
||||
mixins: [ModalMixin, SampleDataMixin],
|
||||
data() {
|
||||
return {
|
||||
content: {
|
||||
|
@ -52,13 +48,21 @@ export default {
|
|||
async getContent() {
|
||||
try {
|
||||
this.isLoading = true
|
||||
const res = await getAction('/spectrumAnalysis/viewSpectrum', {
|
||||
sampleId: this.sampleId
|
||||
const { sampleId, dbName, sampleFileName, gasFileName, detFileName, qcFileName } = this.newSampleData
|
||||
const { success, result, message } = await getAction('/spectrumAnalysis/viewSpectrum', {
|
||||
sampleId,
|
||||
dbName,
|
||||
sampleFileName,
|
||||
gasFileName,
|
||||
detFileName,
|
||||
qcFileName
|
||||
})
|
||||
if (res.success) {
|
||||
this.content = res.result
|
||||
if (success) {
|
||||
if(result) {
|
||||
this.content = result
|
||||
}
|
||||
} else {
|
||||
this.$message.error(res.message)
|
||||
this.$message.error(message)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
|
@ -68,9 +72,7 @@ export default {
|
|||
},
|
||||
|
||||
beforeModalOpen() {
|
||||
if (this.sampleId) {
|
||||
this.getContent()
|
||||
}
|
||||
},
|
||||
handleTabChange(key) {
|
||||
this.currTab = key
|
||||
|
|
|
@ -140,7 +140,6 @@ import { ACCESS_TOKEN } from '@/store/mutation-types'
|
|||
import StripModal from './components/Modals/StripModal.vue'
|
||||
import { FilePicker } from '@/utils/FilePicker'
|
||||
import { zipFile } from '@/utils/file'
|
||||
import { mapMutations } from 'vuex'
|
||||
|
||||
export default {
|
||||
props: {
|
||||
|
@ -532,6 +531,14 @@ export default {
|
|||
},
|
||||
|
||||
dataProcess(result, flag) {
|
||||
const { inputFileName } = this.sample
|
||||
|
||||
this.$store.commit('ADD_SAMPLE_DATA', {
|
||||
inputFileName,
|
||||
data: result,
|
||||
from: flag,
|
||||
})
|
||||
|
||||
this.isLoading = false
|
||||
|
||||
const {
|
||||
|
@ -1576,6 +1583,9 @@ export default {
|
|||
this.option.xAxis.name = 'Channel'
|
||||
this.option.yAxis.type = 'log'
|
||||
this.thumbnailOption.yAxis.type = 'log'
|
||||
|
||||
this.option.series[0].markLine.data[0].xAxis = -1
|
||||
this.setChartBottomTitle(0, 0, 0)
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -1697,8 +1707,6 @@ export default {
|
|||
const arrFunc = isList ? Array.prototype.filter : Array.prototype.find
|
||||
return arrFunc.call(allData, (item) => item.name == name && item.group == group) || {}
|
||||
},
|
||||
|
||||
...mapMutations(['ADD_SAMPLE_DATA', 'GET_SAMPLE_DATA']),
|
||||
},
|
||||
watch: {
|
||||
currStep: {
|
||||
|
@ -1711,13 +1719,13 @@ export default {
|
|||
immediate: true,
|
||||
},
|
||||
sample: {
|
||||
handler(newVal, oldVal) {
|
||||
async handler(newVal, oldVal) {
|
||||
console.log('newValnewVal', newVal)
|
||||
this.graphAssistance.axisType = 'Channel'
|
||||
this.handleResetState()
|
||||
const sampleData = this.GET_SAMPLE_DATA(newVal.inputFileName)
|
||||
const sampleData = await this.$store.dispatch('GET_SAMPLE_DATA', newVal.inputFileName)
|
||||
if (sampleData) {
|
||||
console.log('%c [ ]-1521', 'font-size:13px; background:pink; color:#bf2c9f;', sampleData)
|
||||
this.dataProcess(sampleData.data, sampleData.from)
|
||||
} else {
|
||||
if (newVal.sampleId) {
|
||||
this.getSampleDetail()
|
||||
|
|
|
@ -174,7 +174,7 @@
|
|||
<!-- Beta-Gamma 的 Extrapolation 弹窗结束 -->
|
||||
|
||||
<!-- Beta-Gamma 的 Spectrum 弹窗 -->
|
||||
<beta-gamma-spectrum-modal v-model="betaGammaSpectrumModalVisible" :sampleId="this.sampleData.sampleId" />
|
||||
<beta-gamma-spectrum-modal v-model="betaGammaSpectrumModalVisible" />
|
||||
<!-- Beta-Gamma 的 Spectrum 弹窗 结束 -->
|
||||
|
||||
<!-- Beta-Gamma 的 Sample Infomation 弹窗 -->
|
||||
|
@ -415,10 +415,10 @@ export default {
|
|||
},
|
||||
getStationName(arg, val, flag) {
|
||||
arg.forEach((item) => {
|
||||
item.conc = item.conc.toFixed(6)
|
||||
item.concErr = item.concErr.toFixed(6)
|
||||
item.lc = item.lc.toFixed(6)
|
||||
item.mdc = item.mdc.toFixed(6)
|
||||
item.conc = Number(item.conc).toFixed(6)
|
||||
item.concErr = Number(item.concErr).toFixed(6)
|
||||
item.lc = Number(item.lc).toFixed(6)
|
||||
item.mdc = Number(item.mdc).toFixed(6)
|
||||
})
|
||||
this.resultDisplayFlag = arg
|
||||
this.params_toDB.stationName = val
|
||||
|
|
Loading…
Reference in New Issue
Block a user