feat: Energy的增/删/改及Apply操作,Peak Comment和GeneralComment接口对接

This commit is contained in:
Xu Zhimeng 2023-09-07 19:29:59 +08:00
parent ef3a022528
commit e4edd1abfd
5 changed files with 357 additions and 111 deletions

View File

@ -1,48 +0,0 @@
<template>
<custom-modal v-model="visible" :title="type + ' Comment'" :okHandler="handleOk">
<a-textarea :rows="10" v-model="content"></a-textarea>
</custom-modal>
</template>
<script>
export default {
props: {
value: {
type: Boolean
},
type: {
type: String
}
},
data() {
return {
content: ''
}
},
methods: {
async handleOk() {
if (!this.content) {
this.$message.warn('Please Input Comment')
throw new Error('Content Is Empty')
}
console.log('%c [ ]-29', 'font-size:13px; background:pink; color:#bf2c9f;', this.type, this.content)
}
},
computed: {
visible: {
get() {
if (this.value) {
this.content = ''
}
return this.value
},
set(val) {
this.$emit('input', val)
}
}
}
}
</script>
<style></style>

View File

@ -0,0 +1,69 @@
<template>
<custom-modal v-model="visible" title="General Comment" :okHandler="handleOk">
<a-spin :spinning="isLoading">
<a-textarea :rows="10" v-model="content"></a-textarea>
</a-spin>
</custom-modal>
</template>
<script>
import { getAction, postAction } from '@/api/manage'
import ModalMixin from '@/mixins/ModalMixin'
import SampleDataMixin from '@/views/spectrumAnalysis/SampleDataMixin'
export default {
mixins: [ModalMixin, SampleDataMixin],
data() {
return {
content: ''
}
},
methods: {
async handleOk() {
if (!this.content) {
this.$message.warn('Please Input Comment')
throw new Error('Comment is Empty')
}
try {
this.isSubmitting = true
const { inputFileName: fileName } = this.sampleData
const { success, message } = await postAction('/gamma/addGeneralComment', {
fileName,
comments: this.content
})
if (!success) {
this.$message.error(message)
throw new Error(message)
}
} catch (error) {
console.error(error)
}
},
async getComment() {
try {
this.isLoading = true
const { inputFileName: fileName } = this.sampleData
const { success, result, message } = await getAction('/gamma/viewGenralComment', {
fileName
})
if (success) {
this.content = result
} else {
this.$message.error(message)
}
} catch (error) {
console.error(error)
} finally {
this.isLoading = false
}
},
beforeModalOpen() {
this.content = ''
this.getComment()
}
}
}
</script>
<style></style>

View File

@ -0,0 +1,76 @@
<template>
<custom-modal v-model="visible" title="Peak Comment" :okHandler="handleOk">
<a-spin :spinning="isLoading">
<a-textarea :rows="10" v-model="content"></a-textarea>
</a-spin>
</custom-modal>
</template>
<script>
import { getAction, postAction } from '@/api/manage'
import ModalMixin from '@/mixins/ModalMixin'
import SampleDataMixin from '@/views/spectrumAnalysis/SampleDataMixin'
export default {
mixins: [ModalMixin, SampleDataMixin],
props: {
curRow: {
type: Number
}
},
data() {
return {
content: ''
}
},
methods: {
async handleOk() {
if (!this.content) {
this.$message.warn('Please Input Comment')
throw new Error('Comment is Empty')
}
try {
this.isSubmitting = true
const { inputFileName: fileName } = this.sampleData
const { success, message } = await postAction('/gamma/addPeakComment', {
fileName,
comments: this.content,
curRow: this.curRow
})
if (!success) {
this.$message.error(message)
throw new Error(message)
}
} catch (error) {
console.error(error)
}
},
async getComment() {
try {
this.isLoading = true
const { inputFileName: fileName } = this.sampleData
const { success, result, message } = await getAction('/gamma/viewPeakComment', {
fileName,
curRow: this.curRow
})
if (success) {
this.content = result
} else {
this.$message.error(message)
}
} catch (error) {
console.error(error)
} finally {
this.isLoading = false
}
},
beforeModalOpen() {
this.content = ''
this.getComment()
}
}
}
</script>
<style></style>

View File

