From 65235ec961088b34caf39c846c7021e0853f8f52 Mon Sep 17 00:00:00 2001 From: genggengtang Date: Tue, 10 Mar 2026 22:51:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=AE=A1=E8=AE=A1=E6=8A=A5?= =?UTF-8?q?=E5=91=8A=E7=94=9F=E6=88=90=E5=8A=9F=E8=83=BD=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/ai/auditContent/index.ts | 39 +- src/api/ai/auditReport/index.ts | 116 +++ src/api/pwl/pwlProject/model/index.ts | 4 + .../components/components/EvidenceModal.vue | 112 ++- .../pwlProject/components/pwlProjectEdit.vue | 25 +- .../pwl/pwlProject/components/report.vue | 849 ++++++++++++++++-- .../pwlProject/components/reportContent.vue | 70 +- .../pwlProject/components/reportGenerate.vue | 583 ++++++++++++ .../pwl/pwlProject/components/reportView.vue | 797 ++++++++++++++++ src/views/pwl/pwlProject/index.vue | 24 +- yarn.lock | 396 ++++---- 11 files changed, 2732 insertions(+), 283 deletions(-) create mode 100644 src/views/pwl/pwlProject/components/reportGenerate.vue create mode 100644 src/views/pwl/pwlProject/components/reportView.vue diff --git a/src/api/ai/auditContent/index.ts b/src/api/ai/auditContent/index.ts index f4aba6d..4ad4c0a 100644 --- a/src/api/ai/auditContent/index.ts +++ b/src/api/ai/auditContent/index.ts @@ -780,7 +780,7 @@ export async function generateAuditEvidence(data: { } /** - * 下载审计取证单Word文档 + * 下载审计取证单 Word 文档 */ export async function downloadAuditEvidence(data: { caseIndex?: string; @@ -814,4 +814,41 @@ export async function downloadAuditEvidence(data: { return res.data; } return Promise.reject(new Error('文件下载失败')); +} + +/** + * 保存审计取证单到数据库 + */ +export async function saveAuditEvidence(data: { + caseIndex?: string; + projectId?: number; + projectName?: string; + auditedTarget?: string; + contentType?: number; + auditMatterType?: string; + auditMatter?: string; + summaryTitle?: string; + auditRecord?: string; + auditFinding?: string; + evidenceBasis?: string; + handling?: string; + suggestion?: string; + attachment?: string; + auditors?: string; + compileDate?: string; + providerOpinion?: string; + providerDate?: string; + attachmentPages?: string; + feedbackDeadline?: string; + history?: string; +}) { + const res = await request.post>( + MODULES_API_URL + '/ai/auditEvidence/save', + data + ); + + if (res.data.code === 0) { + return res.data; + } + return Promise.reject(new Error(res.data.message)); } \ No newline at end of file diff --git a/src/api/ai/auditReport/index.ts b/src/api/ai/auditReport/index.ts index 664cfbd..a7591e1 100644 --- a/src/api/ai/auditReport/index.ts +++ b/src/api/ai/auditReport/index.ts @@ -67,4 +67,120 @@ export async function generateAuditReport2( return res.data.data; } return Promise.reject(new Error(res.data.message)); +} + +/** + * 保存审计报告到数据库 + */ +export async function saveAuditReport(data: { + projectId?: number; + projectName?: string; + caseIndex?: string; + auditedTarget?: string; + reportContent?: string; + previewHtml?: string; + sectionCount?: number; + formCommit?: number; +}) { + const res = await request.post>( + MODULES_API_URL + '/ai/auditReport/save', + data + ); + + if (res.data.code === 0) { + return res.data; + } + return Promise.reject(new Error(res.data.message)); +} + +/** + * 查询审计报告 + */ +export async function queryAuditReport(params: { + projectId: number; + formCommit: number; +}) { + const res = await request.post>( + MODULES_API_URL + '/ai/auditReport/query', + null, + { + params + } + ); + + if (res.data.code === 0) { + return res.data; + } + return Promise.reject(new Error(res.data.message)); +} + +/** + * 根据项目 ID 查询审计报告和取证单数据 + * @param projectId 项目 ID + * @param evidenceIds 勾选的取证单 ID 列表(可选) + */ +export async function queryAuditDataByProjectId(projectId: number, evidenceIds?: number[]) { + console.log('=== 前端发起请求 ==='); + console.log('projectId:', projectId); + console.log('evidenceIds:', evidenceIds); + + const res = await request.post>( + MODULES_API_URL + '/ai/auditReport/queryAuditDataByProjectId', + evidenceIds ? { evidenceIds } : {}, + { + params: { projectId }, + headers: { + 'Content-Type': 'application/json;charset=UTF-8' + } + } + ); + + console.log('=== 后端返回响应 ===', res); + console.log('res.data.code:', res.data.code); + console.log('res.data.message:', res.data.message); + console.log('res.data.data:', res.data.data); + + if (res.data.code === 0) { + return res.data; + } + console.error('API 返回错误 - code:', res.data.code, ', message:', res.data.message); + return Promise.reject(new Error(res.data.message || '操作失败')); +} + +/** + * 根据项目 ID 生成审计报告并下载 + */ +export async function generateAuditReportByProjectId(projectId: number) { + const res = await request.post( + MODULES_API_URL + '/ai/auditReport/generateByProjectId', + null, + { + params: { projectId }, + responseType: 'blob' // 处理二进制流响应 + } + ); + + if (res.status === 200) { + return res.data; + } + return Promise.reject(new Error('文件下载失败')); +} + +/** + * 根据项目 ID 和选中的取证单生成审计报告并下载 + */ +export async function generateAuditReportWithEvidences(projectId: number, evidenceIds: number[]) { + const res = await request.post( + MODULES_API_URL + '/ai/auditReport/generateWithEvidences', + { evidenceIds }, + { + params: { projectId }, + responseType: 'blob' // 处理二进制流响应 + } + ); + + if (res.status === 200) { + return res.data; + } + return Promise.reject(new Error('文件下载失败')); } \ No newline at end of file diff --git a/src/api/pwl/pwlProject/model/index.ts b/src/api/pwl/pwlProject/model/index.ts index fa750ce..778d5d8 100644 --- a/src/api/pwl/pwlProject/model/index.ts +++ b/src/api/pwl/pwlProject/model/index.ts @@ -10,6 +10,10 @@ export interface PwlProject { name?: string; // 项目标识 code?: string; + // 针对用户名称 + personName?: string; + // 职务 + position?: string; // 案引号 caseIndex?: string; // 上级id, 0是顶级 diff --git a/src/views/pwl/pwlProject/components/components/EvidenceModal.vue b/src/views/pwl/pwlProject/components/components/EvidenceModal.vue index aa3b72a..098260d 100644 --- a/src/views/pwl/pwlProject/components/components/EvidenceModal.vue +++ b/src/views/pwl/pwlProject/components/components/EvidenceModal.vue @@ -11,9 +11,11 @@ 重置内容 - 导出Word文档 + 导出 Word 文档 + + + 保存到数据库 - 打印预览
可直接在表格中编辑,导出即可生成与效果图一致的取证单
import { PropType, reactive, ref, watch } from 'vue'; - import { message } from 'ant-design-vue'; + import { message, Modal } from 'ant-design-vue'; import { PwlProject } from '@/api/pwl/pwlProject/model'; - import { downloadAuditEvidence } from '@/api/ai/auditContent'; + import { downloadAuditEvidence, saveAuditEvidence } from '@/api/ai/auditContent'; type BaseInfo = { caseIndex?: string; projectName?: string; auditedTarget?: string; auditMatter?: string; + auditMatterType?: string; // 审计事项类型 }; const props = defineProps({ @@ -289,6 +292,7 @@ const printArea = ref(null); const exporting = ref(false); + const saving = ref(false); const defaultForm = () => ({ caseIndex: '', @@ -297,6 +301,7 @@ projectName: '', auditedTarget: '', auditMatter: '', + auditMatterType: '', // 审计事项类型编码(code) summaryTitle: '', auditRecord: '', auditFinding: '', @@ -334,16 +339,30 @@ }; const applyBaseInfo = () => { - console.log('applyBaseInfo called, selectedRows:', props.selectedRows); - console.log('baseInfo:', props.baseInfo); + console.log('===== applyBaseInfo 开始执行 ====='); + console.log('1. selectedRows:', props.selectedRows); + console.log('2. baseInfo:', props.baseInfo); + console.log('3. baseInfo.auditMatterType:', props.baseInfo?.auditMatterType); // 重置表单为默认值 Object.assign(form, defaultForm(), props.baseInfo || {}); + + console.log('4. Object.assign 后的 form.auditMatterType:', form.auditMatterType); + + // 特殊处理:确保 auditMatterType 被正确复制(Object.assign 可能会覆盖) + if (props.baseInfo?.auditMatterType) { + form.auditMatterType = props.baseInfo.auditMatterType; + console.log('✓ 5. 显式设置后的 form.auditMatterType:', form.auditMatterType); + } else { + console.warn('✗ 5. auditMatterType 为空或未设置,无法复制'); + } + + console.log('===== applyBaseInfo 执行完毕 ====='); // 如果有传入的selectedRows,直接使用第一个对象的数据(生成取证单时通常只有一个) if (props.selectedRows && props.selectedRows.length > 0) { const evidenceData = props.selectedRows[0] || {}; - console.log('Evidence data from selectedRows:', evidenceData); + // console.log('Evidence data from selectedRows:', evidenceData); // 直接将后端返回的数据映射到表单字段 form.caseIndex = @@ -402,10 +421,10 @@ if (!form.pageIndex) form.pageIndex = '1'; if (!form.pageTotal) form.pageTotal = '1'; - console.log( - 'Form data after applyBaseInfo:', - JSON.stringify(form, null, 2) - ); + // console.log( + // 'Form data after applyBaseInfo:', + // JSON.stringify(form, null, 2) + // ); }; watch( @@ -419,7 +438,8 @@ watch( () => props.baseInfo, - () => { + (newVal) => { + console.log('watch baseInfo triggered, newVal.auditMatterType:', newVal?.auditMatterType); if (props.visible) { applyBaseInfo(); } @@ -456,6 +476,74 @@ message.success('内容已重置'); }; + /** + * 保存审计取证单到数据库 + */ + const handleSave = async () => { + // 弹出确认对话框 + Modal.confirm({ + title: '确认保存', + content: '是否确认将当前取证单数据保存到数据库?', + okText: '是', + cancelText: '否', + onOk: async () => { + try { + saving.value = true; + + // 准备保存数据 + const saveData = { + caseIndex: form.caseIndex, + projectId: props.project?.id, + projectName: form.projectName, + auditedTarget: form.auditedTarget, + contentType: 1, // 默认值,可根据实际情况调整 + auditMatterType: form.auditMatterType, // 从 form 中获取(必须是 code) + auditMatter: form.auditMatter, + summaryTitle: form.summaryTitle, + auditRecord: form.auditRecord, + auditFinding: form.auditFinding, + evidenceBasis: form.evidenceBasis, + handling: form.handling, + suggestion: form.suggestion, + attachment: form.attachment, + auditors: form.auditors, + compileDate: form.compileDate, + providerOpinion: form.providerOpinion, + providerDate: form.providerDate, + attachmentPages: form.attachmentPages, + feedbackDeadline: form.feedbackDeadline, + history: '' // 历史内容,如果需要的话 + }; + + console.log('=== 保存取证单 ==='); + console.log('form:', form); + console.log('form.auditMatterType:', form.auditMatterType); + console.log('saveData.auditMatterType:', saveData.auditMatterType); + + // 调用保存接口 + const result = await saveAuditEvidence(saveData); + + if (result.code === 0) { + message.success('取证单保存成功'); + // 可以选择关闭弹窗或者清空表单 + // emit('update:visible', false); + } else { + message.error('取证单保存失败:' + (result.message || '未知错误')); + } + } catch (error: any) { + console.error('保存失败:', error); + message.error('取证单保存失败:' + (error.message || '未知错误')); + } finally { + saving.value = false; + } + }, + onCancel() { + // 用户选择"否",不做任何操作 + console.log('用户取消保存'); + } + }); + }; + /** * 导出Word文档 */ diff --git a/src/views/pwl/pwlProject/components/pwlProjectEdit.vue b/src/views/pwl/pwlProject/components/pwlProjectEdit.vue index 5067b97..d5c2682 100644 --- a/src/views/pwl/pwlProject/components/pwlProjectEdit.vue +++ b/src/views/pwl/pwlProject/components/pwlProjectEdit.vue @@ -20,6 +20,8 @@ styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' } " > + + 项目信息 @@ -49,6 +51,22 @@ v-model:value="form.code" /> + + + + + + - - 项目信息 + @@ -378,6 +395,8 @@ const form = reactive({ price: undefined, recommend: undefined, expirationTime: undefined, + personName: undefined, + position: undefined, itemName: undefined, itemYear: undefined, itemType: undefined, diff --git a/src/views/pwl/pwlProject/components/report.vue b/src/views/pwl/pwlProject/components/report.vue index 960a2b3..22bacb2 100644 --- a/src/views/pwl/pwlProject/components/report.vue +++ b/src/views/pwl/pwlProject/components/report.vue @@ -1,4 +1,4 @@ - +