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

View File

@ -56,7 +56,7 @@
<a-button type="primary">Save</a-button> <a-button type="primary">Save</a-button>
</div> </div>
<div> <div>
<a-button type="primary">Apply</a-button> <a-button type="primary" @click="handleApply">Apply</a-button>
</div> </div>
</div> </div>
</div> </div>
@ -68,7 +68,7 @@
<!-- curve --> <!-- curve -->
<title-over-border class="mt-20" title="curve"> <title-over-border class="mt-20" title="curve">
<div class="curve"> <div class="curve">
<custom-chart :option="option" /> <custom-chart :option="option" :opts="opts" />
</div> </div>
</title-over-border> </title-over-border>
</div> </div>
@ -102,7 +102,7 @@
import ModalMixin from '@/mixins/ModalMixin' import ModalMixin from '@/mixins/ModalMixin'
import TitleOverBorder from '../TitleOverBorder.vue' import TitleOverBorder from '../TitleOverBorder.vue'
import CustomChart from '@/components/CustomChart/index.vue' import CustomChart from '@/components/CustomChart/index.vue'
import { getAction } from '@/api/manage' import { getAction, postAction } from '@/api/manage'
import { cloneDeep } from 'lodash' import { cloneDeep } from 'lodash'
import { buildLineSeries } from '@/utils/chartHelper' import { buildLineSeries } from '@/utils/chartHelper'
import SampleDataMixin from '../../SampleDataMixin' import SampleDataMixin from '../../SampleDataMixin'
@ -143,6 +143,17 @@ const initialOption = {
right: 10, right: 10,
bottom: 0 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: { xAxis: {
min: 1, min: 1,
max: 'dataMax', max: 'dataMax',
@ -198,7 +209,10 @@ export default {
selectedRowKeys: [], selectedRowKeys: [],
model: {}, model: {},
currSelectedDataSource: '', currSelectedDataSource: '',
appliedDataSource: '' appliedDataSource: '',
opts: {
notMerge: true
}
} }
}, },
methods: { methods: {
@ -213,46 +227,12 @@ export default {
this.isLoading = false this.isLoading = false
if (success) { if (success) {
console.log('%c [ ]-220', 'font-size:13px; background:pink; color:#bf2c9f;', result) console.log('%c [ ]-220', 'font-size:13px; background:pink; color:#bf2c9f;', result)
const { AllData, equation, list_dataSource, param, table, uncert } = result const { list_dataSource } = result
const [linePoint, scatterPoint] = AllData this.dataSourceList = list_dataSource
this.dataSourceList = [...list_dataSource, 'other']
this.currSelectedDataSource = list_dataSource[0] this.currSelectedDataSource = list_dataSource[0]
this.appliedDataSource = list_dataSource[0] this.appliedDataSource = list_dataSource[0]
this.equation = equation this.handleResult(result)
table.forEach((item, index) => {
item.id = index
})
this.list = table
const series = []
series.push(
buildLineSeries(
'LineSeries',
linePoint.pointlist.map(({ x, y }) => [x, y]),
`rgb(${linePoint.color})`
)
)
series.push({
type: 'scatter',
data: scatterPoint.pointlist.map(({ x, y }) => {
return {
value: [x, y],
itemStyle: {
color: scatterPoint.color,
borderWidth: 0
}
}
}),
emphasis: {
disabled: true
},
animation: false,
zlevel: 20
})
this.option.series = series
} else { } else {
this.$message.error(message) this.$message.error(message)
} }
@ -261,14 +241,59 @@ export default {
} }
}, },
handleResult(result) {
const { AllData, equation, param, table, uncert } = result
//
if (AllData) {
const [linePoint, scatterPoint] = AllData
this.equation = equation
this.param = param
this.uncert = uncert
this.list = table
this.generateTableId()
const series = []
series.push(
buildLineSeries(
'LineSeries',
linePoint.pointlist.map(({ x, y }) => [x, y]),
`rgb(${linePoint.color})`
)
)
series.push({
type: 'scatter',
data: scatterPoint.pointlist.map(({ x, y }) => {
return {
value: [x, y],
itemStyle: {
color: scatterPoint.color,
borderWidth: 0
}
}
}),
emphasis: {
disabled: true
},
animation: false,
zlevel: 20
})
this.option.series = series
}
//
else {
this.option.series = []
}
},
beforeModalOpen() { beforeModalOpen() {
this.selectedRowKeys = []
this.getData() this.getData()
}, },
// //
handleRowClick(row, index) { handleRowClick(row) {
this.model = cloneDeep(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, { this.list.splice(i, 0, {
channel: centroid, channel: centroid,
energy 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 // DataSource
handleDataSourceClick(item) { handleDataSourceClick(item) {
@ -400,9 +533,10 @@ export default {
.equation { .equation {
height: 40px; height: 40px;
line-height: 32px;
text-align: center;
background-color: #1b5465; background-color: #1b5465;
display: flex;
justify-content: center;
align-items: center;
} }
.curve { .curve {