From 5d8d0972257af77437325e86e303d267345c6126 Mon Sep 17 00:00:00 2001 From: tanggeng-RwHN2 Date: Wed, 27 May 2026 23:37:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AE=A1=E8=AE=A1=E6=8A=A5?= =?UTF-8?q?=E5=91=8A=E9=83=A8=E5=88=86=E7=AB=A0=E8=8A=82=E7=9A=84AI?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E8=AF=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pwl/pwlProject/components/reportView.vue | 104 +++++++++--------- 1 file changed, 54 insertions(+), 50 deletions(-) diff --git a/src/views/pwl/pwlProject/components/reportView.vue b/src/views/pwl/pwlProject/components/reportView.vue index 23948c0..d258f1f 100644 --- a/src/views/pwl/pwlProject/components/reportView.vue +++ b/src/views/pwl/pwlProject/components/reportView.vue @@ -132,7 +132,6 @@ @@ -149,6 +148,16 @@ - -
+ +
{ 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) => 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;