From 48378e596c50efbc0852bca09a83b085073b43d5 Mon Sep 17 00:00:00 2001 From: yuance <182865460@qq.com> Date: Wed, 22 Oct 2025 10:58:59 +0800 Subject: [PATCH] =?UTF-8?q?feat(pwl):=E6=B7=BB=E5=8A=A0=E5=AE=A1=E8=AE=A1?= =?UTF-8?q?=E5=86=85=E5=AE=B93=E5=88=9D=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/ai/auditContent/index.ts | 31 ++++ .../pwlProject/components/reportContent.vue | 174 ++++++++++++++++-- 2 files changed, 186 insertions(+), 19 deletions(-) create mode 100644 src/api/ai/auditContent/index.ts diff --git a/src/api/ai/auditContent/index.ts b/src/api/ai/auditContent/index.ts new file mode 100644 index 0000000..9d07751 --- /dev/null +++ b/src/api/ai/auditContent/index.ts @@ -0,0 +1,31 @@ +import request from '@/utils/request'; +import type { ApiResult } from '@/api'; +import { MODULES_API_URL } from '@/config/setting'; + +/** + * 生成重大经济决策调查表 + */ +export async function generateDecisionTable( + kbIds?: string, + libraryIds?: string, + projectLibrary?: string +) { + const params: Record = {}; + + if (kbIds) params.kbIds = kbIds; + if (libraryIds) params.libraryIds = libraryIds; + if (projectLibrary) params.projectLibrary = projectLibrary; + + const res = await request.post>( + MODULES_API_URL + '/ai/auditContent3/generateDecisionTable', + null, + { + params + } + ); + + if (res.data.code === 0) { + return res.data; // 返回整个响应数据,包括data字段 + } + return Promise.reject(new Error(res.data.message)); +} \ No newline at end of file diff --git a/src/views/pwl/pwlProject/components/reportContent.vue b/src/views/pwl/pwlProject/components/reportContent.vue index 307ac95..8c9bdab 100644 --- a/src/views/pwl/pwlProject/components/reportContent.vue +++ b/src/views/pwl/pwlProject/components/reportContent.vue @@ -280,6 +280,7 @@ downloadAuditReport } from '@/api/ai/auditReport'; import { getPwlProjectLibraryByIds } from '@/api/pwl/pwlProjectLibrary'; + import { generateDecisionTable } from '@/api/ai/auditContent'; const useForm = Form.useForm; @@ -383,28 +384,83 @@ { number: '三', name: '审计内容3', - title: '3、审计对象和范围', - description: '点击"AI生成"按钮让AI为您生成该部分内容,或直接在下方编辑', - placeholder: '请输入审计对象和范围内容...', - content: '', - suggestion: '', - formCommit: 30, - rows: 8, + title: '3、重大经济决策调查表', + description: '点击"AI生成"按钮生成重大经济决策调查表数据', generating: false, - columns: columns.value, - data: [ + columns: [ { - index: '1', - name: '测试', - content: '测试内容', - amount: '9999', - progress: '这是程序', - done: '是', - goods: '', - normal: '是', - bad: '', + title: '序号', + dataIndex: 'index', + key: 'index', + width: 80, + align: 'center' + }, + { + title: '重大经济决策事项', + dataIndex: 'name', + key: 'name', + width: 200, + ellipsis: true + }, + { + title: '会议时间', + dataIndex: 'content', // 注意:这里映射的是content字段 + key: 'content', + width: 120, + align: 'center' + }, + { + title: '决策事项金额', + dataIndex: 'amount', + key: 'amount', + width: 120, + align: 'center' + }, + { + title: '程序程序', + dataIndex: 'progress', + key: 'progress', + width: 150, + ellipsis: true + }, + { + title: '执行情况(是/否)', + dataIndex: 'done', + key: 'done', + width: 100, + align: 'center' + }, + { + title: '执行效果(是否实现决策目标)', + children: [ + { + title: '好', + dataIndex: 'goods', + key: 'goods', + width: 60, + align: 'center', + customRender: ({ text }) => text ? '✅' : '' + }, + { + title: '一般', + dataIndex: 'normal', + key: 'normal', + width: 60, + align: 'center', + customRender: ({ text }) => text ? '✅' : '' + }, + { + title: '差', + dataIndex: 'bad', + key: 'bad', + width: 60, + align: 'center', + customRender: ({ text }) => text ? '✅' : '' + } + ] } - ] + ], + data: [] }, { number: '四', @@ -822,6 +878,12 @@ /* AI生成内容 */ const generateContent = async (sectionIndex: number, childIndex?: number) => { + // 特殊处理审计内容3(重大经济决策调查表) + if (sectionIndex === 2) { + await generateContent3(); + return; + } + const section = navigationItems.value[sectionIndex]; // 处理主项生成(当主项没有formCommit时) @@ -870,6 +932,80 @@ } }; + + // 更新审计内容3的生成方法 + const generateContent3 = async () => { + const section = navigationItems.value[2]; + section.generating = true; + + console.log('生成参数:', { + kbIds: props.data?.kbId, + libraryIds: props.data?.libraryIds, + projectLibrary: props.data?.projectLibrary + }); + + try { + // 调用决策表生成接口 + const result = await generateDecisionTable( + props.data?.kbId, + props.data?.libraryIds, + props.data?.projectLibrary + ); + + console.log('接口返回结果:', result); + + // 修正数据访问路径 + if (result.code === 0 && result.data && result.data.success) { + const tableData = result.data.data.map((item, index) => { + // 确保数据转换正确 + const executionEffect = item.executionEffect || {}; + return { + key: index, // 添加key属性用于表格渲染 + index: item.index || String(index + 1), + name: item.name || '未知事项', + content: item.meetingTime || '未知时间', + amount: item.decisionAmount || '0', + progress: item.procedure || '程序未记录', + done: item.executionStatus || '否', + goods: executionEffect.good === '是' ? '是' : '', + normal: executionEffect.normal === '是' ? '是' : '', + bad: executionEffect.bad === '是' ? '是' : '' + }; + }); + + section.data = tableData; + message.success(`成功生成 ${tableData.length} 条重大经济决策记录`); + + // 调试信息 + console.log('转换后的表格数据:', tableData); + } else { + const errorMsg = result.data?.error || result.message || '生成失败'; + throw new Error(errorMsg); + } + } catch (error) { + console.error('生成重大经济决策调查表失败:', error); + message.error('生成失败: ' + (error.message || '未知错误')); + + // 在错误时显示一些示例数据用于调试 + section.data = [ + { + key: 1, + index: '1', + name: '示例决策事项', + content: '2024-01-01', + amount: '100万元', + progress: '集体决策程序完整', + done: '是', + goods: '是', + normal: '', + bad: '' + } + ]; + } finally { + section.generating = false; + } + }; + /* 监听滚动位置更新当前章节 */ const handleScroll = () => { const sections = navigationItems.value.map((_, index) =>