自建台站增加两个弹窗,优化保存谱到DB的逻辑

This commit is contained in:
Xu Zhimeng 2024-07-31 17:12:57 +08:00
parent 2e4a58c95a
commit 70f49fe8b2
4 changed files with 627 additions and 6 deletions

View File

@ -605,7 +605,6 @@ export default {
fileName,
})
if (success) {
this.$message.success('Save Success')
// DetailedInfomation
updateSampleData({
inputFileName: fileName,
@ -613,7 +612,7 @@ export default {
data: [...result.DetailedInformation],
})
} else {
this.$message.error(message)
throw new Error(message)
}
},
},

View File

@ -0,0 +1,151 @@
<template>
<custom-modal v-model="visible" :width="490" title="Config User Library" :footer="null">
<a-spin :spinning="isLoading">
<div class="config-user-library">
<a-transfer
:titles="['Total Nuclides', 'User Nuclides']"
:dataSource="list"
:list-style="{
width: '200px',
height: '400px',
}"
:target-keys="targetKeys"
:render="(item) => item.title"
:showSearch="true"
:showSelectAll="false"
@change="handleChange"
></a-transfer>
<!--<div class="config-user-library-btns">
<div>
<a-button type="primary" @click="handleDefault">Default</a-button>
<a-button type="primary">Load</a-button>
</div>
<div>
<a-button type="primary" :loading="isSaving" @click="handleSave">Save</a-button>
<a-button type="primary">Apply</a-button>
</div>
<a-button type="primary" :loading="isSaving" @click="handleSave">Save</a-button>
</div>-->
<div style="margin-top: 20px; display: flex; justify-content: end">
<a-button type="primary" :loading="isSaving" @click="handleSave">Save</a-button>
</div>
</div>
</a-spin>
</custom-modal>
</template>
<script>
import { getAction, postAction } from '@/api/manage'
import SampleDataMixin from '@/views/spectrumAnalysis/SampleDataMixin';
import { cloneDeep } from 'lodash'
export default {
mixins: [SampleDataMixin],
data() {
return {
visible: false,
isLoading: false,
list: [],
targetKeys: [],
isSaving: false,
}
},
methods: {
handleChange(targetKeys) {
this.targetKeys = targetKeys
},
//
async getInfo() {
try {
this.isLoading = true
const { sampleId, inputFileName: fileName } = this.sampleData
const { success, result, message } = await getAction('/selfStation/configUserLibrary', {
sampleId,
fileName,
})
if (success) {
this.isLoading = false
const { AllNuclides, UserNuclides } = result
this.list = AllNuclides.map((item) => ({
key: item,
title: item,
}))
this.targetKeys = UserNuclides.map((item) => item)
this.initialTargetKeys = cloneDeep(this.targetKeys)
} else {
this.$message.error(message)
}
} catch (error) {
console.error(error)
}
},
open() {
this.visible = true
this.getInfo()
},
//
handleDefault() {
this.targetKeys = cloneDeep(this.initialTargetKeys)
},
//
async handleSave() {
try {
this.isSaving = true
const { inputFileName: fileName } = this.sampleData
const { success, result, message } = await postAction('/selfStation/saveUserLibrary', {
fileName,
userLibraryName: this.targetKeys,
})
if (success) {
this.$message.success('Save Success')
} else {
this.$message.error(message)
}
} catch (error) {
console.error(error)
} finally {
this.isSaving = false
}
},
},
}
</script>
<style lang="less" scoped>
.config-user-library {
&-btns {
margin-top: 20px;
display: flex;
justify-content: space-between;
> div {
width: 200px;
display: flex;
justify-content: space-between;
}
}
}
::v-deep {
.ant-transfer-list-header {
text-align: center;
&-selected {
span:first-child {
display: none;
}
}
&-title {
position: static;
}
}
}
</style>

View File

