WIP: 性能优化

This commit is contained in:
Xu Zhimeng 2024-04-11 09:58:36 +08:00
parent 656a02c1ec
commit e9c693ee51
9 changed files with 125 additions and 74 deletions

View File

@ -6,7 +6,6 @@ import user from './modules/user'
import permission from './modules/permission'
import enhance from './modules/enhance'
import online from './modules/online'
import sample from './modules/sample'
import getters from './getters'
Vue.use(Vuex)
@ -18,7 +17,6 @@ export default new Vuex.Store({
permission,
enhance,
online,
sample
},
state: {

View File

@ -1,52 +0,0 @@
const sample = {
state: Object.freeze({
sampleList: [] // [{ inputFileName: String; data: Object; }]
}),
mutations: {
SET_SAMPLE_LIST: (state, sampleList) => {
state.sampleList = sampleList
},
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)
}
},
UPDATE_SAMPLE_DATA: (state, { inputFileName, key, data }) => {
const find = state.sampleList.find(item => item.inputFileName == inputFileName)
if (find) {
find.data[key] = data
}
},
UPDATE_SAMPLE_DATA_ANALY: (state, { inputFileName, data }) => {
const find = state.sampleList.find(item => item.inputFileName == inputFileName)
if (find) {
data.DetailedInformation = find.data.DetailedInformation
find.data = data
}
},
REMOVE_SAMPLE_DATA: (state, inputFileName) => {
const findIndex = state.sampleList.findIndex(item => item.inputFileName == inputFileName)
if(-1 !== findIndex) {
state.sampleList.splice(findIndex, 1)
}
},
CLEAR_SAMPLE_DATA: (state) => {
state.sampleList = []
}
},
actions: {
GET_SAMPLE_DATA: ({ state }, inputFileName) => {
const find = state.sampleList.find(item => item.inputFileName == inputFileName)
return find ? find : null
}
}
}
export default sample

84
src/utils/SampleStore.js Normal file
View File

@ -0,0 +1,84 @@
// 所有缓存的谱
let sampleList = []
/**
* 重新设置缓存的谱
* @param {Array} list
*/
const setSampleList = list => {
sampleList = list
}
/**
* 缓存一条谱数据
* @param {*} sampleData
*/
const addSampleData = sampleData => {
const find = sampleList.find(item => item.inputFileName == sampleData.inputFileName)
if (find) {
find.data = sampleData.data
} else {
sampleList.push(sampleData)
}
}
/**
* 更新谱数据
* @param {{ inputFileName: string; key: string; data: any; }} param0
*/
const updateSampleData = ({ inputFileName, key, data }) => {
const find = sampleList.find(item => item.inputFileName == inputFileName)
if (find) {
find.data[key] = data
}
}
/**
* 移除谱数据
* @param {string} inputFileName
*/
const removeSampleData = inputFileName => {
const findIndex = sampleList.findIndex(item => item.inputFileName == inputFileName)
if (-1 !== findIndex) {
sampleList.splice(findIndex, 1)
}
}
/**
* 更新分析数据
* @param {{ inputFileName: string; data: any; }} param0
*/
const updateSampleDataAnaly = ({ inputFileName, data }) => {
const find = sampleList.find(item => item.inputFileName == inputFileName)
if (find) {
data.DetailedInformation = find.data.DetailedInformation
find.data = data
}
}
/**
* 清理缓存列表
*/
const clearSampleData = () => {
sampleList = []
}
/**
* 根据文件名获取谱
* @param {string} inputFileName
*/
const getSampleData = inputFileName => {
const find = sampleList.find(item => item.inputFileName == inputFileName)
return find ? find : null
}
export {
sampleList,
setSampleList,
addSampleData,
updateSampleData,
removeSampleData,
updateSampleDataAnaly,
clearSampleData,
getSampleData
}

View File

