feat:项目管理-取证单-优化取证单导出word功能
This commit is contained in:
@@ -778,3 +778,40 @@ export async function generateAuditEvidence(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('文件下载失败'));
|
||||
}
|
||||
@@ -10,10 +10,13 @@
|
||||
<div class="evidence-actions">
|
||||
<a-space>
|
||||
<a-button @click="resetFields">重置内容</a-button>
|
||||
<a-button type="primary" @click="printEvidence">打印/导出</a-button>
|
||||
<a-button type="primary" @click="handleExport" :loading="exporting">
|
||||
导出Word文档
|
||||
</a-button>
|
||||
<a-button v-if="false" @click="printEvidence">打印预览</a-button>
|
||||
</a-space>
|
||||
<div class="action-tip"
|
||||
>可直接在表格中编辑,打印即可生成与效果图一致的取证单</div
|
||||
>可直接在表格中编辑,导出即可生成与效果图一致的取证单</div
|
||||
>
|
||||
</div>
|
||||
|
||||
@@ -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<HTMLElement | null>(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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user