@ -0,0 +1,458 @@
<template>
<custom-modal v-model="visible" :width="980" title="Nuclide Library" :footer="null">
<a-spin :spinning="isLoading">
<div class="nuclide-library">
<div class="nuclide-library-list">
<div
class="nuclide-library-list-item"
:class="{ active: selectedNuclide == item }"
v-for="(item, index) in nuclideList"
:key="index"
@click="handleNuclideItemClick(item)"
>
{{ item }}
</div>
</div>
<div class="nuclide-library-settings">
<div class="nuclide-library-settings-select">
<title-over-border class="select-library" title="Select Library">
<a-radio-group v-model="model.libraryName" @change="handleChangeLibraryType">
<a-radio value="UserLibrary">User Library</a-radio>
<a-radio value="FULLLibrary">Full Library</a-radio>
<a-radio value="RelevantLibrary">Relevant Library</a-radio>
</a-radio-group>
</title-over-border>
<div class="parent-and-daughters">
<div class="parents">
<div class="title">Parents</div>
<div class="content">
<div
class="parent-item"
:class="selectedParent == parentItem ? 'active' : ''"
v-for="(parentItem, index) in parentList"
:key="index"
@dblclick="handleParentDBClick(parentItem)"
@click="handleParentClick(parentItem)"
>
{{ parentItem }}
</div>
</div>
</div>
<div class="daughters">
<div class="title">Daughters</div>
<div class="content">
<custom-table
size="small"
:class="daughterList.length ? 'has-data' : ''"
:columns="daughterColumns"
:list="daughterList"
:pagination="false"
:scroll="{ y: 84 }"
rowKey="daughters"
@rowDblClick="handleParentDBClick($event.daughters)"
></custom-table>
</div>
</div>
</div>
</div>
<div class="nuclide-library-settings-main">
<a-form-model layout="inline">
<a-form-model-item label="Name">
<a-input v-model="model.nuclideName"></a-input>
</a-form-model-item>
<a-form-model-item label="Half Life">
{{ nuclideInfo.lab_halfLife }}
</a-form-model-item>
<a-form-model-item label="Half Life Err">
{{ nuclideInfo.lab_halfLifeErr }}
</a-form-model-item>
<a-form-model-item label="Lines">
{{ nuclideInfo.lab_lines }}
</a-form-model-item>
</a-form-model>
<!-- 主体表格 -->
<a-table
size="small"
:class="nuclLinesLibs.length ? 'has-data' : ''"
:columns="mainColumns"
:dataSource="nuclLinesLibs"
:pagination="false"
:scroll="{ y: 330 }"
>
<template slot="keyLine" slot-scope="text">
<span v-if="text == 1" class="green-check-mark"> </span>
</template>
</a-table>
</div>
<div class="nuclide-library-settings-operation">
<a-space :size="10">
<span> Energy: </span>
<a-input v-model="model.editEnergy"></a-input>
<a-input-number
v-model="model.err"
:min="0"
:step="0.5"
:precision="2"
@blur="handleErrInputBlur"
></a-input-number>
<a-button type="primary" @click="handleSearch">Search</a-button>
</a-space>
<a-space :size="10">
<a-button type="primary" @click="handleReset">Reset</a-button>
<a-button type="primary" @click="visible = false">Close</a-button>
</a-space>
</div>
</div>
</div>
</a-spin>
</custom-modal>
</template>
<script>
import SampleDataMixin from '@/views/spectrumAnalysis/SampleDataMixin'
import { getAction } from '@/api/manage'
import TitleOverBorder from '../../TitleOverBorder.vue'
//
const daughterColumns = [
{
title: 'Name',
dataIndex: 'daughters',
align: 'center',
},
{
title: 'Ratio',
dataIndex: 'branchingratios',
align: 'center',
},
{
title: 'Status',
dataIndex: 'daughtersstable',
align: 'center',
},
]
//
const mainColumns = [
{
title: 'Id',
width: 80,
customRender: (_, __, index) => {
return index + 1
},
},
{
title: 'Full Name',
dataIndex: 'fullName',
},
{
title: 'Energy(keV)',
dataIndex: 'energy',
width: 100,
customRender: (text) => Number(text).toFixed(3),
},
{
title: 'Energy Uncert(%)',
dataIndex: 'energyUncert',
width: 120,
customRender: (text) => Number(text).toFixed(6),
},
{
title: 'Yield',
dataIndex: 'yield',
width: 80,
customRender: (text) => Number(text).toFixed(3),
},
{
title: 'Yield Uncert(%)',
dataIndex: 'yieldUncert',
width: 120,
customRender: (text) => Number(text).toFixed(3),
},
{
title: 'KeyLine',
dataIndex: 'keyFlag',
width: 100,
align: 'center',
scopedSlots: {
customRender: 'keyLine',
},
},
]
export default {
mixins: [SampleDataMixin],
components: {
TitleOverBorder,
},
data() {
this.daughterColumns = daughterColumns
this.mainColumns = mainColumns
return {
visible: false,
isLoading: false,
nuclideList: [],
nuclideInfo: {},
daughterList: [],
parentList: [],
nuclLinesLibs: [],
model: {},
selectedNuclide: {}, // Nuclide
selectedParent: {}, // Parent
}
},
methods: {
//
async getInfo(selectFirst = false) {
this.selectedParent = {}
try {
this.isLoading = true
const { sampleId, inputFileName: fileName } = this.sampleData
const { success, result, message } = await getAction('/selfStation/NuclideLibrary', {
sampleId,
fileName,
...this.model,
})
if (success) {
const {
daughter: { list_parent, table_daughter },
nuclLinesLibs,
nuclideInfo,
nuclides,
} = result
this.nuclideList = nuclides
this.parentList = list_parent ? list_parent.filter((item) => item) : []
this.daughterList = table_daughter ? table_daughter.filter((item) => item.daughters) : []
this.nuclideInfo = nuclideInfo
this.nuclLinesLibs = nuclLinesLibs
if (selectFirst) {
this.selectedNuclide = nuclides[0]
this.model.nuclideName = nuclides[0]
}
} else {
this.$message.error(message)
}
} catch (error) {
console.error(error)
} finally {
this.isLoading = false
}
},
open() {
this.model = {
libraryName: 'UserLibrary',
err: 0.5,
editEnergy: '',
nuclideName: '',
}
this.getInfo(true)
this.visible = true
},
handleNuclideItemClick(item) {
this.selectedNuclide = item
this.model.nuclideName = item
this.getInfo()
},
handleErrInputBlur() {
if (!this.model.err) {
this.model.err = 0
}
},
// Library
handleChangeLibraryType() {
this.model.nuclideName = ''
this.handleSearch()
},
//
handleSearch() {
this.getInfo(true)
},
//
handleReset() {
this.model.editEnergy = ''
this.getInfo(true)
},
handleParentClick(item) {
this.selectedParent = item
},
// Parents
handleParentDBClick(item) {
this.model.nuclideName = item
this.getInfo()
},
},
}
</script>
<style lang="less" scoped>
.nuclide-library {
display: flex;
gap: 20px;
margin-top: 5px;
&-list {
padding: 5px;
width: 150px;
height: 632px;
overflow: auto;
background-color: #275466;
&-item {
height: 32px;
line-height: 32px;
padding: 0 4px;
cursor: pointer;
}
}
&-settings {
flex: 1;
&-select {
display: flex;
gap: 15px;
.select-library {
width: 200px;
height: 128px;
.ant-radio-group {
height: 100%;
display: flex;
flex-direction: column;
justify-content: space-between;
}
}
.parent-and-daughters {
flex: 1;
display: flex;
gap: 10px;
.title {
height: 32px;
line-height: 32px;
background-color: #497e9d;
text-align: center;
}
.content {
height: 111px;
}
.parents {
width: 180px;
.content {
background-color: #275466;
overflow: auto;
.parent-item {
padding: 3px 5px;
cursor: pointer;
user-select: none;
}
}
}
.daughters {
flex: 1;
.ant-table-wrapper {
&.has-data {
::v-deep {
.ant-table-body {
height: 84px;
background-color: #06282a;
}
}
}
::v-deep {
.ant-table {
&-placeholder {
height: 85px;
display: flex;
justify-content: center;
align-items: center;
}
}
}
}
}
}
}
&-main {
margin-top: 20px;
.ant-form {
display: flex;
justify-content: space-between;
}
.ant-table {
&-wrapper {
margin-top: 20px;
&.has-data {
::v-deep {
.ant-table-body {
height: 330px;
background-color: #06282a;
}
}
}
::v-deep {
.ant-table {
&-placeholder {
height: 331px;
display: flex;
justify-content: center;
align-items: center;
}
}
}
}
}
}
&-operation {
margin-top: 20px;
display: flex;
justify-content: space-between;
}
}
}
.active {
background-color: #296d81;
}
.green-check-mark {
&::after {
@color: #3df9a7;
content: '';
border-radius: 0px;
width: 16px;
height: 9px;
display: inline-block;
border-bottom: 3px solid @color;
border-left: 3px solid @color;
transform: rotate(-45deg);
}
}
</style>