@ -121,6 +121,7 @@
</template>
<script>
import { addSampleData, getSampleData, sampleList, setSampleList, updateSampleData } from '@/utils/SampleStore'
import { getAction, postAction } from '../../api/manage'
import BetaGammaChartContainer from './components/BetaGammaChartContainer.vue'
import BetaGammaSpectrumChart from './components/BetaGammaSpectrumChart.vue'
@ -323,10 +324,11 @@ export default {
this.changeChartByType('sample')
this.emitGetFiles(result)
this.$store.commit('ADD_SAMPLE_DATA', {
addSampleData({
inputFileName,
data: result,
from: 'db',
type: 'beta',
})
} else {
this.$message.error(message)
@ -369,11 +371,13 @@ export default {
this.sampleDetail = result
this.changeChartByType('sample')
this.$store.commit('ADD_SAMPLE_DATA', {
addSampleData({
inputFileName: this.sample.sampleFileName,
data: result,
from: 'file',
type: 'beta',
})
this.isLoading = false
} else {
this.$message.error(message)
@ -568,6 +572,7 @@ export default {
}
})
},
//
getAnalyzeAllSpectrum() {
let params = {
dbNames: [this.sample.dbName],
@ -588,13 +593,24 @@ export default {
item.lc = parseFloat(item.lc.toPrecision(6))
item.mdc = parseFloat(item.mdc.toPrecision(6))
})
this.$emit('reAnalyAll', true, res.result.XeData)
this.$emit('reAnalyAll', res.result.savedAnalysisResult, res.result.XeData)
//
this.removeOtherBetaSamples()
} else {
this.$message.warning(res.message)
}
})
},
// beta
removeOtherBetaSamples() {
const filterList = sampleList.filter(
(item) => item.type !== 'beta' || item.inputFileName == this.sample.inputFileName
)
setSampleList(filterList)
},
//
handleZoom(nuclideName) {
let ROI_nums = []
@ -655,7 +671,7 @@ export default {
sample: {
async handler(newVal, oldVal) {
this.resultDisplay = []
const sampleData = await this.$store.dispatch('GET_SAMPLE_DATA', newVal.inputFileName)
const sampleData = getSampleData(newVal.inputFileName)
if (sampleData) {
this.cancelLastRequest()
this.isLoading = false
@ -673,6 +689,7 @@ export default {
this.getSampleDetail_file()
}
}
await this.$nextTick()
this.$refs.betaGammaChartRef.handleUnzoom()
},
immediate: true,
@ -683,7 +700,7 @@ export default {
// this.currResultDisplay = newVal.XeData
this.resultDisplay = cloneDeep(newVal.XeData) || []
this.sortResultDisplay()
this.$store.commit('UPDATE_SAMPLE_DATA', {
updateSampleData({
inputFileName: this.sample.inputFileName,
key: 'XeData',
data: newVal.XeData,

View File

@ -1,5 +1,5 @@
import { deleteAction } from '@/api/manage'
import store from '@/store'
import { removeSampleData } from '@/utils/SampleStore'
import Vue from 'vue'
/**
@ -16,7 +16,7 @@ export const clearSampleCache = sampleList => {
params = { sampleFileName: fileName }
}
deleteAction(url, params)
store.commit('REMOVE_SAMPLE_DATA', fileName)
removeSampleData(fileName)
Vue.ls.remove(`CALIBRATION_GAMMA_${fileName}`)
Vue.ls.remove(`CALIBRATION_BETA_${fileName}`)
})

View File

@ -228,6 +228,7 @@ import { updateBaseLine } from '@/utils/WasmHelper'
import RectList from './components/RectList.vue'
import { isNullOrUndefined } from '@/utils/util'
import { findNearPeak, getLineData, transformPointListData } from '@/utils/sampleHelper'
import { getSampleData } from '@/utils/SampleStore'
//
const initialOption = {
@ -514,7 +515,7 @@ export default {
}
},
methods: {
async getInfo() {
getInfo() {
this.option.series = []
this.thumbnailOption.series = []
this.list = []
@ -522,7 +523,7 @@ export default {
const { inputFileName } = this.sampleData
const currSampleDetailInfo = await this.$store.dispatch('GET_SAMPLE_DATA', inputFileName)
const currSampleDetailInfo = getSampleData(inputFileName)
const {
data: { allData, shadowChannelChart, shapeChannelData, peak, BaseCtrls, barChart },
} = currSampleDetailInfo
@ -583,8 +584,8 @@ export default {
this.handleResetChart()
},
async beforeModalOpen() {
await this.getInfo()
beforeModalOpen() {
this.getInfo()
this.reset()
},

View File

@ -50,6 +50,7 @@ import { postAction } from '@/api/manage'
import BetaDetectorCalibration from './components/BetaDetectorCalibration.vue'
import GammaDetectorCalibration from './components/GammaDetectorCalibration.vue'
import TitleOverBorder from '@/views/spectrumAnalysis/components/TitleOverBorder.vue'
import { removeSampleData } from '@/utils/SampleStore'
export default {
components: { BetaDetectorCalibration, GammaDetectorCalibration, TitleOverBorder },
mixins: [ModalMixin, SampleDataMixin],
@ -179,8 +180,7 @@ export default {
//
clearSameStationCache(sampleList) {
sampleList.forEach(({ inputFileName }) => {
console.log('inputFileName>>' + inputFileName)
this.$store.commit('REMOVE_SAMPLE_DATA', inputFileName)
removeSampleData(inputFileName)
})
},
// Calibration 20231115xiao

View File

@ -136,6 +136,7 @@ import { readFile, zipFile } from '@/utils/file'
import { findNearPeak } from '@/utils/sampleHelper'
import { add, subtract } from 'xe-utils/methods'
import { PHDParser, isSample, getSampleTypeIdentify } from '@/utils/phdHelper'
import { addSampleData, getSampleData } from '@/utils/SampleStore'
export default {
props: {
@ -579,7 +580,7 @@ export default {
dataProcess(result, flag) {
const { inputFileName } = this.sample
this.$store.commit('ADD_SAMPLE_DATA', {
addSampleData({
inputFileName,
data: result,
from: flag,
@ -2057,11 +2058,11 @@ export default {
immediate: true,
},
sample: {
async handler(newVal, oldVal) {
handler(newVal, oldVal) {
console.log('newValnewVal', newVal)
this.graphAssistance.axisType = 'Channel'
this.handleResetState()
const sampleData = await this.$store.dispatch('GET_SAMPLE_DATA', newVal.inputFileName)
const sampleData = getSampleData(newVal.inputFileName)
if (sampleData) {
this.cancelLastRequest()
this.isLoading = false

View File

@ -281,6 +281,7 @@ import BGLogViewer from './components/Modals/BetaGammaModals/BGLogViewer.vue'
import { saveAs } from 'file-saver'
import CompareFromDbModal from './components/Modals/CompareFromDBModal.vue'
import { clearSampleData, updateSampleDataAnaly } from '@/utils/SampleStore'
//
const ANALYZE_TYPE = {
@ -467,7 +468,7 @@ export default {
destroyed() {
this.$bus.$off('reanalyse', this.handleReanalyse)
this.$store.commit('CLEAR_SAMPLE_DATA')
clearSampleData()
this.handleCleanAll()
window.removeEventListener('beforeunload', this.handleCleanAll)
},
@ -478,8 +479,10 @@ export default {
this.params_toDB.savedAnalysisResult = flag
this.resultDisplayFlag = val
},
getReAnalyAll(val) {
getReAnalyAll(flag, val) {
this.isReAnalyed_beta = flag
this.resultDisplayFlag = val
this.params_toDB.savedAnalysisResult = flag
},
handleReAnalyed(val) {
this.isReAnalyed_gamma = val
@ -841,7 +844,6 @@ export default {
* @param { 'all' | 'current' } type
*/
handleSavePHDToFile(type) {
console.log('%c [ savePHDToFile ]-162', 'font-size:13px; background:pink; color:#bf2c9f;', type)
if (this.isGamma) {
if (type == 'current') {
let params = {
@ -901,7 +903,7 @@ export default {
try {
const { success, result, message } = await postAction(`/gamma/Reprocessing?fileName=${fileNames[0]}`)
if (success) {
this.$store.commit('UPDATE_SAMPLE_DATA_ANALY', {
updateSampleDataAnaly({
inputFileName: fileNames[0],
data: result,
})