Commit 62e338b1 authored by 徐俊's avatar 徐俊

xujun

parent 8819516f
<template>
<div class="app-content layoutEmbedded" style="height: 76vh;overflow: auto;">
<a-spin :spinning="loading" style="width: 100%;height: 100%;">
......@@ -165,8 +164,36 @@ export default {
})
},
onProjectExport () {
this.$api.project.projectExport({ id: this.value }).then((res) => {
this.$message.success(data.msg)
this.loading = true
this.$api.project.projectExport({ id: this.value }, {
responseType: 'blob',
headers: {
'Accept': 'application/pdf'
}
}).then((res) => {
const contentType = res.headers['content-type']
if (contentType && contentType.includes('application/pdf')) {
let blob = new Blob([res.data], {
type: 'application/pdf'
});
const fileName = this.formData.projName + '.pdf';
let downloadElement = document.createElement('a')
let href = window.URL.createObjectURL(blob);
downloadElement.href = href;
downloadElement.download = fileName;
document.body.appendChild(downloadElement);
downloadElement.click();
document.body.removeChild(downloadElement);
window.URL.revokeObjectURL(href);
this.$message.success('导出成功')
} else {
this.$message.error('导出失败:返回格式错误')
}
this.loading = false
}).catch((error) => {
console.error('导出错误:', error)
this.$message.error('导出失败,请稍后重试')
this.loading = false
})
},
callback (key) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment