118 lines
2.8 KiB
Vue
118 lines
2.8 KiB
Vue
<template>
|
|
<custom-modal v-model="visible" :width="1000" :title="type == 1 || type == 3 ? 'ARR' : 'RRR'">
|
|
<a-spin :spinning="isLoading">
|
|
<pre>{{ content }}</pre>
|
|
</a-spin>
|
|
<div slot="custom-footer" style="text-align: center;">
|
|
<a-space :size="20">
|
|
<a-button type="primary" @click="handleOk">Export</a-button>
|
|
<a-button @click="visible = false">Cancel</a-button>
|
|
</a-space>
|
|
</div>
|
|
</custom-modal>
|
|
</template>
|
|
|
|
<script>
|
|
import ModalMixin from '@/mixins/ModalMixin'
|
|
import { getAction } from '../../../../api/manage'
|
|
import { saveAs } from 'file-saver';
|
|
export default {
|
|
mixins: [ModalMixin],
|
|
props: {
|
|
type: {
|
|
type: Number
|
|
},
|
|
sampleId: {
|
|
type: Number
|
|
},
|
|
extraData: {
|
|
type: Object,
|
|
default: () => ({})
|
|
}
|
|
},
|
|
data() {
|
|
return {
|
|
content: '',
|
|
isLoading: true,
|
|
fileName: ''
|
|
}
|
|
},
|
|
methods: {
|
|
async getContent() {
|
|
let url = ''
|
|
|
|
console.log('%c [ ]-42', 'font-size:13px; background:pink; color:#bf2c9f;', this.type)
|
|
switch (this.type) {
|
|
case 1:
|
|
url = '/gamma/viewARR'
|
|
break
|
|
case 2:
|
|
url = '/gamma/viewRRR'
|
|
break
|
|
case 3:
|
|
url = '/spectrumAnalysis/viewARR'
|
|
break
|
|
case 4:
|
|
url = '/spectrumAnalysis/viewRRR'
|
|
break
|
|
}
|
|
try {
|
|
this.content = ''
|
|
this.isLoading = true
|
|
const res = await getAction(url, { sampleId: this.sampleId, ...this.extraData })
|
|
if (res.success) {
|
|
this.content = res.result
|
|
} else {
|
|
this.content = res
|
|
}
|
|
} catch (error) {
|
|
console.error(error)
|
|
} finally {
|
|
this.isLoading = false
|
|
}
|
|
},
|
|
|
|
beforeModalOpen() {
|
|
|
|
console.log('%c [ ]-75', 'font-size:13px; background:pink; color:#bf2c9f;', this.sampleId)
|
|
if (this.sampleId) {
|
|
this.getContent()
|
|
}
|
|
},
|
|
handleOk() {
|
|
let strData = new Blob([this.content], { type: 'text/plain;charset=utf-8' });
|
|
// if (this.type == 1 || this.type == 3) {
|
|
// saveAs(strData, `${this.type == 1 ?'Gamma-':'Beta-'} ARR.txt`)
|
|
// } else {
|
|
// saveAs(strData, `${this.type == 2 ?'Gamma-':'Beta-'} RRR.txt`)
|
|
// }
|
|
let _this = this
|
|
this.$confirm({
|
|
title: 'Please enter file name',
|
|
content: h => <a-input v-model={_this.fileName} />,
|
|
okText: 'Save',
|
|
cancelText: 'Cancle',
|
|
onOk() {
|
|
if (_this.fileName) {
|
|
_this.visible = false
|
|
saveAs(strData, `${_this.fileName}.txt`)
|
|
}
|
|
},
|
|
onCancel() {
|
|
console.log('Cancel');
|
|
},
|
|
});
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="less" scoped>
|
|
pre {
|
|
height: 450px;
|
|
padding: 5px;
|
|
overflow: auto;
|
|
background-color: #285367;
|
|
}
|
|
</style>
|