|
|
|
@ -139,11 +139,16 @@ |
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
<script> |
|
|
|
|
import util from "@/libs/util"; |
|
|
|
|
import Setting from '@/setting' |
|
|
|
|
import Util from '@/libs/util' |
|
|
|
|
import Axios from 'axios' |
|
|
|
|
export default { |
|
|
|
|
data () { |
|
|
|
|
return { |
|
|
|
|
reportId: this.$route.query.reportId, |
|
|
|
|
headers: { |
|
|
|
|
token: sessionStorage.getItem('token') |
|
|
|
|
}, |
|
|
|
|
title: "实验报告", |
|
|
|
|
form: { |
|
|
|
|
className: "", |
|
|
|
@ -221,7 +226,7 @@ export default { |
|
|
|
|
this.expData = list |
|
|
|
|
this.loading = false |
|
|
|
|
}, |
|
|
|
|
exportPage () { |
|
|
|
|
async exportPage () { |
|
|
|
|
this.exporting = true |
|
|
|
|
const form = Object.assign(this.form, this.infoData) |
|
|
|
|
const list = JSON.parse(JSON.stringify(this.expData)) |
|
|
|
@ -237,16 +242,20 @@ export default { |
|
|
|
|
if (form[i] && typeof form[i] === 'string') form[i] = form[i].replace(/<[^>]+>/g, '') |
|
|
|
|
} |
|
|
|
|
form.purpose = form.purpose.replace(/<[^>]+>/g, '') |
|
|
|
|
this.$post(this.project ? this.api.exportBankExperimentReport : this.api.exportLabReport, { |
|
|
|
|
...form, |
|
|
|
|
experimentalData: list |
|
|
|
|
}).then(res => { |
|
|
|
|
console.log(res) |
|
|
|
|
util.downloadFileDirect(`实验报告.docx`, new Blob([res])) |
|
|
|
|
this.exporting = false |
|
|
|
|
}).catch(res => { |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
const res = await Axios.post(this.api[this.project ? 'exportBankExperimentReport' : 'exportLabReport'], { |
|
|
|
|
...form, |
|
|
|
|
experimentalData: list |
|
|
|
|
}, { |
|
|
|
|
headers: this.headers, |
|
|
|
|
responseType: 'blob' |
|
|
|
|
}) |
|
|
|
|
const name = res.headers['content-disposition'] |
|
|
|
|
Util.downloadFileDirect(name ? decodeURI(name) : `实验报告.docx`, new Blob([res.data])) |
|
|
|
|
} finally { |
|
|
|
|
this.exporting = false |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|