@ -40,8 +40,8 @@
</custom-table>
<div class="operators">
<a-button type="primary" @click="nuclideReviewModalVisible = true">Nuclide Review Window</a-button>
<a-button type="primary" @click="handleAddComment('Peak')">Add Peak Comment</a-button>
<a-button type="primary" @click="handleAddComment('General')">Add General Comment</a-button>
<a-button type="primary" @click="handleAddPeakComment()">Add Peak Comment</a-button>
<a-button type="primary" @click="handleAddGeneralComment()">Add General Comment</a-button>
</div>
</div>
<!-- 表格结束 -->
@ -158,9 +158,14 @@
<!-- 右侧结束 -->
</div>
</a-spin>
<!-- Comment弹窗 开始 -->
<comment-modal v-model="commentModalVisible" :type="commentType" />
<!-- Comment弹窗 结束 -->
<!-- Peak Comment弹窗 开始 -->
<peak-comment-modal v-model="peakCommentModalVisible" :curRow="curRow" />
<!-- Peak Comment弹窗 结束 -->
<!-- General Comment弹窗 开始 -->
<general-comment-modal v-model="generalCommentModalVisible" />
<!-- General Comment弹窗 结束 -->
<!-- Fit Peaks and Baseline弹窗 开始 -->
<fit-peaks-and-base-line-modal
v-model="fitPeaksAndBaselineModalVisible"
@ -178,7 +183,7 @@
<script>
import CustomChart from '@/components/CustomChart/index.vue'
import TitleOverBorder from '../../TitleOverBorder.vue'
import CommentModal from './components/CommentModal.vue'
import PeakCommentModal from './components/PeakCommentModal.vue'
import FitPeaksAndBaseLineModal from './components/FitPeaksAndBaselineModal.vue'
import NuclideReviewModal from './components/NuclideReviewModal.vue'
import ModalMixin from '@/mixins/ModalMixin'
@ -187,6 +192,7 @@ import { cloneDeep } from 'lodash'
import Response from './Response.json'
import { findSeriesByName, getXAxisAndYAxisByPosition, rangeNumber } from '@/utils/chartHelper'
import SampleDataMixin from '@/views/spectrumAnalysis/SampleDataMixin'
import GeneralCommentModal from './components/GeneralCommentModal.vue'
//
const initialOption = {
@ -381,9 +387,10 @@ export default {
components: {
CustomChart,
TitleOverBorder,
CommentModal,
PeakCommentModal,
FitPeaksAndBaseLineModal,
NuclideReviewModal
NuclideReviewModal,
GeneralCommentModal
},
data() {
this.columns = columns
@ -402,8 +409,9 @@ export default {
list: [],
sampleId: -1,
commentModalVisible: false, // Comment
commentType: 'Peak',
peakCommentModalVisible: false, // Comment
curRow: -1,
generalCommentModalVisible: false, // Comment
btnGroupType: 1, // Peak
@ -697,14 +705,21 @@ export default {
return maxXAxises
},
// comment
handleAddComment(type) {
if (type == 'Peak' && !this.selectedKeys.length) {
// peak comment
handleAddPeakComment () {
if (!this.selectedKeys.length) {
this.$message.warn('Please Select a Peak that You Want to Add Comment!')
return
}
this.commentType = type
this.commentModalVisible = true
const [willDelKey] = this.selectedKeys
const findIndex = this.list.findIndex(item => item.index == willDelKey)
this.curRow = findIndex
this.peakCommentModalVisible = true
},
// general comment
handleAddGeneralComment() {
this.generalCommentModalVisible = true
},
// Insert

View File

@ -56,7 +56,7 @@
<a-button type="primary">Save</a-button>
</div>
<div>
<a-button type="primary">Apply</a-button>
<a-button type="primary" @click="handleApply">Apply</a-button>
</div>
</div>
</div>
@ -68,7 +68,7 @@
<!-- curve -->
<title-over-border class="mt-20" title="curve">
<div class="curve">
<custom-chart :option="option" />
<custom-chart :option="option" :opts="opts" />
</div>
</title-over-border>
</div>
@ -102,7 +102,7 @@
import ModalMixin from '@/mixins/ModalMixin'
import TitleOverBorder from '../TitleOverBorder.vue'
import CustomChart from '@/components/CustomChart/index.vue'
import { getAction } from '@/api/manage'
import { getAction, postAction } from '@/api/manage'
import { cloneDeep } from 'lodash'
import { buildLineSeries } from '@/utils/chartHelper'
import SampleDataMixin from '../../SampleDataMixin'
@ -143,6 +143,17 @@ const initialOption = {
right: 10,
bottom: 0
},
tooltip: {
trigger: 'axis',
formatter: params => {
const [x, y] = params[0].value
const channel = parseInt(x)
const energy = y.toFixed(3)
return `<div class="channel">Channel: ${channel}</div>
<div class="energy">Energy: ${energy}</div>`
},
className: 'figure-chart-option-tooltip'
},
xAxis: {
min: 1,
max: 'dataMax',
@ -198,7 +209,10 @@ export default {
selectedRowKeys: [],
model: {},
currSelectedDataSource: '',
appliedDataSource: ''
appliedDataSource: '',
opts: {
notMerge: true
}
}
},
methods: {
@ -213,19 +227,31 @@ export default {
this.isLoading = false
if (success) {
console.log('%c [ ]-220', 'font-size:13px; background:pink; color:#bf2c9f;', result)
const { AllData, equation, list_dataSource, param, table, uncert } = result
const [linePoint, scatterPoint] = AllData
this.dataSourceList = [...list_dataSource, 'other']
const { list_dataSource } = result
this.dataSourceList = list_dataSource
this.currSelectedDataSource = list_dataSource[0]
this.appliedDataSource = list_dataSource[0]
this.equation = equation
this.handleResult(result)
} else {
this.$message.error(message)
}
} catch (error) {
console.error(error)
}
},
handleResult(result) {
const { AllData, equation, param, table, uncert } = result
//
if (AllData) {
const [linePoint, scatterPoint] = AllData
this.equation = equation
this.param = param
this.uncert = uncert
table.forEach((item, index) => {
item.id = index
})
this.list = table
this.generateTableId()
const series = []
series.push(
@ -253,22 +279,21 @@ export default {
zlevel: 20
})
this.option.series = series
} else {
this.$message.error(message)
}
} catch (error) {
console.error(error)
//
else {
this.option.series = []
}
},
beforeModalOpen() {
this.selectedRowKeys = []
this.getData()
},
//
handleRowClick(row, index) {
handleRowClick(row) {
this.model = cloneDeep(row)
this.currSelectedIndex = index
},
//
@ -298,18 +323,126 @@ export default {
}
}
console.log('%c [ 在位置插入 ]-297', 'font-size:13px; background:pink; color:#bf2c9f;', i)
this.list.splice(i, 0, {
channel: centroid,
energy
})
this.uncert.splice(i, 0, 0.5)
this.selectedRowKeys = [i]
this.generateTableId()
this.recalculate()
},
// tableid
generateTableId() {
this.list.forEach((item, index) => {
item.id = index
})
},
//
handleModify() {},
handleModify() {
if (this.selectedRowKeys.length) {
const centroid = parseFloat(this.model.channel)
const energy = parseFloat(this.model.energy)
if (Number.isNaN(centroid) || Number.isNaN(energy)) {
this.$message.warn('Format is invalid.')
return
}
if (centroid <= 100 || centroid >= 16342) {
this.$message.warn('Centroid must be in the range of analysis!')
return
}
const [currSelectedIndex] = this.selectedRowKeys
this.list[currSelectedIndex].channel = centroid
this.list[currSelectedIndex].energy = energy
this.uncert[currSelectedIndex] = 0
this.recalculate()
}
},
//
handleDelete() {},
handleDelete() {
if (this.selectedRowKeys.length) {
const [currSelectedIndex] = this.selectedRowKeys
this.list.splice(currSelectedIndex, 1)
this.uncert.splice(currSelectedIndex, 1)
this.generateTableId()
if (this.list.length) {
const selectedKey = this.selectedRowKeys[0]
if (selectedKey > this.list.length - 1) {
this.selectedRowKeys[0] = selectedKey - 1
}
} else {
this.selectedRowKeys = []
}
this.recalculate()
}
},
//
async recalculate() {
try {
this.isLoading = true
const { sampleId, inputFileName: fileName } = this.sampleData
const { success, result, message } = await postAction('/gamma/changeDataEnergy', {
sampleId,
fileName,
m_vCurCentroid: this.list.map(item => item.channel),
m_vCurEnergy: this.list.map(item => item.energy),
m_vCurUncert: this.uncert,
m_curParam: this.param
})
if (success) {
this.handleResult(result)
} else {
this.$message.error(message)
}
} catch (error) {
console.error(error)
} finally {
this.isLoading = false
}
},
//
async handleApply() {
try {
let curCalName = this.currSelectedDataSource
// InputPHD
if (!curCalName.includes('Input')) {
curCalName = `Input ${this.dataSourceList.filter(item => item.includes('Input')).length + 1}`
}
const { sampleId, inputFileName: fileName } = this.sampleData
const { success, result, message } = await postAction('/gamma/applyDataEnergy', {
m_vCurCentroid: this.list.map(item => item.channel),
m_vCurEnergy: this.list.map(item => item.energy),
m_vCurUncert: this.uncert,
m_curParam: this.param,
curCalName,
sampleId,
fileName
})
if (success) {
this.dataSourceList.push(curCalName)
} else {
this.$message.error(message)
}
} catch (error) {
console.error(error)
}
},
// DataSource
handleDataSourceClick(item) {
@ -400,9 +533,10 @@ export default {
.equation {
height: 40px;
line-height: 32px;
text-align: center;
background-color: #1b5465;
display: flex;
justify-content: center;
align-items: center;
}
.curve {