AnalysisSystemForRadionucli.../src/views/spectrumAnalysis/components/Modals/NuclideActivityAndMDCModal.vue

290 lines
7.8 KiB
Vue

<template>
<custom-modal
v-model="visible"
:width="1231"
title="Nuclide Activity and MDC"
class="nuclide-activity-and-mdc-modal"
:footer="null"
>
<!-- 顶部搜索栏 -->
<a-form-model class="search-form">
<div class="time-pickers">
<a-form-model-item label="Activity reference time">
<custom-date-picker show-time v-model="queryParam.activityReferenceTime" />
</a-form-model-item>
<a-form-model-item label="Concentration reference time">
<custom-date-picker show-time v-model="queryParam.concentrationReferenceTime" />
</a-form-model-item>
</div>
<a-space class="operators" :size="20">
<a-button :type="compareVisible ? 'grey' : 'primary'" @click="handleComparision">
<img src="@/assets/images/spectrum/comparation.png" />
{{ compareVisible ? 'Cancel comparison' : 'Comparison' }}
</a-button>
<a-button type="primary" @click="handleExportToExcel">
<img src="@/assets/images/spectrum/download.png" />
Export to Excel
</a-button>
</a-space>
</a-form-model>
<!-- 顶部搜索栏结束 -->
<a-spin :spinning="isLoading">
<!-- 主体部分 -->
<div v-if="compareVisible" class="comparison-list">
<div class="comparison-list-item">
<div class="comparison-list-item-title">ARMD</div>
<custom-table :list="list" :scroll="{ y: 230 }" :columns="columns"></custom-table>
</div>
<div class="comparison-list-item">
<div class="comparison-list-item-title">IDC</div>
<custom-table :list="compareList" :scroll="{ y: 230 }" :columns="columns"></custom-table>
</div>
</div>
<custom-table v-else :columns="columns" :list="list" :scroll="{ y: 460 }" :canSelect="false"></custom-table>
</a-spin>
</custom-modal>
</template>
<script>
import { getAction, getFileAction } from '@/api/manage'
import ModalMixin from '@/mixins/ModalMixin'
import { saveAs } from 'file-saver'
import SampleDataMixin from '../../SampleDataMixin'
const columns = [
{
title: 'Nuclide',
dataIndex: 'nuclide',
},
{
title: 'HalfLife',
dataIndex: 'halfLife',
},
{
title: 'Energy (keV)',
dataIndex: 'energy',
customRender: (text) => {
return text && text !== 'null' ? parseFloat(Number(text).toPrecision(6)) : text
},
},
{
title: 'Yield (%)',
dataIndex: 'yield',
customRender: (text) => {
return text && text !== 'null' ? parseFloat(Number(text).toPrecision(6)) : text
},
},
{
title: 'Efficiency',
dataIndex: 'efficiency',
customRender: (text) => {
return text && text !== 'null' ? parseFloat(Number(text).toPrecision(6)) : text
},
},
{
title: 'Activity (Bq)',
dataIndex: 'activity',
customRender: (text) => {
return text && text !== 'null' ? parseFloat(Number(text).toPrecision(6)) : text
},
},
{
title: 'Act Err (%)',
dataIndex: 'actErr',
customRender: (text) => {
return text && text !== 'null' ? parseFloat(Number(text).toPrecision(6)) : text
},
},
{
title: 'MDA (Bq)',
dataIndex: 'mda',
customRender: (text) => {
return text && text !== 'null' ? parseFloat(Number(text).toPrecision(6)) : text
},
},
{
title: 'Conc (uBq/m3)',
dataIndex: 'conc',
customRender: (text) => {
return text && text !== 'null' ? parseFloat(Number(text).toPrecision(6)) : text
},
},
{
title: 'MDC (uBq/m3)',
dataIndex: 'mdc',
customRender: (text) => {
return text && text !== 'null' ? parseFloat(Number(text).toPrecision(6)) : text
},
},
]
export default {
mixins: [ModalMixin, SampleDataMixin],
data() {
this.columns = columns
return {
queryParam: {
activityReferenceTime: undefined,
concentrationReferenceTime: undefined,
},
compareVisible: false,
isLoading: false,
list: [],
compareList: [],
fileName: '',
}
},
methods: {
// 切换比较
handleComparision() {
this.compareVisible = !this.compareVisible
},
async getInfo() {
try {
this.isLoading = true
const { sampleId, inputFileName: fileName } = this.sampleData
const { success, result, message } = await getAction('/gamma/radionuclideActivity', {
sampleId,
fileName,
})
if (success) {
const { dateTime_act_ref, dateTime_con_ref, table } = result
this.queryParam.activityReferenceTime = dateTime_act_ref
this.queryParam.concentrationReferenceTime = dateTime_con_ref
this.list = table
} else {
this.$message.error(message)
}
} catch (error) {
console.error(error)
} finally {
this.isLoading = false
}
},
beforeModalOpen() {
this.compareVisible = false
this.getInfo()
},
// 导出到Excel
handleExportToExcel() {
this.fileName = ''
const { sampleId, inputFileName: fileName } = this.sampleData
if (this.list.length > 0) {
let name = this.newSampleData.inputFileName.split('.')[0]
let params = {
sampleId,
fileName,
}
getFileAction('/gamma/exportRadionuclideActivity', params).then((res) => {
if (res.code && res.code == 500) {
this.$message.warning('This operation fails. Contact your system administrator')
} else {
const blob = new Blob([res], { type: 'application/vnd.ms-excel' })
saveAs(blob, `${name}_Nuclide Activity and MDC`)
}
})
// let _this = this
// this.$confirm({
// title: 'Please enter file name',
// content: h => <a-input v-model={_this.fileName} />,
// okText: 'Cancle',
// cancelText: 'Save',
// okButtonProps: {style: {backgroundColor: "#b98326", color: "#fff", borderColor: "transparent"}},
// cancelButtonProps: {style: {color: "#fff", backgroundColor: "#31aab0", borderColor: "transparent"}},
// onOk() {
// console.log('Cancel');
// },
// onCancel() {
// if (_this.fileName) {
// let params = {
// sampleId,
// fileName
// }
// getFileAction('/gamma/exportRadionuclideActivity', params).then(res => {
// if (res.code && res.code == 500) {
// this.$message.warning("This operation fails. Contact your system administrator")
// } else {
// const blob = new Blob([res], { type: "application/vnd.ms-excel" })
// saveAs(blob, `${_this.fileName}`)
// }
// })
// }
// },
// });
} else {
this.$message.warning('No downloadable data')
}
},
},
}
</script>
<style lang="less" scoped>
.nuclide-activity-and-mdc-modal {
::v-deep {
.ant-modal-body {
padding: 16px;
}
}
}
.search-form {
display: flex;
justify-content: space-between;
margin-bottom: 15px;
.time-pickers {
display: flex;
.ant-form-item {
margin-bottom: 0;
&:nth-child(2) {
margin-left: 20px;
}
::v-deep {
.ant-form-item {
&-label {
> label {
color: #ade6ee;
}
}
&-control-wrapper {
width: 210px;
}
}
}
}
}
.operators {
.ant-btn {
display: flex;
align-items: center;
img {
margin-right: 10px;
}
}
}
}
.comparison-list {
padding-top: 15px;
border-top: 1px solid rgba(13, 109, 118, 0.5);
&-item {
&-title {
color: #0cebc9;
}
&:last-child {
margin-top: 12px;
}
}
}
</style>