fix: 将Load From DB拆分,修复Compare/Strip状态问题

This commit is contained in:
Xu Zhimeng 2023-12-12 12:18:37 +08:00
parent a35992098e
commit 285fdec881
3 changed files with 667 additions and 79 deletions

View File

@ -0,0 +1,610 @@
<template>
<custom-modal v-model="visible" :width="1280" title="Load From Database" class="load-from-db-modal">
<search-form ref="searchFormRef" :items="formItems" v-model="queryParam">
<a-space slot="additional">
<a-button @click="handleReset">Reset</a-button>
<a-button type="primary" @click="searchQuery">Search</a-button>
</a-space>
</search-form>
<custom-table
size="middle"
rowKey="sampleId"
:columns="columns"
:list="dataSource"
:pagination="ipagination"
:loading="loading"
@change="handleTableChange"
:selectedRowKeys.sync="selectedRowKeys"
:selectionRows.sync="selectionRows"
:multiple="false"
:scroll="{ y: 'calc(100vh - 550px)' }"
>
</custom-table>
<!-- 底部操作栏 -->
<template slot="custom-footer">
<a-space>
<a-button type="primary" @click="handleLoad">Load</a-button>
</a-space>
</template>
</custom-modal>
</template>
<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { getAction } from '../../../../api/manage'
import moment from 'moment'
import { cloneDeep } from 'lodash'
import SampleDataMixin from '../../SampleDataMixin'
const columns = [
{
title: 'SampleID',
align: 'center',
dataIndex: 'sampleId',
},
{
title: 'Station',
align: 'center',
dataIndex: 'stationName',
width: 80,
},
{
title: 'Detector',
align: 'center',
dataIndex: 'detectorsName',
width: 110,
},
{
title: 'Sample',
align: 'center',
dataIndex: 'sampleType',
width: 65,
},
{
title: 'DataType',
align: 'center',
dataIndex: 'dataType',
},
{
title: 'Qualifier',
align: 'center',
dataIndex: 'spectralQualifie',
},
{
title: 'Col.Stop',
align: 'center',
dataIndex: 'collectStop',
sorter: true,
width: 170,
},
{
title: 'Acq.Start',
align: 'center',
dataIndex: 'acquisitionStart',
width: 170,
},
{
title: 'Acq.real',
align: 'center',
dataIndex: 'acquisitionRealSec',
width: 100,
},
{
title: 'Acq.live',
align: 'center',
dataIndex: 'acquisitionLiveSec',
width: 100,
},
{
title: 'Status',
align: 'center',
dataIndex: 'status',
},
]
export default {
mixins: [JeecgListMixin, SampleDataMixin],
data() {
this.columns = cloneDeep(columns)
this.disableMixinCreated = true
return {
visible: false,
loadType: 'compare',
queryParam: {
menuTypes: 'G',
sampleType: '',
stationName: '',
detectorsName: '',
startDate: moment().add(-30, 'd').format('YYYY-MM-DD'),
endDate: moment().format('YYYY-MM-DD'),
dbName: 'auto',
spectralQualifie: 'FULL',
checkboxGroup: ['AcqStartB', 'AllUsers'],
},
url: {
list: '/gamma/loadSampleData',
},
selectedRowKeys: [],
selectionRows: [],
stationList: [],
detectorList: [],
sampleTypeOption: [
{
label: 'P',
value: 'P',
},
{
label: 'B',
value: 'B',
},
{
label: 'G',
value: 'G',
},
],
}
},
created() {
this.getStationAndDetectorList()
},
methods: {
searchQuery() {
this.loadData(1)
this.selectedRowKeys = []
this.selectionRows = []
},
loadData(arg) {
const params = this.getQueryParams() //
const { startDate, endDate, menuTypes } = params
if (!menuTypes) {
this.$message.warn('Please Select SampleType First')
return
}
if (!startDate || !endDate) {
this.$message.warn(`'From' Date And 'To' Date Cannot Be Null`)
return
}
if (moment(startDate).isAfter(moment(endDate))) {
this.$message.warn(`'From' Date Cannot Be Late Than 'To' Date`)
return
}
// 1
if (arg === 1) {
this.ipagination.current = 1
}
params.AllUsers = this.allUsersValue
params.CollectStopB = this.collectStopValue
params.AcqStartB = this.acqStartValue
delete params.checkboxGroup
this.onClearSelected()
this.loading = true
getAction(this.url.list, params)
.then((res) => {
if (res.success) {
const result = res.result.records || res.result
result.forEach((item) => {
const fileName = item.inputFileName
if (fileName) {
const arr = fileName.split('/')
item.inputFileName = arr[arr.length - 1]
}
})
this.dataSource = result
if (res.result.total) {
this.ipagination.total = res.result.total
} else {
this.ipagination.total = 0
}
} else {
this.$message.warning(res.message)
}
})
.finally(() => {
this.loading = false
})
},
//
show(loadType) {
this.loadType = loadType
this.visible = true
const { inputFileName, sampleType } = this.sampleData
this.queryParam.detectorsName = undefined
this.queryParam.sampleType = sampleType
const index = inputFileName.indexOf('_')
this.queryParam.stationName = inputFileName.slice(0, index)
this.searchQuery()
},
/**
* 加载
*/
handleLoad() {
if (!this.selectedRowKeys.length) {
this.$message.warn('Please Select Sample To Load')
return
}
this.selectedRowKeys = []
this.visible = false
this.$emit('loadSample', {
sampleList: cloneDeep(this.selectionRows),
loadType: this.loadType,
})
},
//
async getStationAndDetectorList() {
try {
this.stationList = []
this.detectorList = []
this.queryParam.stationName = undefined
this.queryParam.detectorsName = undefined
const { success, result, message } = await getAction('/spectrumAnalysis/getDBSearchList', {
AllUsers: this.allUsersValue,
})
if (success) {
this.stationList = result.stationCode.map((item) => ({ label: item, value: item }))
this.allDetectorList = result.detectorCode.map((item) => ({ label: item, value: item }))
} else {
this.$message.error(message)
}
} catch (error) {
console.error(error)
}
},
//
handleReset() {
const stationName = this.queryParam.stationName
this.$refs.searchFormRef.$refs.form.resetFields()
this.queryParam.stationName = stationName
},
filterOption(input, option) {
return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
},
},
computed: {
formItems() {
return [
{
label: 'SampleType',
type: 'custom-select',
name: 'menuTypes',
props: {
options: [
{
label: 'All',
value: 'G,B',
},
{
label: 'Gamma',
value: 'G',
},
{
label: 'Beta',
value: 'B',
},
],
allowClear: true,
disabled: true,
},
style: {
width: '18%',
},
on: {
change: (event) => {
console.log('event', event)
if (!event) {
this.stationList = []
this.detectorList = []
return
}
let arr_B = [
{
label: 'B',
value: 'B',
},
]
let arr_G = [
{
label: 'P',
value: 'P',
},
{
label: 'G',
value: 'G',
},
]
let arr_A = [
{
label: 'P',
value: 'P',
},
{
label: 'B',
value: 'B',
},
{
label: 'G',
value: 'G',
},
]
if (event == 'B') {
this.sampleTypeOption = arr_B
this.$nextTick(() => {
this.queryParam.sampleType = 'B'
})
} else if (event == 'G') {
this.sampleTypeOption = arr_G
this.$nextTick(() => {
this.queryParam.sampleType = 'P'
})
} else {
this.sampleTypeOption = arr_A
this.$nextTick(() => {
this.queryParam.sampleType = ''
})
}
},
},
},
{
label: 'Station',
type: 'custom-select',
name: 'stationName',
props: {
options: this.stationList,
showSearch: true,
filterOption: this.filterOption,
allowClear: true,
disabled: true,
},
style: {
width: '19%',
},
on: {
change: (val) => {
if (val) {
this.detectorList = this.allDetectorList.filter((item) => {
return item.label.includes(val)
})
} else {
this.detectorList = []
}
this.queryParam.detectorsName = undefined
},
},
},
{
label: 'Detector',
type: 'custom-select',
name: 'detectorsName',
props: {
options: this.detectorList,
showSearch: true,
filterOption: this.filterOption,
allowClear: true,
disabled: true,
},
style: {
width: '19%',
},
},
{
label: 'Sample',
type: 'custom-select',
name: 'sampleType',
props: {
options: this.sampleTypeOption,
allowClear: true,
disabled: true,
},
style: {
width: '14%',
},
},
{
label: 'DataType',
type: 'custom-select',
name: 'dataType',
props: {
options: [
{
label: 'S',
value: 'S',
},
{
label: 'G',
value: 'G',
},
{
label: 'D',
value: 'D',
},
{
label: 'Q',
value: 'Q',
},
{
label: 'B',
value: 'B',
},
{
label: 'C',
value: 'C',
},
],
allowClear: true,
},
style: {
width: '14%',
},
},
{
label: 'Qualifier',
type: 'custom-select',
name: 'spectralQualifie',
props: {
options: [
{
label: 'FULL',
value: 'FULL',
},
{
label: 'PREL',
value: 'PREL',
},
],
allowClear: true,
},
style: {
width: '16%',
paddingRight: 0,
},
},
{
label: 'SampleID',
type: 'a-input',
name: 'sampleId',
props: {
allowClear: true,
},
style: {
width: '207px',
},
},
{
label: '',
type: 'a-checkbox-group',
name: 'checkboxGroup',
props: {
options: [
{ label: 'All User', value: 'AllUsers', disabled: true },
{ label: 'Collect Stop', value: 'CollectStopB' },
{ label: 'Acq.Start', value: 'AcqStartB' },
],
},
style: {
width: '305px',
paddingRight: 0,
},
},
{
label: 'From',
type: 'custom-date-picker',
name: 'startDate',
props: {
format: 'YYYY-MM-DD',
valueFormat: 'YYYY-MM-DD',
style: {
minWidth: 'auto',
},
},
style: {
width: '16%',
},
},
{
label: 'To',
type: 'custom-date-picker',
name: 'endDate',
props: {
format: 'YYYY-MM-DD',
valueFormat: 'YYYY-MM-DD',
style: {
minWidth: 'auto',
},
},
style: {
paddingRight: 0,
marginRight: '8px',
width: '13%',
},
},
{
label: 'Status',
type: 'custom-select',
name: 'status',
props: {
options: [
{
label: 'U',
value: 'U',
},
{
label: 'A',
value: 'A',
},
{
label: 'P',
value: 'P',
},
{
label: 'R',
value: 'R',
},
{
label: 'F',
value: 'F',
},
],
allowClear: true,
},
style: {
width: '14%',
marginRight: '10px',
},
},
]
},
allUsersValue() {
const checkboxGroup = this.queryParam.checkboxGroup
return !!(checkboxGroup && checkboxGroup.includes('AllUsers'))
},
collectStopValue() {
const checkboxGroup = this.queryParam.checkboxGroup
return !!(checkboxGroup && checkboxGroup.includes('CollectStopB'))
},
acqStartValue() {
const checkboxGroup = this.queryParam.checkboxGroup
return !!(checkboxGroup && checkboxGroup.includes('AcqStartB'))
},
},
watch: {
// All User station detector
allUsersValue() {
if (this.queryParam.menuTypes) {
this.stationList = []
this.detectorList = []
this.getStationAndDetectorList(this.queryParam.menuTypes)
}
},
},
}
</script>
<style lang="less" scoped>
.load-from-db-modal {
::v-deep {
.search-btn {
display: none;
}
}
}
</style>

