|
@@ -4,10 +4,10 @@
|
|
|
<el-form-item label="导出格式" :label-width="formLabelWidth">
|
|
|
</el-form-item>
|
|
|
<el-radio-group v-model="exformat">
|
|
|
- <el-radio :value="doc">doc</el-radio>
|
|
|
- <el-radio :value="pdf">pdf</el-radio>
|
|
|
- <el-radio :value="HTML">HTML</el-radio>
|
|
|
- <el-radio :value="image">image</el-radio>
|
|
|
+ <el-radio label="2">doc</el-radio>
|
|
|
+ <el-radio label="1">pdf</el-radio>
|
|
|
+ <el-radio label="3">HTML</el-radio>
|
|
|
+ <el-radio label="4">image</el-radio>
|
|
|
</el-radio-group>
|
|
|
<!-- <div style="text-align: center;width: 100%;">
|
|
|
<el-transfer
|
|
@@ -70,13 +70,15 @@
|
|
|
import { ref, onMounted, reactive, provide, nextTick } from "vue"
|
|
|
import { ElMessage, ElButton, ElDialog, ElSelect } from "element-plus"
|
|
|
import { Edit, CaretBottom } from "@element-plus/icons-vue"
|
|
|
+import { requestblobfile, uploadFile } from "@/utils/request"
|
|
|
|
|
|
import fileUploads from "../components/fileuploads.vue";
|
|
|
const meshFileImgSrc = new URL("@/assets/img/open.png", import.meta.url).href;
|
|
|
|
|
|
let formLabelWidth = ref(90)
|
|
|
|
|
|
-let exformat = ref('pdf')
|
|
|
+let pid = ref()
|
|
|
+let exformat = ref('2')
|
|
|
|
|
|
let selectedvalue = ref([])
|
|
|
let selflietype = ref('Adobe PDF(*.pdf)')
|
|
@@ -95,4 +97,50 @@ let flietypelist = ref([
|
|
|
{ label:"All Image Files(*.png,*.jpg,*.jpeg,*.gif)", value:"img" },
|
|
|
])
|
|
|
|
|
|
+const exportreport = (id) => {
|
|
|
+ pid.value = id;
|
|
|
+ const params = {
|
|
|
+ transCode: "MDO0082",
|
|
|
+ pid: pid.value,
|
|
|
+ type: exformat.value
|
|
|
+ };
|
|
|
+
|
|
|
+ requestblobfile(params)
|
|
|
+ .then(res => {
|
|
|
+ // 1. 获取服务器返回的文件名(从 Content-Disposition)
|
|
|
+ const contentDisposition = res.headers['content-disposition'];
|
|
|
+ let fileName = `报告_${pid.value}.docx`; // 默认文件名(如果解析失败)
|
|
|
+
|
|
|
+ if (contentDisposition) {
|
|
|
+ const fileNameMatch = contentDisposition.match(/filename=(.+)/i);
|
|
|
+ if (fileNameMatch && fileNameMatch[1]) {
|
|
|
+ fileName = fileNameMatch[1].trim(); // 提取服务器返回的文件名
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 获取正确的 MIME 类型(从 Content-Type)
|
|
|
+ const contentType = res.headers['content-type'] || 'application/octet-stream';
|
|
|
+
|
|
|
+ // 3. 创建 Blob 并下载
|
|
|
+ const blob = new Blob([res.data], { type: contentType });
|
|
|
+ const link = document.createElement('a');
|
|
|
+ const blobUrl = URL.createObjectURL(blob);
|
|
|
+ link.href = blobUrl;
|
|
|
+ link.download = fileName; // 使用服务器返回的文件名
|
|
|
+ document.body.appendChild(link);
|
|
|
+ link.click();
|
|
|
+
|
|
|
+ // 清理资源
|
|
|
+ URL.revokeObjectURL(blobUrl);
|
|
|
+ document.body.removeChild(link);
|
|
|
+ })
|
|
|
+ .catch(err => {
|
|
|
+ ElMessage.error('导出报告失败');
|
|
|
+ console.error('导出错误:', err);
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
+defineExpose({
|
|
|
+ exportreport
|
|
|
+})
|
|
|
</script>
|