feat: 学生报告改为流式排版并隐藏空数据区块

This commit is contained in:
2026-08-05 17:20:57 +08:00
parent fd39e1686a
commit 81e622fa09
9 changed files with 269 additions and 204 deletions

View File

@@ -13,7 +13,7 @@ import { esc } from './archive-report.helpers';
import { buildCover, buildBasicInfo } from './archive-report.cover';
import { buildExamOverview, buildExamDetail } from './archive-report.exam';
import { buildAttendance } from './archive-report.attendance';
import { buildLearningAndResult } from './archive-report.learning';
import { buildLearning, buildResult } from './archive-report.learning';
interface ReportData {
student: Student;
@@ -71,17 +71,33 @@ export class ArchiveReportService {
day: 'numeric',
});
const sections = [
{
name: enrollments.length > 0 ? '基础信息与报读记录' : '基础信息',
html: buildBasicInfo(student, profile, enrollments, now),
},
{ name: '考试成绩总览', html: buildExamOverview(exams, now) },
{ name: '出勤记录', html: buildAttendance(attendances, now) },
{ name: '文化课考试成绩', html: buildExamDetail(exams, now) },
{ name: '学情记录', html: buildLearning(learnings, now) },
{ name: '录取归档', html: buildResult(result, now) },
].filter((section) => section.html.length > 0);
const cover = buildCover(
student,
profile,
enrollments,
now,
sections.map((section) => section.name),
);
return `<!DOCTYPE html>
<html lang="zh-CN">
<head><meta charset="UTF-8"><title>学生档案报告 - ${esc(name)}</title>
<style>${ARCHIVE_REPORT_CSS}</style></head>
<body>
${buildCover(student, profile, enrollments, now)}
${buildBasicInfo(student, profile, enrollments, now)}
${buildExamOverview(exams, now)}
${buildAttendance(attendances, now)}
${buildExamDetail(exams, now)}
${buildLearningAndResult(learnings, result, now)}
${cover}
${sections.map((section) => section.html).join('\n')}
</body></html>`;
}
}