View File

@ -8,7 +8,7 @@
</search-form>
<custom-table
size="middle"
:rowKey="this.loadType == 'db' ? 'analysitId' : 'sampleId'"
rowKey="analysitId"
:columns="columns"
:list="dataSource"
:pagination="ipagination"
@ -16,14 +16,14 @@
@change="handleTableChange"
:selectedRowKeys.sync="selectedRowKeys"
:selectionRows.sync="selectionRows"
:multiple="loadType == 'db'"
:multiple="true"
:scroll="{ y: 'calc(100vh - 550px)' }"
>
</custom-table>
<!-- 底部操作栏 -->
<template slot="custom-footer">
<a-space>
<a-radio-group v-if="loadType == 'db'" v-model="queryParam.dbName">
<a-radio-group 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,7 +38,6 @@ import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { getAction } from '../../../../api/manage'
import moment from 'moment'
import { cloneDeep } from 'lodash'
import SampleDataMixin from '../../SampleDataMixin'
const columns = [
{
@ -113,17 +112,20 @@ const columns = [
]
export default {
mixins: [JeecgListMixin, SampleDataMixin],
props: {
value: {
type: Boolean,
},
},
mixins: [JeecgListMixin],
data() {
this.columns = cloneDeep(columns)
this.columns = 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',
@ -135,6 +137,9 @@ export default {
stationList: [],
detectorList: [],
url: {
list: '/spectrumAnalysis/getDBSpectrumList',
},
sampleTypeOption: [
{
label: 'P',
@ -155,12 +160,6 @@ export default {
this.getStationAndDetectorList()
},
methods: {
searchQuery() {
this.loadData(1)
this.selectedRowKeys = []
this.selectionRows = []
},
loadData(arg) {
const params = this.getQueryParams() //
const { startDate, endDate, menuTypes } = params
@ -220,53 +219,21 @@ export default {
})
},
//
show(loadType) {
if (loadType !== this.loadType) {
this.dataSource = []
this.ipagination.total = 0
}
this.loadType = loadType
show() {
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')) {
// All Users
this.queryParam.checkboxGroup.push('AllUsers')
}
this.queryParam.detectorsName = undefined
this.queryParam.sampleType = sampleType
this.queryParam.dbName = 'auto'
const index = inputFileName.indexOf('_')
setTimeout(() => {
// AllUsersgetStationAndDetectorListstationName
this.queryParam.stationName = inputFileName.slice(0, index)
}, 100)
}
},
/**
* 加载
*/
handleLoad() {
async handleLoad() {
if (!this.selectedRowKeys.length) {
this.$message.warn('Please Select Sample To Load')
return
}
this.selectedRowKeys = []
this.visible = false
this.$emit('loadSample', {
sampleList: cloneDeep(this.selectionRows),
loadType: this.loadType,
})
this.$emit('loadSample', cloneDeep(this.selectionRows))
},
//
@ -302,11 +269,6 @@ export default {
},
},
computed: {
url() {
return {
list: this.loadType == 'db' ? '/spectrumAnalysis/getDBSpectrumList' : '/gamma/loadSampleData',
}
},
formItems() {
return [
{
@ -329,7 +291,6 @@ export default {
},
],
allowClear: true,
disabled: this.loadType !== 'db',
},
style: {
width: '18%',
@ -400,7 +361,6 @@ export default {
showSearch: true,
filterOption: this.filterOption,
allowClear: true,
disabled: this.loadType !== 'db',
},
style: {
width: '19%',
@ -427,7 +387,6 @@ export default {
showSearch: true,
filterOption: this.filterOption,
allowClear: true,
disabled: this.loadType !== 'db',
},
style: {
width: '19%',
@ -440,7 +399,6 @@ export default {
props: {
options: this.sampleTypeOption,
allowClear: true,
disabled: this.loadType !== 'db',
},
style: {
width: '14%',
@ -522,7 +480,7 @@ export default {
name: 'checkboxGroup',
props: {
options: [
{ label: 'All User', value: 'AllUsers', disabled: this.loadType !== 'db' },
{ label: 'All User', value: 'AllUsers' },
{ label: 'Collect Stop', value: 'CollectStopB' },
{ label: 'Acq.Start', value: 'AcqStartB' },
],

View File

@ -74,6 +74,10 @@
<load-from-db-modal ref="loadFromDBModalRef" @loadSample="handleLoadSampleFromDB" />
<!-- 从数据库加载结束 -->
<!-- 从数据库比较开始 -->
<compare-from-db-modal ref="compareFromDBModalRef" @loadSample="handleCompareSampleFromDB" />
<!-- 从数据库比较结束 -->
<!-- 从文件加载开始 -->
<load-from-file-modal v-model="loadFromFileModalVisible" @loadFormFile="handleLoadSampleFromFile" />
<!-- 从文件加载结束 -->
@ -272,6 +276,7 @@ import { fetchAndDownload } from '@/utils/file'
import BGLogViewer from './components/Modals/BetaGammaModals/BGLogViewer.vue'
import { saveAs } from 'file-saver'
import CompareFromDbModal from './components/Modals/CompareFromDBModal.vue'
//
const ANALYZE_TYPE = {
@ -319,6 +324,7 @@ export default {
AutomaticAnalysisLogModal,
BetaGammaExtrapolationModal,
BgLogViewer: BGLogViewer,
CompareFromDbModal,
},
provide() {
@ -510,21 +516,24 @@ export default {
* 从数据库加载-选择完成
* @param {any[]} 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 {
const sample = sampleList[0]
if (loadType == 'compare') {
this.isStriping = false
this.$refs.gammaAnalysisRef.handleDBFileSelect(sample.sampleId, false)
} else if (loadType == 'strip') {
this.isComparing = false
this.$refs.gammaAnalysisRef.handleDBFileSelect(sample.sampleId, true)
}
handleLoadSampleFromDB(sampleList) {
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)
},
/**
* 从数据库比较-选择完成
* @param {any[]} sampleList
*/
handleCompareSampleFromDB({ sampleList, loadType }) {
const sample = sampleList[0]
if (loadType == 'compare') {
this.isStriping = false
this.$refs.gammaAnalysisRef.handleDBFileSelect(sample.sampleId, false)
} else if (loadType == 'strip') {
this.isComparing = false
this.$refs.gammaAnalysisRef.handleDBFileSelect(sample.sampleId, true)
}
},
handleLoadSampleFromFile(sampleList) {
@ -607,6 +616,7 @@ export default {
this.sampleList = []
this.analysisType = undefined
this.sampleData = {}
this.resetCompareStripState()
},
//
@ -992,6 +1002,15 @@ export default {
this.isComparing = true
}
},
// comparestrip
resetCompareStripState() {
this.isComparing = false
this.isStriping = false
if (this.$refs.gammaAnalysisRef) {
this.$refs.gammaAnalysisRef.clearCompareLine()
}
},
},
computed: {
//
@ -1067,19 +1086,19 @@ export default {
menuClick: ({ key }) => {
switch (key) {
case 'loadFromDB':
this.$refs.loadFromDBModalRef.show('db')
this.$refs.loadFromDBModalRef.show()
break
case 'loadFromFile':
this.loadFromFileModalVisible = true
break
case 'compare':
if(this.isComparing) {
if (this.isComparing) {
this.$refs.gammaAnalysisRef.clearCompareLine()
this.isComparing = false
}
break
case 'strip':
if(this.isStriping) {
if (this.isStriping) {
this.$refs.gammaAnalysisRef.clearCompareLine()
this.isStriping = false
}
@ -1099,14 +1118,14 @@ export default {
this.$refs.gammaAnalysisRef.showCompareModal(false)
break
case 'compareFromDB':
this.$refs.loadFromDBModalRef.show('compare')
this.$refs.compareFromDBModalRef.show('compare')
break
case 'stripFromFile':
this.isComparing = false
this.$refs.gammaAnalysisRef.showCompareModal(true)
break
case 'stripFromDB':
this.$refs.loadFromDBModalRef.show('strip')
this.$refs.compareFromDBModalRef.show('strip')
break
}
},
@ -1130,6 +1149,7 @@ export default {
on: {
change: (spectra) => {
if (spectra) {
this.resetCompareStripState()
this.loadSelectedSample(spectra)
} else {
this.analysisType = undefined