优化审计报告部分章节的AI提示词

This commit is contained in:
2026-05-27 23:37:34 +08:00
parent c61328a81e
commit 5d8d097225

View File

@@ -132,7 +132,6 @@
<a-textarea
v-model:value="chapter.content"
:auto-size="{ minRows: 6, maxRows: 20 }"
placeholder="点击 AI 生成按钮将显示内容,也可手动编辑..."
@change="onChapterContentChange(chapter.index)"
/>
</div>
@@ -149,6 +148,16 @@
<template v-if="subChapter.noAI && subChapter.noHistory">
<!-- 子章节标题 AI 生成和历史记录按钮 -->
<div class="sub-chapter-title plain-subtitle">{{ subChapter.title }}</div>
<!-- 审计依据内容显示区域 -->
<div class="chapter-content">
<a-textarea
v-model:value="subChapter.content"
:auto-size="{ minRows: 6, maxRows: 20 }"
placeholder="未找到相关数据"
readonly
/>
</div>
</template>
<template v-else>
<div class="chapter-header">
@@ -181,8 +190,8 @@
<div class="sub-chapter-title">{{ subChapter.title }}</div>
</template>
<!-- 子章节内容文本框 -->
<div class="chapter-content">
<!-- 子章节内容文本框审计依据已在上面处理 -->
<div class="chapter-content" v-if="!(subChapter.noAI && subChapter.noHistory)">
<a-textarea
v-model:value="subChapter.content"
:auto-size="{ minRows: 6, maxRows: 20 }"
@@ -503,6 +512,9 @@ const loadReport = async () => {
console.log('=== 开始解析后端返回的 reports 数据 ===');
console.log('reports 数量:', reports.length);
// 先检查是否有 formCommit=10 的数据
const report10 = reports.find((r: any) => r.formCommit === 10);
reports.forEach((report: any) => {
console.log('\n--- 处理单条报告 ---');
console.log('formCommit:', report.formCommit);
@@ -511,56 +523,28 @@ const loadReport = async () => {
if (report.formCommit && report.reportContent) {
hasData = true; // 只要有报告记录,就标记为有数据
try {
const content = JSON.parse(report.reportContent);
let extractedContent = '';
// 如果是 JSON 格式
if (content.sections && Array.isArray(content.sections)) {
console.log('JSON 格式sections 数量:', content.sections.length);
content.sections.forEach((section: any) => {
console.log(' - section.content:', section.content?.substring(0, 50) || '空');
if (section.content) {
extractedContent += section.content + '\n';
}
// 只处理前 5 条记录(针对审计依据)
const maxRecords = report.formCommit === 10 ? 5 : Number.MAX_SAFE_INTEGER;
if (section.records && Array.isArray(section.records)) {
console.log(' - section.records 数量:', section.records.length);
section.records.slice(0, maxRecords).forEach((rec: any, idx: number) => {
console.log(` - rec[${idx}].content:`, rec.content?.substring(0, 50) || '空');
if (rec.content) {
extractedContent += rec.content + '\n';
}
});
}
});
} else {
// 如果是纯文本
// console.log('纯文本格式');
// 对于审计依据formCommit=10只取前 5 条数据
if (report.formCommit === 10) {
// 按换行符分割成多行
const lines = report.reportContent.split('\n').filter(line => line.trim() !== '');
// 只取前 5 条非空行
extractedContent = lines.slice(0, 5).join('\n');
console.log('纯文本格式,限制为前 5 条,原始行数:', lines.length, '提取后内容:', extractedContent);
} else {
extractedContent = report.reportContent;
}
}
// 直接使用 reportContent不再尝试解析 JSON
let extractedContent = '';
// 存储到对应的 formCommit
contentMap[report.formCommit] = extractedContent.trim();
console.log('提取后的内容长度:', extractedContent.trim().length);
console.log('存入 contentMap[' + report.formCommit + ']');
} catch (e) {
// JSON 解析失败,直接存储原文本
console.log('JSON 解析失败,使用原文本');
contentMap[report.formCommit] = report.reportContent;
// 对于审计依据(formCommit=10只取前 5 条数据
if (report.formCommit === 10) {
// 按换行符分割成多行
const lines = report.reportContent.split('\n').filter(line => line.trim() !== '');
// 只取前 5 条非空行
extractedContent = lines.slice(0, 5).join('\n');
console.log('审计依据,限制为前 5 条,原始行数:', lines.length, '提取后内容:', extractedContent);
} else {
extractedContent = report.reportContent;
}
// 存储到对应的 formCommit 下
contentMap[report.formCommit] = extractedContent.trim();
console.log('提取后的内容长度:', extractedContent.trim().length);
} else {
console.log('跳过formCommit 或 reportContent 为空');
console.log(' - report.formCommit 值:', report.formCommit);
console.log(' - report.reportContent 值:', report.reportContent);
}
});
@@ -675,19 +659,33 @@ const initChapterStructure = (data: any, contentMap?: Record<number, string>) =>
if (chapter.children && chapter.children.length > 0) {
console.log(`处理主章节 ${chapter.title} 的子章节,数量:${chapter.children.length}`);
chapter.children.forEach((child: any) => {
child.content = child.content || '';
// 确保 content 有值,如果为空则设置为空字符串
if (!child.content) {
child.content = '';
}
child.customInput = ''; // 确保有 customInput 属性
chapterContentMap.value[chapterIndex] = child.content || '';
chapterHistoryMap.value[chapterIndex] = [];
child.index = chapterIndex;
child.parentTitle = chapter.title;
console.log(`初始化子章节:${child.title}, 索引:${chapterIndex}, noAI: ${child.noAI}, noHistory: ${child.noHistory}`);
console.log(`初始化子章节:${child.title}, 索引:${chapterIndex}, noAI: ${child.noAI}, noHistory: ${child.noHistory}, content长度: ${child.content?.length || 0}`);
chapterIndex++;
});
}
});
console.log('章节结构初始化完成:', JSON.stringify(outlineStructure.value, null, 2));
// 特别检查审计依据的内容
const auditBasisChapter = outlineStructure.value[0]?.children?.[0];
if (auditBasisChapter) {
console.log('\n=== 审计依据章节检查 ===');
console.log('标题:', auditBasisChapter.title);
console.log('content:', auditBasisChapter.content);
console.log('content 长度:', auditBasisChapter.content?.length || 0);
console.log('contentMap[10]:', contentMap?.[10]);
console.log('========================\n');
}
};
/**
@@ -1567,6 +1565,12 @@ const loadChapterFromHistory = async (chapter: any, chapterIndex: number) => {
console.log(`[loadChapterFromHistory] 内容预览:${content ? content.substring(0, 50) + '...' : '空'}`);
if (content) {
// 过滤掉单独的"无"字
if (content.trim() === '无') {
console.log(`[loadChapterFromHistory] 章节 "${chapter.title}" 的内容为单独的"无",已清空`);
content = '';
}
// 更新章节内容
chapter.content = content;
chapterContentMap.value[chapterIndex] = content;