feat: Energy的增/删/改及Apply操作,Peak Comment和GeneralComment接口对接
This commit is contained in:
parent
ef3a022528
commit
e4edd1abfd
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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按钮
|
||||
|
|
|
@ -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,46 +227,12 @@ 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
|
||||
|
||||
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
|
||||
this.handleResult(result)
|
||||
} else {
|
||||
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() {
|
||||
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()
|
||||
},
|
||||
|
||||
// 生成table中数据的id,用以选中
|
||||
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
|
||||
// 如果沒选中以Input开头的,也就是选中了PHD之类的
|
||||
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 {
|
||||
|
|
Loading…
Reference in New Issue
Block a user