2023-07-17 19:37:46 +08:00
|
|
|
<template>
|
|
|
|
<custom-modal v-model="visible" :width="750" title="Sample Infomation">
|
2023-08-30 13:36:53 +08:00
|
|
|
<a-spin :spinning="isLoading">
|
|
|
|
<div class="sample-infomation">
|
|
|
|
<a-form-model :labelCol="{ style: { width: '150px', textAlign: 'left' } }">
|
|
|
|
<a-row>
|
|
|
|
<a-col :span="12" v-for="(item, index) in columns" :key="index">
|
|
|
|
<a-form-model-item :label="item.title">
|
|
|
|
{{ item.key == 'sampleId' && !isLoading ? sampleId : data[item.key] }}
|
|
|
|
</a-form-model-item>
|
|
|
|
</a-col>
|
|
|
|
</a-row>
|
|
|
|
</a-form-model>
|
|
|
|
</div>
|
|
|
|
</a-spin>
|
2023-07-17 19:37:46 +08:00
|
|
|
<div slot="custom-footer" style="text-align: center;">
|
|
|
|
<a-space :size="20">
|
2023-09-07 17:30:07 +08:00
|
|
|
<a-button type="primary" @click="handleExportToExcel">Export to Excel</a-button>
|
2023-07-17 19:37:46 +08:00
|
|
|
<a-button @click="visible = false">Close</a-button>
|
|
|
|
</a-space>
|
|
|
|
</div>
|
|
|
|
</custom-modal>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2023-09-07 17:30:07 +08:00
|
|
|
import { getAction, getFileAction } from '@/api/manage'
|
2023-07-17 19:37:46 +08:00
|
|
|
import ModalMixin from '@/mixins/ModalMixin'
|
2023-09-07 17:30:07 +08:00
|
|
|
import SampleDataMixin from '@/views/spectrumAnalysis/SampleDataMixin'
|
|
|
|
import { saveAs } from 'file-saver';
|
2023-07-17 19:37:46 +08:00
|
|
|
|
|
|
|
const columns = [
|
|
|
|
{
|
|
|
|
title: 'Station Id',
|
|
|
|
key: 'stationId'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Detector Id',
|
|
|
|
key: 'detectorId'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Sample Id',
|
|
|
|
key: 'sampleId'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Sample Geometry',
|
|
|
|
key: 'sampleGeometry'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Sample Quantity',
|
|
|
|
key: 'sampleQuantity'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Sample Type',
|
|
|
|
key: 'sampleType'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Collection Start',
|
2023-08-30 13:36:53 +08:00
|
|
|
key: 'collectStart'
|
2023-07-17 19:37:46 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Sampling Time',
|
|
|
|
key: 'samplingTime'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Collection Stop',
|
2023-08-30 13:36:53 +08:00
|
|
|
key: 'collectStop'
|
2023-07-17 19:37:46 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Decay Time',
|
|
|
|
key: 'decayTime'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Acquisition Start',
|
|
|
|
key: 'acquisitionStart'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Acquisition Time',
|
|
|
|
key: 'acquisitionTime'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Acquisition Stop',
|
|
|
|
key: 'acquisitionStop'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Avg Flow Rate',
|
|
|
|
key: 'avgFlowRate'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
export default {
|
2023-09-07 17:30:07 +08:00
|
|
|
mixins: [ModalMixin, SampleDataMixin],
|
2023-08-30 13:36:53 +08:00
|
|
|
props: {
|
|
|
|
sampleId: {
|
|
|
|
type: Number
|
|
|
|
}
|
|
|
|
},
|
2023-07-17 19:37:46 +08:00
|
|
|
data() {
|
|
|
|
this.columns = columns
|
|
|
|
return {
|
2023-08-30 13:36:53 +08:00
|
|
|
isLoading: false,
|
2023-09-07 17:30:07 +08:00
|
|
|
data: {},
|
|
|
|
fileName: ''
|
2023-08-30 13:36:53 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
async getInfo() {
|
|
|
|
try {
|
|
|
|
this.isLoading = true
|
|
|
|
const { success, result, message } = await getAction('/gamma/sampleInformation', {
|
|
|
|
sampleId: this.sampleId
|
|
|
|
})
|
|
|
|
if (success) {
|
|
|
|
this.data = result
|
|
|
|
} else {
|
|
|
|
this.$message.error(message)
|
|
|
|
}
|
|
|
|
} catch (error) {
|
|
|
|
console.error(error)
|
|
|
|
} finally {
|
|
|
|
this.isLoading = false
|
2023-07-17 19:37:46 +08:00
|
|
|
}
|
2023-08-30 13:36:53 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
beforeModalOpen() {
|
|
|
|
this.data = {}
|
|
|
|
this.getInfo()
|
2023-09-07 17:30:07 +08:00
|
|
|
},
|
|
|
|
// 导出到Excel
|
|
|
|
handleExportToExcel() {
|
|
|
|
if (Object.keys(this.data).length > 0) {
|
|
|
|
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) {
|
|
|
|
_this.visible = false
|
|
|
|
let params = {
|
|
|
|
// sampleId: "426530",
|
|
|
|
// fileName: "CAX05_001-20230731_1528_S_FULL_37563.6.PHD"
|
|
|
|
sampleId: this.sampleId,
|
|
|
|
fileName: this.sampleData.fileName
|
|
|
|
}
|
|
|
|
getFileAction('/gamma/exportSampleInformation', 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")
|
|
|
|
}
|
2023-07-17 19:37:46 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="less" scoped>
|
|
|
|
.sample-infomation {
|
|
|
|
background-color: #143644;
|
|
|
|
padding: 20px;
|
|
|
|
|
|
|
|
.ant-form-item {
|
|
|
|
margin-bottom: 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|