From b74bc2d1e7f004b218dcf8ebb8907587bd0a6105 Mon Sep 17 00:00:00 2001 From: yuance <182865460@qq.com> Date: Wed, 4 Feb 2026 17:12:16 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E9=A1=B9=E7=9B=AE=E7=AE=A1=E7=90=86-?= =?UTF-8?q?=E5=8F=96=E8=AF=81=E5=8D=95-=E4=BC=98=E5=8C=96=E5=8F=96?= =?UTF-8?q?=E8=AF=81=E5=8D=95=E5=AF=BC=E5=87=BAword=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/ai/auditContent/index.ts | 37 ++++++++++ .../components/components/EvidenceModal.vue | 74 ++++++++++++++++++- 2 files changed, 107 insertions(+), 4 deletions(-) diff --git a/src/api/ai/auditContent/index.ts b/src/api/ai/auditContent/index.ts index 2b36fb8..f4aba6d 100644 --- a/src/api/ai/auditContent/index.ts +++ b/src/api/ai/auditContent/index.ts @@ -777,4 +777,41 @@ export async function generateAuditEvidence(data: { return res.data; } return Promise.reject(new Error(res.data.message)); +} + +/** + * 下载审计取证单Word文档 + */ +export async function downloadAuditEvidence(data: { + caseIndex?: string; + pageIndex?: string; + pageTotal?: string; + projectName?: string; + auditedTarget?: string; + auditMatter?: string; + summaryTitle?: string; + auditRecord?: string; + auditFinding?: string; + evidenceBasis?: string; + handling?: string; + attachment?: string; + auditors?: string; + compileDate?: string; + providerOpinion?: string; + providerDate?: string; + attachmentPages?: string; + feedbackDeadline?: string; +}) { + const res = await request.post( + MODULES_API_URL + '/ai/auditEvidence/download', + data, + { + responseType: 'blob' // 处理二进制流响应 + } + ); + + if (res.status === 200) { + return res.data; + } + return Promise.reject(new Error('文件下载失败')); } \ No newline at end of file diff --git a/src/views/pwl/pwlProject/components/components/EvidenceModal.vue b/src/views/pwl/pwlProject/components/components/EvidenceModal.vue index 9a0aca4..aa3b72a 100644 --- a/src/views/pwl/pwlProject/components/components/EvidenceModal.vue +++ b/src/views/pwl/pwlProject/components/components/EvidenceModal.vue @@ -10,10 +10,13 @@
重置内容 - 打印/导出 + + 导出Word文档 + + 打印预览
可直接在表格中编辑,打印即可生成与效果图一致的取证单
可直接在表格中编辑,导出即可生成与效果图一致的取证单
@@ -252,6 +255,7 @@ import { PropType, reactive, ref, watch } from 'vue'; import { message } from 'ant-design-vue'; import { PwlProject } from '@/api/pwl/pwlProject/model'; + import { downloadAuditEvidence } from '@/api/ai/auditContent'; type BaseInfo = { caseIndex?: string; @@ -284,6 +288,7 @@ }>(); const printArea = ref(null); + const exporting = ref(false); const defaultForm = () => ({ caseIndex: '', @@ -312,7 +317,7 @@ const formatAttachmentText = (caseIndex: string, raw: string) => { const safeCaseIndex = (caseIndex || '').trim(); const items = (raw || '') - .split(/[\n,,]/) + .split(/[\n\r,,、;;\s]+/) .map((s) => s.trim()) .filter(Boolean); if (!safeCaseIndex || items.length === 0) return raw || ''; @@ -451,10 +456,71 @@ message.success('内容已重置'); }; + /** + * 导出Word文档 + */ + const handleExport = async () => { + try { + exporting.value = true; + + // 准备导出数据 + const exportData = { + caseIndex: form.caseIndex, + pageIndex: form.pageIndex, + pageTotal: form.pageTotal, + projectName: form.projectName, + auditedTarget: form.auditedTarget, + auditMatter: form.auditMatter, + summaryTitle: form.summaryTitle, + auditRecord: form.auditRecord, + auditFinding: form.auditFinding, + evidenceBasis: form.evidenceBasis, + handling: form.handling, + attachment: form.attachment, + auditors: form.auditors, + compileDate: form.compileDate, + providerOpinion: form.providerOpinion, + providerDate: form.providerDate, + attachmentPages: form.attachmentPages, + feedbackDeadline: form.feedbackDeadline + }; + + // 调用后端下载接口 + const blob = await downloadAuditEvidence(exportData); + + // 创建下载链接 + const url = window.URL.createObjectURL(new Blob([blob])); + const link = document.createElement('a'); + link.href = url; + + // 设置文件名 + const fileName = `审计取证单_${form.projectName || '取证单'}_${form.caseIndex || ''}.docx`; + link.setAttribute('download', fileName); + + // 触发下载 + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); + + // 释放URL对象 + window.URL.revokeObjectURL(url); + + message.success('取证单导出成功'); + } catch (error) { + console.error('导出失败:', error); + message.error('取证单导出失败'); + } finally { + exporting.value = false; + } + }; + + /** + * 打印预览 + */ const printEvidence = () => { const area = printArea.value; if (!area) { - message.warning('暂无可导出的内容'); + message.warning('暂无可打印的内容'); return; }