beta qc Result 弹窗表格字段调整

qc Result 弹窗下载txt 功能改成接口调用
This commit is contained in:
任珮宇 2023-11-20 14:07:24 +08:00
parent aa8dc51b86
commit 7a84831ff8

View File

@ -12,6 +12,7 @@
<script>
import { getAction, getFileAction } from '@/api/manage'
import ModalMixin from '@/mixins/ModalMixin'
import { fetchAndDownload } from '@/utils/file'
import { saveAs } from 'file-saver'
import SampleDataMixin from '@/views/spectrumAnalysis/SampleDataMixin'
@ -31,7 +32,7 @@ const columns = [
dataIndex: 'value',
align: 'center',
customRender: (text) => {
if (text !== 'Match' && text !== 'UnMatch') {
if (text !== 'Match' && text !== 'UnMatch' && text !== 'None') {
return parseFloat(Number(text).toPrecision(6))
} else {
return text
@ -142,37 +143,21 @@ export default {
this.list = []
this.getData()
},
SaveText() {
this.fileName = ''
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 name = this.newSampleData.inputFileName.split('.')[0]
let strData = new Blob([this.text], { type: 'text/plain;charset=utf-8' })
saveAs(strData, `${name}_QC Result.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`)
// }
// },
// })
async SaveText() {
let url = '/spectrumAnalysis/exportQCResultTXT'
const { sampleId, inputFileName: fileName, dbName, detFileName, gasFileName } = this.newSampleData
let params = {
sampleId: sampleId || '',
dbName,
sampleFileName: fileName,
gasFileName,
detFileName,
}
try {
await fetchAndDownload(url, params, 'get')
} catch (error) {
console.error(error)
}
},
// Excel
handleExportToExcel() {
@ -195,34 +180,6 @@ export default {
saveAs(blob, `${name}_QC Result`)
}
})
// let _this = this
// this.$confirm({
// title: 'Please enter file name',
// content: (h) => <a-input v-model={_this.fileName_excel} />,
// 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_excel) {
// let params = {
// sampleId: sampleId || '',
// fileName,
// }
// getFileAction('/spectrumAnalysis/exportQCResult', 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_excel}`)
// }
// })
// }
// },
// })
} else {
this.$message.warning('No downloadable data')
}