WIP: Compare和Strip从数据库对比功能

This commit is contained in:
Xu Zhimeng 2023-12-11 21:21:33 +08:00
parent 96bf95741c
commit 044195a799
4 changed files with 258 additions and 82 deletions

View File

@ -16,14 +16,14 @@
@change="handleTableChange"
:selectedRowKeys.sync="selectedRowKeys"
:selectionRows.sync="selectionRows"
:multiple="true"
:multiple="loadType == 'db'"
:scroll="{ y: 'calc(100vh - 550px)' }"
>
</custom-table>
<!-- 底部操作栏 -->
<template slot="custom-footer">
<a-space>
<a-radio-group v-model="queryParam.dbName">
<a-radio-group v-if="loadType == 'db'" v-model="queryParam.dbName">
<a-radio value="auto">From Auto DB</a-radio>
<a-radio value="man">From Interactive DB</a-radio>
</a-radio-group>
@ -38,6 +38,7 @@ import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { getAction } from '../../../../api/manage'
import moment from 'moment'
import { cloneDeep } from 'lodash'
import SampleDataMixin from '../../SampleDataMixin'
const columns = [
{
@ -112,19 +113,17 @@ const columns = [
]
export default {
props: {
value: {
type: Boolean,
},
},
mixins: [JeecgListMixin],
mixins: [JeecgListMixin, SampleDataMixin],
data() {
this.columns = columns
this.columns = cloneDeep(columns)
this.disableMixinCreated = true
return {
visible: false,
loadType: 'db',
queryParam: {
menuTypes: 'G,B',
sampleType: '',
stationName: '',
startDate: moment().add(-30, 'd').format('YYYY-MM-DD'),
endDate: moment().format('YYYY-MM-DD'),
dbName: 'auto',
@ -136,9 +135,6 @@ export default {
stationList: [],
detectorList: [],
url: {
list: '/spectrumAnalysis/getDBSpectrumList',
},
sampleTypeOption: [
{
label: 'P',
@ -159,6 +155,12 @@ export default {
this.getStationAndDetectorList()
},
methods: {
searchQuery() {
this.loadData(1)
this.selectedRowKeys = []
this.selectionRows = []
},
loadData(arg) {
const params = this.getQueryParams() //
const { startDate, endDate, menuTypes } = params
@ -218,6 +220,33 @@ export default {
})
},
//
show(loadType) {
this.loadType = loadType
this.visible = true
this.columns = cloneDeep(columns)
if (loadType != 'db') {
this.columns.splice(10, 1)
const { inputFileName, sampleType } = this.sampleData
this.queryParam.menuTypes = 'G'
if (!this.queryParam.checkboxGroup.includes('AllUsers')) {
this.queryParam.checkboxGroup.push('AllUsers')
}
this.queryParam.detectorsName = undefined
this.queryParam.sampleType = sampleType
this.queryParam.dbName = 'auto'
this.dataSource = []
const index = inputFileName.indexOf('_')
setTimeout(() => {
// AllUsersgetStationAndDetectorListstationName
this.queryParam.stationName = inputFileName.slice(0, index)
}, 100)
}
},
/**
* 加载
*/
@ -228,7 +257,10 @@ export default {
}
this.selectedRowKeys = []
this.visible = false
this.$emit('loadSample', cloneDeep(this.selectionRows))
this.$emit('loadSample', {
sampleList: cloneDeep(this.selectionRows),
loadType: this.loadType,
})
},
//
@ -264,13 +296,10 @@ export default {
},
},
computed: {
visible: {
get() {
return this.value
},
set(val) {
this.$emit('input', val)
},
url() {
return {
list: this.loadType == 'db' ? '/spectrumAnalysis/getDBSpectrumList' : '/gamma/loadSampleData',
}
},
formItems() {
return [
@ -294,6 +323,7 @@ export default {
},
],
allowClear: true,
disabled: this.loadType !== 'db',
},
style: {
width: '18%',
@ -364,6 +394,7 @@ export default {
showSearch: true,
filterOption: this.filterOption,
allowClear: true,
disabled: this.loadType !== 'db',
},
style: {
width: '19%',
@ -390,6 +421,7 @@ export default {
showSearch: true,
filterOption: this.filterOption,
allowClear: true,
disabled: this.loadType !== 'db',
},
style: {
width: '19%',
@ -402,6 +434,7 @@ export default {
props: {
options: this.sampleTypeOption,
allowClear: true,
disabled: this.loadType !== 'db',
},
style: {
width: '14%',
@ -483,7 +516,7 @@ export default {
name: 'checkboxGroup',
props: {
options: [
{ label: 'All User', value: 'AllUsers' },
{ label: 'All User', value: 'AllUsers', disabled: true },
{ label: 'Collect Stop', value: 'CollectStopB' },
{ label: 'Acq.Start', value: 'AcqStartB' },
],

View File

@ -6,7 +6,7 @@
<div v-if="item.children" :key="index">
<a-menu class="multi-level-menu-sub-menu">
<template v-for="child in item.children">
<a-menu-item v-if="child.show !== false" :key="child.key" @click="handleSubMenuClick(item, child)">
<a-menu-item v-if="child.show !== false" :key="child.key" v-bind="child.attrs" @click="handleSubMenuClick(item, child)">
{{ child.title }}
</a-menu-item>
</template>

View File

@ -1601,6 +1601,89 @@ export default {
}
},
// DB
async handleDBFileSelect(sampleId, isStrip, isOperating) {
if (this.isLoading) {
this.$message.warn('Sample is Loading')
return
}
this.handleResetChart()
this.clearCompareLine()
if (isOperating) {
return
}
const { inputFileName: fileName } = this.sample
const hide = this.$message.loading(isStrip ? 'Stripping...' : 'Comparing...', 0)
try {
let param = {
fileName,
sampleId,
},
url = '/gamma/CompareDB'
// Strip
if (isStrip) {
const ratio = await this.$refs.stripModal.getRatio()
param = {
fileName,
sampleId,
ratioRate: ratio || 1,
}
url = '/gamma/StripDB'
}
const { success, result, message } = await getAction(url, param)
if (success) {
if (isStrip) {
const { reference: referenceLine, result: compareLine } = result
this.channelCompareLine = compareLine[0]
this.energyCompareLine = compareLine[1]
this.redrawLineBySeriesName(
'Compare',
this.energyCompareLine,
this.channelCompareLine,
true,
this.channelCompareLine.color
)
this.channelStripReferenceLine = referenceLine[0]
this.energyStripReferenceLine = referenceLine[1]
this.redrawLineBySeriesName(
'StripReference',
this.energyStripReferenceLine,
this.channelStripReferenceLine,
true,
this.channelStripReferenceLine.color
)
this.$nextTick(() => {
this.thumbnailOption.yAxis.max = getAxisMax(this.getChart(), 'yAxis')
})
} else {
const [channelData, energyData] = result
this.channelCompareLine = channelData
this.energyCompareLine = energyData
this.redrawLineBySeriesName('Compare', energyData, channelData, true, channelData.color)
this.$nextTick(() => {
this.thumbnailOption.yAxis.max = getAxisMax(this.getChart(), 'yAxis')
})
}
this.$emit('compareSuccess', isStrip)
} else {
this.$message.error(message)
}
} catch (error) {
console.error(error)
} finally {
hide()
}
},
// Compare 线
clearCompareLine() {
const compareLine = findSeriesByName(this.option.series, 'Compare')

View File

@ -71,7 +71,7 @@
<!-- 频谱分析部分结束 -->
<!-- 从数据库加载开始 -->
<load-from-db-modal v-model="loadFromDbModalVisible" @loadSample="handleLoadSampleFromDB" />
<load-from-db-modal ref="loadFromDBModalRef" @loadSample="handleLoadSampleFromDB" />
<!-- 从数据库加载结束 -->
<!-- 从文件加载开始 -->
@ -340,7 +340,6 @@ export default {
sampleList: [],
loadFromDbModalVisible: false, //
loadFromFileModalVisible: false, //
ftransltModalVisible: false, // Ftransit
@ -511,11 +510,27 @@ export default {
* 从数据库加载-选择完成
* @param {any[]} sampleList
*/
handleLoadSampleFromDB(sampleList) {
handleLoadSampleFromDB({ sampleList, loadType }) {
if (loadType == 'db') {
const ids = this.sampleList.map((item) => item.sampleId) // Sampleid
const willAddList = sampleList.filter((item) => !ids.includes(item.sampleId))
this.callInitValue(willAddList)
this.sampleList = this.sampleList.concat(willAddList)
} else if (loadType == 'compare') {
const sample = sampleList[0]
this.isStriping = false
this.$refs.gammaAnalysisRef.handleDBFileSelect(sample.sampleId, false, this.isComparing)
if (this.isComparing) {
this.isComparing = false
}
} else if (loadType == 'strip') {
const sample = sampleList[0]
this.isComparing = false
this.$refs.gammaAnalysisRef.handleDBFileSelect(sample.sampleId, true, this.isStriping)
if (this.isStriping) {
this.isStriping = false
}
}
},
handleLoadSampleFromFile(sampleList) {
let arr = sampleList.filter((item) => {
@ -991,29 +1006,31 @@ export default {
title: 'SAMPLE',
children: [
{
type: 'a-menu',
type: 'MultiLevelMenu',
attrs: {
children: [
{
type: 'a-menu-item',
title: 'Load From DB',
handler: () => (this.loadFromDbModalVisible = true),
key: 'loadFromDB',
},
{
type: 'a-menu-item',
title: 'Load From File',
handler: () => (this.loadFromFileModalVisible = true),
key: 'loadFromFile',
},
{
type: 'a-menu-item',
title: 'Compare',
key: 'compare',
show: this.isGamma,
handler: () => {
this.isStriping = false
this.$refs.gammaAnalysisRef.showCompareModal(false, this.isComparing)
if (this.isComparing) {
this.isComparing = false
}
children: [
{
title: 'From File',
key: 'compareFromFile',
},
{
title: 'From DB',
key: 'compareFromDB',
},
],
attrs: {
style: {
color: this.isComparing ? 'red' : '#fff',
@ -1021,16 +1038,19 @@ export default {
},
},
{
type: 'a-menu-item',
title: 'Strip',
key: 'strip',
show: this.isGamma,
handler: () => {
this.isComparing = false
this.$refs.gammaAnalysisRef.showCompareModal(true, this.isStriping)
if (this.isStriping) {
this.isStriping = false
}
children: [
{
title: 'From File',
key: 'stripFromFile',
},
{
title: 'From DB',
key: 'stripFromDB',
},
],
attrs: {
style: {
color: this.isStriping ? 'red' : '#fff',
@ -1038,19 +1058,59 @@ export default {
},
},
{
type: 'a-menu-item',
title: 'Ftransit',
handler: () => (this.ftransltModalVisible = true),
key: 'fTransit',
},
{
type: 'a-menu-item',
title: 'Clean All',
handler: () => {
this.handleCleanAll()
},
key: 'cleanAll',
},
],
},
on: {
menuClick: ({ key }) => {
switch (key) {
case 'loadFromDB':
this.$refs.loadFromDBModalRef.show('db')
break
case 'loadFromFile':
this.loadFromFileModalVisible = true
break
case 'fTransit':
this.ftransltModalVisible = true
break
case 'cleanAll':
this.handleCleanAll()
break
}
},
submenuClick: ({ child: { key } }) => {
switch (key) {
case 'compareFromFile':
this.isStriping = false
this.$refs.gammaAnalysisRef.showCompareModal(false, this.isComparing)
if (this.isComparing) {
this.isComparing = false
}
break
case 'compareFromDB':
this.$refs.loadFromDBModalRef.show('compare')
break
case 'stripFromFile':
this.isComparing = false
this.$refs.gammaAnalysisRef.showCompareModal(true, this.isStriping)
if (this.isStriping) {
this.isStriping = false
}
break
case 'stripFromDB':
this.$refs.loadFromDBModalRef.show('strip')
break
}
},
},
},
{
type: 'a-divider',
attrs: {