WIP: 性能优化
This commit is contained in:
parent
656a02c1ec
commit
e9c693ee51
|
@ -6,7 +6,6 @@ import user from './modules/user'
|
||||||
import permission from './modules/permission'
|
import permission from './modules/permission'
|
||||||
import enhance from './modules/enhance'
|
import enhance from './modules/enhance'
|
||||||
import online from './modules/online'
|
import online from './modules/online'
|
||||||
import sample from './modules/sample'
|
|
||||||
import getters from './getters'
|
import getters from './getters'
|
||||||
|
|
||||||
Vue.use(Vuex)
|
Vue.use(Vuex)
|
||||||
|
@ -18,7 +17,6 @@ export default new Vuex.Store({
|
||||||
permission,
|
permission,
|
||||||
enhance,
|
enhance,
|
||||||
online,
|
online,
|
||||||
sample
|
|
||||||
},
|
},
|
||||||
state: {
|
state: {
|
||||||
|
|
||||||
|
|
|
@ -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
84
src/utils/SampleStore.js
Normal 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
|
||||||
|
}
|
|
@ -121,6 +121,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { addSampleData, getSampleData, sampleList, setSampleList, updateSampleData } from '@/utils/SampleStore'
|
||||||
import { getAction, postAction } from '../../api/manage'
|
import { getAction, postAction } from '../../api/manage'
|
||||||
import BetaGammaChartContainer from './components/BetaGammaChartContainer.vue'
|
import BetaGammaChartContainer from './components/BetaGammaChartContainer.vue'
|
||||||
import BetaGammaSpectrumChart from './components/BetaGammaSpectrumChart.vue'
|
import BetaGammaSpectrumChart from './components/BetaGammaSpectrumChart.vue'
|
||||||
|
@ -323,10 +324,11 @@ export default {
|
||||||
this.changeChartByType('sample')
|
this.changeChartByType('sample')
|
||||||
this.emitGetFiles(result)
|
this.emitGetFiles(result)
|
||||||
|
|
||||||
this.$store.commit('ADD_SAMPLE_DATA', {
|
addSampleData({
|
||||||
inputFileName,
|
inputFileName,
|
||||||
data: result,
|
data: result,
|
||||||
from: 'db',
|
from: 'db',
|
||||||
|
type: 'beta',
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
this.$message.error(message)
|
this.$message.error(message)
|
||||||
|
@ -369,11 +371,13 @@ export default {
|
||||||
this.sampleDetail = result
|
this.sampleDetail = result
|
||||||
this.changeChartByType('sample')
|
this.changeChartByType('sample')
|
||||||
|
|
||||||
this.$store.commit('ADD_SAMPLE_DATA', {
|
addSampleData({
|
||||||
inputFileName: this.sample.sampleFileName,
|
inputFileName: this.sample.sampleFileName,
|
||||||
data: result,
|
data: result,
|
||||||
from: 'file',
|
from: 'file',
|
||||||
|
type: 'beta',
|
||||||
})
|
})
|
||||||
|
|
||||||
this.isLoading = false
|
this.isLoading = false
|
||||||
} else {
|
} else {
|
||||||
this.$message.error(message)
|
this.$message.error(message)
|
||||||
|
@ -568,6 +572,7 @@ export default {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
// 分析全部
|
||||||
getAnalyzeAllSpectrum() {
|
getAnalyzeAllSpectrum() {
|
||||||
let params = {
|
let params = {
|
||||||
dbNames: [this.sample.dbName],
|
dbNames: [this.sample.dbName],
|
||||||
|
@ -588,13 +593,24 @@ export default {
|
||||||
item.lc = parseFloat(item.lc.toPrecision(6))
|
item.lc = parseFloat(item.lc.toPrecision(6))
|
||||||
item.mdc = parseFloat(item.mdc.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 {
|
} else {
|
||||||
this.$message.warning(res.message)
|
this.$message.warning(res.message)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// 移除其他的beta缓存
|
||||||
|
removeOtherBetaSamples() {
|
||||||
|
const filterList = sampleList.filter(
|
||||||
|
(item) => item.type !== 'beta' || item.inputFileName == this.sample.inputFileName
|
||||||
|
)
|
||||||
|
setSampleList(filterList)
|
||||||
|
},
|
||||||
|
|
||||||
// 右下角放大镜
|
// 右下角放大镜
|
||||||
handleZoom(nuclideName) {
|
handleZoom(nuclideName) {
|
||||||
let ROI_nums = []
|
let ROI_nums = []
|
||||||
|
@ -655,7 +671,7 @@ export default {
|
||||||
sample: {
|
sample: {
|
||||||
async handler(newVal, oldVal) {
|
async handler(newVal, oldVal) {
|
||||||
this.resultDisplay = []
|
this.resultDisplay = []
|
||||||
const sampleData = await this.$store.dispatch('GET_SAMPLE_DATA', newVal.inputFileName)
|
const sampleData = getSampleData(newVal.inputFileName)
|
||||||
if (sampleData) {
|
if (sampleData) {
|
||||||
this.cancelLastRequest()
|
this.cancelLastRequest()
|
||||||
this.isLoading = false
|
this.isLoading = false
|
||||||
|
@ -673,6 +689,7 @@ export default {
|
||||||
this.getSampleDetail_file()
|
this.getSampleDetail_file()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
await this.$nextTick()
|
||||||
this.$refs.betaGammaChartRef.handleUnzoom()
|
this.$refs.betaGammaChartRef.handleUnzoom()
|
||||||
},
|
},
|
||||||
immediate: true,
|
immediate: true,
|
||||||
|
@ -683,7 +700,7 @@ export default {
|
||||||
// this.currResultDisplay = newVal.XeData
|
// this.currResultDisplay = newVal.XeData
|
||||||
this.resultDisplay = cloneDeep(newVal.XeData) || []
|
this.resultDisplay = cloneDeep(newVal.XeData) || []
|
||||||
this.sortResultDisplay()
|
this.sortResultDisplay()
|
||||||
this.$store.commit('UPDATE_SAMPLE_DATA', {
|
updateSampleData({
|
||||||
inputFileName: this.sample.inputFileName,
|
inputFileName: this.sample.inputFileName,
|
||||||
key: 'XeData',
|
key: 'XeData',
|
||||||
data: newVal.XeData,
|
data: newVal.XeData,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { deleteAction } from '@/api/manage'
|
import { deleteAction } from '@/api/manage'
|
||||||
import store from '@/store'
|
import { removeSampleData } from '@/utils/SampleStore'
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,7 +16,7 @@ export const clearSampleCache = sampleList => {
|
||||||
params = { sampleFileName: fileName }
|
params = { sampleFileName: fileName }
|
||||||
}
|
}
|
||||||
deleteAction(url, params)
|
deleteAction(url, params)
|
||||||
store.commit('REMOVE_SAMPLE_DATA', fileName)
|
removeSampleData(fileName)
|
||||||
Vue.ls.remove(`CALIBRATION_GAMMA_${fileName}`)
|
Vue.ls.remove(`CALIBRATION_GAMMA_${fileName}`)
|
||||||
Vue.ls.remove(`CALIBRATION_BETA_${fileName}`)
|
Vue.ls.remove(`CALIBRATION_BETA_${fileName}`)
|
||||||
})
|
})
|
||||||
|
|
|
@ -228,6 +228,7 @@ import { updateBaseLine } from '@/utils/WasmHelper'
|
||||||
import RectList from './components/RectList.vue'
|
import RectList from './components/RectList.vue'
|
||||||
import { isNullOrUndefined } from '@/utils/util'
|
import { isNullOrUndefined } from '@/utils/util'
|
||||||
import { findNearPeak, getLineData, transformPointListData } from '@/utils/sampleHelper'
|
import { findNearPeak, getLineData, transformPointListData } from '@/utils/sampleHelper'
|
||||||
|
import { getSampleData } from '@/utils/SampleStore'
|
||||||
|
|
||||||
// 初始配置
|
// 初始配置
|
||||||
const initialOption = {
|
const initialOption = {
|
||||||
|
@ -514,7 +515,7 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async getInfo() {
|
getInfo() {
|
||||||
this.option.series = []
|
this.option.series = []
|
||||||
this.thumbnailOption.series = []
|
this.thumbnailOption.series = []
|
||||||
this.list = []
|
this.list = []
|
||||||
|
@ -522,7 +523,7 @@ export default {
|
||||||
|
|
||||||
const { inputFileName } = this.sampleData
|
const { inputFileName } = this.sampleData
|
||||||
|
|
||||||
const currSampleDetailInfo = await this.$store.dispatch('GET_SAMPLE_DATA', inputFileName)
|
const currSampleDetailInfo = getSampleData(inputFileName)
|
||||||
const {
|
const {
|
||||||
data: { allData, shadowChannelChart, shapeChannelData, peak, BaseCtrls, barChart },
|
data: { allData, shadowChannelChart, shapeChannelData, peak, BaseCtrls, barChart },
|
||||||
} = currSampleDetailInfo
|
} = currSampleDetailInfo
|
||||||
|
@ -583,8 +584,8 @@ export default {
|
||||||
this.handleResetChart()
|
this.handleResetChart()
|
||||||
},
|
},
|
||||||
|
|
||||||
async beforeModalOpen() {
|
beforeModalOpen() {
|
||||||
await this.getInfo()
|
this.getInfo()
|
||||||
this.reset()
|
this.reset()
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,7 @@ import { postAction } from '@/api/manage'
|
||||||
import BetaDetectorCalibration from './components/BetaDetectorCalibration.vue'
|
import BetaDetectorCalibration from './components/BetaDetectorCalibration.vue'
|
||||||
import GammaDetectorCalibration from './components/GammaDetectorCalibration.vue'
|
import GammaDetectorCalibration from './components/GammaDetectorCalibration.vue'
|
||||||
import TitleOverBorder from '@/views/spectrumAnalysis/components/TitleOverBorder.vue'
|
import TitleOverBorder from '@/views/spectrumAnalysis/components/TitleOverBorder.vue'
|
||||||
|
import { removeSampleData } from '@/utils/SampleStore'
|
||||||
export default {
|
export default {
|
||||||
components: { BetaDetectorCalibration, GammaDetectorCalibration, TitleOverBorder },
|
components: { BetaDetectorCalibration, GammaDetectorCalibration, TitleOverBorder },
|
||||||
mixins: [ModalMixin, SampleDataMixin],
|
mixins: [ModalMixin, SampleDataMixin],
|
||||||
|
@ -179,8 +180,7 @@ export default {
|
||||||
// 清理相同台站的缓存
|
// 清理相同台站的缓存
|
||||||
clearSameStationCache(sampleList) {
|
clearSameStationCache(sampleList) {
|
||||||
sampleList.forEach(({ inputFileName }) => {
|
sampleList.forEach(({ inputFileName }) => {
|
||||||
console.log('inputFileName>>' + inputFileName)
|
removeSampleData(inputFileName)
|
||||||
this.$store.commit('REMOVE_SAMPLE_DATA', inputFileName)
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
// 相同台站能谱缓存一样的Calibration数据 20231115:xiao
|
// 相同台站能谱缓存一样的Calibration数据 20231115:xiao
|
||||||
|
|
|
@ -136,6 +136,7 @@ import { readFile, zipFile } from '@/utils/file'
|
||||||
import { findNearPeak } from '@/utils/sampleHelper'
|
import { findNearPeak } from '@/utils/sampleHelper'
|
||||||
import { add, subtract } from 'xe-utils/methods'
|
import { add, subtract } from 'xe-utils/methods'
|
||||||
import { PHDParser, isSample, getSampleTypeIdentify } from '@/utils/phdHelper'
|
import { PHDParser, isSample, getSampleTypeIdentify } from '@/utils/phdHelper'
|
||||||
|
import { addSampleData, getSampleData } from '@/utils/SampleStore'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
|
@ -579,7 +580,7 @@ export default {
|
||||||
dataProcess(result, flag) {
|
dataProcess(result, flag) {
|
||||||
const { inputFileName } = this.sample
|
const { inputFileName } = this.sample
|
||||||
|
|
||||||
this.$store.commit('ADD_SAMPLE_DATA', {
|
addSampleData({
|
||||||
inputFileName,
|
inputFileName,
|
||||||
data: result,
|
data: result,
|
||||||
from: flag,
|
from: flag,
|
||||||
|
@ -2057,11 +2058,11 @@ export default {
|
||||||
immediate: true,
|
immediate: true,
|
||||||
},
|
},
|
||||||
sample: {
|
sample: {
|
||||||
async handler(newVal, oldVal) {
|
handler(newVal, oldVal) {
|
||||||
console.log('newValnewVal', newVal)
|
console.log('newValnewVal', newVal)
|
||||||
this.graphAssistance.axisType = 'Channel'
|
this.graphAssistance.axisType = 'Channel'
|
||||||
this.handleResetState()
|
this.handleResetState()
|
||||||
const sampleData = await this.$store.dispatch('GET_SAMPLE_DATA', newVal.inputFileName)
|
const sampleData = getSampleData(newVal.inputFileName)
|
||||||
if (sampleData) {
|
if (sampleData) {
|
||||||
this.cancelLastRequest()
|
this.cancelLastRequest()
|
||||||
this.isLoading = false
|
this.isLoading = false
|
||||||
|
|
|
@ -281,6 +281,7 @@ import BGLogViewer from './components/Modals/BetaGammaModals/BGLogViewer.vue'
|
||||||
|
|
||||||
import { saveAs } from 'file-saver'
|
import { saveAs } from 'file-saver'
|
||||||
import CompareFromDbModal from './components/Modals/CompareFromDBModal.vue'
|
import CompareFromDbModal from './components/Modals/CompareFromDBModal.vue'
|
||||||
|
import { clearSampleData, updateSampleDataAnaly } from '@/utils/SampleStore'
|
||||||
|
|
||||||
// 分析类型
|
// 分析类型
|
||||||
const ANALYZE_TYPE = {
|
const ANALYZE_TYPE = {
|
||||||
|
@ -467,7 +468,7 @@ export default {
|
||||||
|
|
||||||
destroyed() {
|
destroyed() {
|
||||||
this.$bus.$off('reanalyse', this.handleReanalyse)
|
this.$bus.$off('reanalyse', this.handleReanalyse)
|
||||||
this.$store.commit('CLEAR_SAMPLE_DATA')
|
clearSampleData()
|
||||||
this.handleCleanAll()
|
this.handleCleanAll()
|
||||||
window.removeEventListener('beforeunload', this.handleCleanAll)
|
window.removeEventListener('beforeunload', this.handleCleanAll)
|
||||||
},
|
},
|
||||||
|
@ -478,8 +479,10 @@ export default {
|
||||||
this.params_toDB.savedAnalysisResult = flag
|
this.params_toDB.savedAnalysisResult = flag
|
||||||
this.resultDisplayFlag = val
|
this.resultDisplayFlag = val
|
||||||
},
|
},
|
||||||
getReAnalyAll(val) {
|
getReAnalyAll(flag, val) {
|
||||||
|
this.isReAnalyed_beta = flag
|
||||||
this.resultDisplayFlag = val
|
this.resultDisplayFlag = val
|
||||||
|
this.params_toDB.savedAnalysisResult = flag
|
||||||
},
|
},
|
||||||
handleReAnalyed(val) {
|
handleReAnalyed(val) {
|
||||||
this.isReAnalyed_gamma = val
|
this.isReAnalyed_gamma = val
|
||||||
|
@ -841,7 +844,6 @@ export default {
|
||||||
* @param { 'all' | 'current' } type
|
* @param { 'all' | 'current' } type
|
||||||
*/
|
*/
|
||||||
handleSavePHDToFile(type) {
|
handleSavePHDToFile(type) {
|
||||||
console.log('%c [ savePHDToFile ]-162', 'font-size:13px; background:pink; color:#bf2c9f;', type)
|
|
||||||
if (this.isGamma) {
|
if (this.isGamma) {
|
||||||
if (type == 'current') {
|
if (type == 'current') {
|
||||||
let params = {
|
let params = {
|
||||||
|
@ -901,7 +903,7 @@ export default {
|
||||||
try {
|
try {
|
||||||
const { success, result, message } = await postAction(`/gamma/Reprocessing?fileName=${fileNames[0]}`)
|
const { success, result, message } = await postAction(`/gamma/Reprocessing?fileName=${fileNames[0]}`)
|
||||||
if (success) {
|
if (success) {
|
||||||
this.$store.commit('UPDATE_SAMPLE_DATA_ANALY', {
|
updateSampleDataAnaly({
|
||||||
inputFileName: fileNames[0],
|
inputFileName: fileNames[0],
|
||||||
data: result,
|
data: result,
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue
Block a user