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