下载文件添加自定义文件名称的逻辑
实现beta的弹窗文件下载功能
This commit is contained in:
parent
301a42b93e
commit
c0139480f5
|
@ -33,7 +33,8 @@ export default {
|
|||
data() {
|
||||
return {
|
||||
content: '',
|
||||
isLoading: true
|
||||
isLoading: true,
|
||||
fileName: ''
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
@ -80,7 +81,27 @@ export default {
|
|||
},
|
||||
handleOk() {
|
||||
let strData = new Blob([this.content], { type: 'text/plain;charset=utf-8' });
|
||||
saveAs(strData, `${this.type == 1 || this.type == 3 ? 'ARR' : 'RRR'}.txt`)
|
||||
// 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');
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,16 @@
|
|||
<template>
|
||||
<custom-modal v-model="visible" :width="1000" title="Auto Process Log Viewer" :okHandler="handleOk">
|
||||
<custom-modal v-model="visible" :width="1000" title="Auto Process Log Viewer">
|
||||
<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">Save</a-button>
|
||||
<a-button @click="visible = false">Cancel</a-button>
|
||||
</a-space>
|
||||
</div>
|
||||
</custom-modal>
|
||||
</template>
|
||||
|
||||
|
@ -23,7 +29,8 @@ export default {
|
|||
},
|
||||
data() {
|
||||
return {
|
||||
content: ''
|
||||
content: '',
|
||||
fileName: ''
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
@ -31,7 +38,7 @@ export default {
|
|||
try {
|
||||
this.isLoading = true
|
||||
const { sampleId } = this.sampleData
|
||||
const res = await getAction(this.type == 1 ? '/gamma/viewAutomaticAnalysisLog' : '', {
|
||||
const res = await getAction(this.type == 1 ? '/gamma/viewAutomaticAnalysisLog' : '/gamma/viewAutomaticAnalysisLog', { // 自动分析日志接口暂用都是gammam,beta暂时没有
|
||||
sampleId
|
||||
})
|
||||
this.content = res
|
||||
|
@ -47,8 +54,24 @@ export default {
|
|||
},
|
||||
|
||||
handleOk() {
|
||||
let _this = this
|
||||
let strData = new Blob([this.content], { type: 'text/plain;charset=utf-8' });
|
||||
saveAs(strData, `Automatic Analysis Log.txt`)
|
||||
// saveAs(strData, `${this.type == 1 ?'Gamma-':'Beta-'}Automatic Analysis Log.txt`)
|
||||
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');
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<custom-modal v-model="visible" :width="750" title="QC Result">
|
||||
<a-table :loading="isLoading" :columns="columns" :dataSource="list" :pagination="false"> </a-table>
|
||||
<a-space slot="custom-footer" :size="20">
|
||||
<a-button type="primary">Save Text</a-button>
|
||||
<a-button type="primary" @click="SaveText">Save Text</a-button>
|
||||
<a-button type="primary">Save Excel</a-button>
|
||||
<a-button type="primary" @click="visible = false">Cancel</a-button>
|
||||
</a-space>
|
||||
|
@ -57,7 +57,9 @@ export default {
|
|||
this.columns = columns
|
||||
return {
|
||||
list: [],
|
||||
isLoading: false
|
||||
isLoading: false,
|
||||
text: '',
|
||||
fileName: ''
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
@ -124,6 +126,34 @@ export default {
|
|||
beforeModalOpen() {
|
||||
this.list = []
|
||||
this.getData()
|
||||
},
|
||||
SaveText() {
|
||||
this.text = `#QC RESULT\n${this.columns[0].title} ${this.columns[1].title} ${this.columns[2].title} ${this.columns[3].title}\n`
|
||||
this.list.forEach(item => {
|
||||
let str = ""
|
||||
str += `${item.qcFlags} `
|
||||
str += `${item.evaluationMetrics} `
|
||||
str += `${item.value} `
|
||||
str += `${item.status} \n`
|
||||
this.text+=str
|
||||
})
|
||||
let strData = new Blob([this.text], { type: 'text/plain;charset=utf-8' });
|
||||
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');
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
<div slot="custom-footer">
|
||||
<a-space :size="20">
|
||||
<a-button type="primary">Save Text</a-button>
|
||||
<a-button type="primary" @click="saveText">Save Text</a-button>
|
||||
<a-button type="primary">Save Excel</a-button>
|
||||
<a-button @click="visible = false">Cancel</a-button>
|
||||
</a-space>
|
||||
|
@ -17,6 +17,7 @@
|
|||
<script>
|
||||
import { getAction } from '@/api/manage'
|
||||
import ModalMixin from '@/mixins/ModalMixin'
|
||||
import { saveAs } from 'file-saver';
|
||||
export default {
|
||||
mixins: [ModalMixin],
|
||||
props: {
|
||||
|
@ -27,7 +28,8 @@ export default {
|
|||
data() {
|
||||
return {
|
||||
content: '',
|
||||
isLoading: true
|
||||
isLoading: true,
|
||||
fileName: ''
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
@ -55,6 +57,26 @@ export default {
|
|||
if (this.sampleId) {
|
||||
this.getContent()
|
||||
}
|
||||
},
|
||||
saveText() {
|
||||
let strData = new Blob([this.content], { type: 'text/plain;charset=utf-8' });
|
||||
// saveAs(strData, `Beta-View Sample Infomation.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');
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<template>
|
||||
<custom-modal v-model="visible" :width="1000" title="View Spectrum" :footer="null" destroyOnClose>
|
||||
<custom-modal v-model="visible" :width="1000" title="View Spectrum" destroyOnClose>
|
||||
<a-spin :spinning="isLoading">
|
||||
<a-tabs :animated="false">
|
||||
<a-tabs :animated="false" @change="handleTabChange">
|
||||
<a-tab-pane tab="Sample Spectrum" :key="1">
|
||||
<pre>{{ content.sample.join('\n') }}</pre>
|
||||
</a-tab-pane>
|
||||
|
@ -16,6 +16,12 @@
|
|||
</a-tab-pane>
|
||||
</a-tabs>
|
||||
</a-spin>
|
||||
<div slot="custom-footer">
|
||||
<a-space :size="20">
|
||||
<a-button type="primary" @click="handleOk">Save Text</a-button>
|
||||
<a-button @click="visible = false">Cancel</a-button>
|
||||
</a-space>
|
||||
</div>
|
||||
</custom-modal>
|
||||
</template>
|
||||
|
||||
|
@ -37,7 +43,9 @@ export default {
|
|||
qc: [],
|
||||
sample: []
|
||||
},
|
||||
isLoading: true
|
||||
isLoading: true,
|
||||
fileName: '',
|
||||
currTab: 1
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
@ -63,6 +71,40 @@ export default {
|
|||
if (this.sampleId) {
|
||||
this.getContent()
|
||||
}
|
||||
},
|
||||
handleTabChange(key) {
|
||||
this.currTab = key
|
||||
},
|
||||
handleOk() {
|
||||
let text = ""
|
||||
if (this.currTab==1) {
|
||||
text=this.content.sample.join('\n')
|
||||
} else if (this.currTab == 2) {
|
||||
text=this.content.gasBg.join('\n')
|
||||
}else if (this.currTab == 3) {
|
||||
text=this.content.detBg.join('\n')
|
||||
}else if (this.currTab == 4) {
|
||||
text=this.content.qc.join('\n')
|
||||
}
|
||||
console.log(text);
|
||||
let strData = new Blob([text], { type: 'text/plain;charset=utf-8' });
|
||||
// saveAs(strData, `GammaViewer Log.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');
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
<a-spin :spinning="isLoading">
|
||||
<pre class="data-processing-log">{{ text }}</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>
|
||||
<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>
|
||||
|
||||
|
@ -27,6 +27,7 @@ export default {
|
|||
return {
|
||||
text: "",
|
||||
isLoading: false,
|
||||
fileName: ''
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
@ -50,7 +51,23 @@ export default {
|
|||
},
|
||||
handleOk() {
|
||||
let strData = new Blob([this.text], { type: 'text/plain;charset=utf-8' });
|
||||
saveAs(strData, `GammaViewer Log.txt`)
|
||||
// saveAs(strData, `GammaViewer Log.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');
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
|
@ -897,7 +897,7 @@ export default {
|
|||
type: 'a-menu-item',
|
||||
title: 'Automatic Analysis Log',
|
||||
handler: () => {
|
||||
this.autoAnalysisMogModalType = 1
|
||||
this.autoAnalysisMogModalType = this.isGamma?1:this.isBetaGamma?2:1
|
||||
this.autoAnalysisMogModalVisible = true
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue
Block a user