feat(pwl):添加审计内容3初版

This commit is contained in:
2025-10-22 10:58:59 +08:00
parent f1a72c334e
commit 48378e596c
2 changed files with 186 additions and 19 deletions

View File

@@ -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<string, any> = {};
if (kbIds) params.kbIds = kbIds;
if (libraryIds) params.libraryIds = libraryIds;
if (projectLibrary) params.projectLibrary = projectLibrary;
const res = await request.post<ApiResult<any>>(
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));
}

View File

@@ -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) =>