View File

@ -259,6 +259,8 @@
<bg-log-viewer v-model="bgLogViewerVisible" />
<CalibrationModal :sampleList="sampleList" ref="newCalibrationModalRef" />
<self-station-nuclide-library-modal ref="selfStationNuclideLibraryModalRef" />
<self-station-config-user-library-modal ref="selfStationConfigUserLibraryModalRef" />
</div>
</template>
<script>
@ -318,6 +320,8 @@ import CompareFromDbModal from './components/Modals/CompareFromDBModal.vue'
import { clearSampleData, getSampleData, updateSampleData, updateSampleDataAnaly } from '@/utils/SampleStore'
import BetaAnalyzeInteractiveToolModal from './components/Modals/SelfStation/BetaAnalyzeInteractiveToolModal/index.vue'
import SelfStationAnalyzeSettingModal from './components/Modals/SelfStation/SelfStationAnalyzeSettingModal.vue'
import SelfStationNuclideLibraryModal from './components/Modals/SelfStation/SelfStationNuclideLibraryModal.vue'
import SelfStationConfigUserLibraryModal from './components/Modals/SelfStation/SelfStationConfigUserLibraryModal.vue'
//
const ANALYZE_TYPE = {
@ -376,6 +380,8 @@ export default {
CalibrationModal,
BetaAnalyzeInteractiveToolModal,
SelfStationAnalyzeSettingModal,
SelfStationNuclideLibraryModal,
SelfStationConfigUserLibraryModal,
},
provide() {
@ -889,6 +895,7 @@ export default {
await this.saveSelfStationToDBRequest(fileName)
}
}
this.$message.success('Save Success')
} catch (error) {
this.$message.error(error && (error.message || error))
} finally {
@ -1544,15 +1551,21 @@ export default {
children: [
{
type: 'a-menu-item',
show: this.isGamma,
show: this.isGamma || this.isBeta,
title: 'Nuclide Library',
handler: () => (this.nuclideLibraryModalVisible = true),
handler: () => {
if (this.isGamma) this.nuclideLibraryModalVisible = true
if (this.isBeta) this.$refs.selfStationNuclideLibraryModalRef.open()
},
},
{
type: 'a-menu-item',
show: this.isGamma,
show: this.isGamma || this.isBeta,
title: 'Config User Library',
handler: () => (this.configUserLibModalVisible = true),
handler: () => {
if (this.isGamma) this.configUserLibModalVisible = true
if (this.isBeta) this.$refs.selfStationConfigUserLibraryModalRef.open()
},
},
],
},