2023-07-17 19:37:46 +08:00
|
|
|
<template>
|
2023-09-21 19:41:16 +08:00
|
|
|
<custom-modal v-model="visible" :width="1200" :title="type == 1 || type == 3 ? 'ARR' : 'RRR'">
|
2023-07-20 14:11:37 +08:00
|
|
|
<a-spin :spinning="isLoading">
|
|
|
|
<pre>{{ content }}</pre>
|
|
|
|
</a-spin>
|
2023-07-17 19:37:46 +08:00
|
|
|
<div slot="custom-footer" style="text-align: center;">
|
|
|
|
<a-space :size="20">
|
2023-09-05 17:50:36 +08:00
|
|
|
<a-button type="primary" @click="handleOk">Export</a-button>
|
2023-07-17 19:37:46 +08:00
|
|
|
<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'
|
2023-09-05 17:50:36 +08:00
|
|
|
import { saveAs } from 'file-saver';
|
2023-09-05 19:06:19 +08:00
|
|
|
import SampleDataMixin from '../../SampleDataMixin'
|
2023-07-17 19:37:46 +08:00
|
|
|
export default {
|
2023-09-05 19:06:19 +08:00
|
|
|
mixins: [ModalMixin, SampleDataMixin],
|
2023-07-17 19:37:46 +08:00
|
|
|
props: {
|
|
|
|
type: {
|
2023-07-20 14:11:37 +08:00
|
|
|
type: Number
|
|
|
|
},
|
2023-08-11 09:25:28 +08:00
|
|
|
extraData: {
|
|
|
|
type: Object,
|
|
|
|
default: () => ({})
|
2023-07-17 19:37:46 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2023-07-20 14:11:37 +08:00
|
|
|
content: '',
|
2023-09-06 15:12:15 +08:00
|
|
|
isLoading: true,
|
|
|
|
fileName: ''
|
2023-07-17 19:37:46 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
async getContent() {
|
2023-07-20 14:11:37 +08:00
|
|
|
let url = ''
|
|
|
|
switch (this.type) {
|
2023-08-30 13:36:53 +08:00
|
|
|
case 1:
|
|
|
|
url = '/gamma/viewARR'
|
|
|
|
break
|
|
|
|
case 2:
|
|
|
|
url = '/gamma/viewRRR'
|
|
|
|
break
|
2023-07-20 14:11:37 +08:00
|
|
|
case 3:
|
|
|
|
url = '/spectrumAnalysis/viewARR'
|
|
|
|
break
|
2023-08-09 19:21:00 +08:00
|
|
|
case 4:
|
|
|
|
url = '/spectrumAnalysis/viewRRR'
|
2023-08-30 13:36:53 +08:00
|
|
|
break
|
2023-07-20 14:11:37 +08:00
|
|
|
}
|
2023-07-17 19:37:46 +08:00
|
|
|
try {
|
2023-07-20 14:11:37 +08:00
|
|
|
this.content = ''
|
|
|
|
this.isLoading = true
|
2023-09-05 19:06:19 +08:00
|
|
|
const { sampleId, inputFileName: fileName } = this.sampleData
|
|
|
|
const res = await getAction(url, {
|
|
|
|
sampleId,
|
|
|
|
fileName,
|
|
|
|
...this.extraData
|
|
|
|
})
|
2023-08-30 13:36:53 +08:00
|
|
|
if (res.success) {
|
2023-08-11 09:25:28 +08:00
|
|
|
this.content = res.result
|
2023-08-30 13:36:53 +08:00
|
|
|
} else {
|
2023-09-06 17:48:47 +08:00
|
|
|
this.content = ""
|
2023-08-11 09:25:28 +08:00
|
|
|
}
|
2023-07-17 19:37:46 +08:00
|
|
|
} catch (error) {
|
|
|
|
console.error(error)
|
2023-07-20 14:11:37 +08:00
|
|
|
} finally {
|
|
|
|
this.isLoading = false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
beforeModalOpen() {
|
2023-09-05 19:06:19 +08:00
|
|
|
this.getContent()
|
2023-09-05 17:50:36 +08:00
|
|
|
},
|
|
|
|
handleOk() {
|
2023-09-07 18:17:24 +08:00
|
|
|
this.fileName=""
|
2023-09-06 17:48:47 +08:00
|
|
|
if (this.content) {
|
|
|
|
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: '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) {
|
|
|
|
saveAs(strData, `${_this.fileName}.txt`)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
this.$message.warning("No data can be saved!")
|
|
|
|
}
|
2023-07-17 19:37:46 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="less" scoped>
|
|
|
|
pre {
|
2023-09-21 19:41:16 +08:00
|
|
|
height: calc(100vh - 350px);
|
2023-07-17 19:37:46 +08:00
|
|
|
padding: 5px;
|
|
|
|
overflow: auto;
|
|
|
|
background-color: #285367;
|
|
|
|
}
|
|
|
|
</style>
|