From 9aac4f14188e8c7697290ff8420428f1944656da Mon Sep 17 00:00:00 2001 From: "15881625488@163.com" <15881625488@163.com> Date: Wed, 1 Apr 2026 16:20:36 +0800 Subject: [PATCH] =?UTF-8?q?fix:[=E6=A8=A1=E6=9D=BF=E7=AE=A1=E7=90=86]?= =?UTF-8?q?=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/business/study/studyFormFill.js | 10 ++ .../business/comps/template/comps/gsp/GSP015.vue | 130 ++++++++++++++++----- 2 files changed, 109 insertions(+), 31 deletions(-) diff --git a/src/api/business/study/studyFormFill.js b/src/api/business/study/studyFormFill.js index 009ca76..119f8b8 100644 --- a/src/api/business/study/studyFormFill.js +++ b/src/api/business/study/studyFormFill.js @@ -24,6 +24,16 @@ export function studyFormFill_exportDetail(query) { params: query }) } + +export function studyFormFill_exportTbByFileUrl(query) { + return request({ + url: '/system/business/studyFormFill/exportTbByFileUrl', + method: 'get', + params: query + }) +} + + export function studyFormFill_exportByFileUrl(query) { return request({ url: '/system/business/studyFormFill/exportByFileUrl', diff --git a/src/views/business/comps/template/comps/gsp/GSP015.vue b/src/views/business/comps/template/comps/gsp/GSP015.vue index 3f0c67e..2478c32 100644 --- a/src/views/business/comps/template/comps/gsp/GSP015.vue +++ b/src/views/business/comps/template/comps/gsp/GSP015.vue @@ -18,7 +18,7 @@ @click="onExportXqjyxx">导出 + }" ref="html2PdfXqjyxx" @beforeDownload="handleBeforeDownload" @progress="onProgressXqjyxx">
@@ -85,9 +85,9 @@ @click="onAdd('ecDataList')">新增 导出 - + }" ref="html2PdfEcxsxx" @beforeDownload="handleBeforeDownload" @progress="onProgressEcxsxx">
-
-
-
- - {{ - $t('template.common.deleteBtn') - }} - -
- - - - -
-
+
+
+
+ + {{ + $t('template.common.deleteBtn') + }} + +
+ + + + +
+
@@ -161,7 +161,9 @@ import { getuuid, justUpdateFilledFormData } from "@/utils/index"; import { isCommonUnit } from "@/utils/conTools"; import { convertConcentration } from "@/utils/conConverter";//浓度单位转换 import { volumeConverter } from "@/utils/volConverter";//体积单位转换 +import { getToken } from "@/utils/auth" import moment from "moment";//时间处理 +import { studyFormFill_exportTbByFileUrl } from "@/api/business/study/studyFormFill" import { getBaseInfoFormConfig, getRemarkFormConfig, getYbsmFormConfig, getQyTableColumns, getJyTableColumns, getEcFormConfig } from "../../formConfig/gsp/gsp015"; const refConfig = { baseInfoRef: "baseInfoRef", @@ -213,12 +215,78 @@ export default { return { refConfig, currentIndex: -1, + appTitle: process.env.VUE_APP_TITLE, + baseUrl: process.env.VUE_APP_FILE_DOMAIN, + uploadFileUrl: process.env.VUE_APP_BASE_API + '/file/upload', // 上传文件服务器地址 }; }, mounted() { }, methods: { + //获取文件blog + async handleBeforeDownload({ html2pdf, options, pdfContent }) { + this.$modal.loading() + // 1. 使用 html2pdf 手动构建 PDF,并获取底层的 jsPDF 实例 + const pdf = await html2pdf() + .set(options) // 应用你的配制选项 + .from(pdfContent) // 指定 PDF 内容 + .toPdf() // 转换为 PDF + .get('pdf'); // 获取 jsPDF 实例 + + // 2. 从 jsPDF 实例中输出 Blob 对象 + const blob = pdf.output('blob'); + + // 3. 将 Blob 上传到你的服务器 + await this.uploadPdfToServer(blob); + + // 注意:如果你还想让文件自动下载,可以在这里调用 .save() + // pdf.save('my-document.pdf'); + }, + //上传到服务器 + async uploadPdfToServer(blob) { + let that=this + const formData = new FormData(); + formData.append('file', blob, 'hxhq-export-form.pdf'); + try { + const response = await fetch(this.uploadFileUrl, { + method: 'POST', + headers: { + Authorization: "Bearer " + getToken(), + }, + body: formData + }); + // 检查响应状态 + if (!response.ok) { + // 如果响应不成功,可以尝试获取错误信息 + const errorData = await response.json().catch(() => ({})); + throw new Error(errorData.message || `HTTP error! status: ${response.status}`); + } + // 获取 JSON 数据 + const data = await response.json(); + // console.log('返回的JSON数据:', data); + if (data.code == 200) { + studyFormFill_exportTbByFileUrl( + { + url: data.data.url, + studyFormFillId:that.formData.id, + version: that.appTitle, + lang: that.$store.getters.language.split("_")[0] + } + ).then(response => { + window.open(that.baseUrl + response.msg) + }).finally(() => { + this.$modal.closeLoading() + }) + } else { + this.$modal.msgError(data.msg) + this.$modal.closeLoading() + } + } catch (error) { + this.$modal.msgError("导出失败,稍后再试") + this.$modal.closeLoading() + } + }, onConfigComplete(e, type) { const { rowData, headerSelectFields } = e; let params = {