feat(pdf): 添加PDF文件列表功能并优化报告页面

- 新增PDF文件列表页面,显示服务器上所有历史PDF报告
- 在报告页面添加"更早的"按钮链接到PDF列表
- 将历史PDF链接显示从30天改为7天
- 优化PDF生成错误处理和日志记录
- 更新按钮文字描述为"预览PDF模板"
This commit is contained in:
2026-01-20 21:07:13 +08:00
parent c22c001ee0
commit eee44ad342
5 changed files with 157 additions and 50 deletions

View File

@@ -70,7 +70,7 @@
<a href="{% url 'today_records' %}" class="btn btn-outline-primary mb-2">添加今日信息</a>
<a href="{% url 'yesterday_records' %}" class="btn btn-outline-primary mb-2">追加昨日信息</a>
<a href="{% url 'today_plan' %}" class="btn btn-outline-primary mb-2">管理今日计划</a>
<a href="{% url 'generate_report' %}" class="btn btn-outline-primary mb-2">查看今日报告</a>
<a href="{% url 'generate_report' %}" class="btn btn-outline-primary mb-2">预览家庭日报PDF模板</a>
<a href="{% url 'send_email' %}" class="btn btn-outline-success">发送今日邮件</a>
</div>
</div>

View File

@@ -0,0 +1,43 @@
{% extends 'core/base.html' %}
{% block content %}
<h2>PDF文件列表</h2>
<div class="card">
<div class="card-header bg-primary text-white">
<h5 class="card-title mb-0">服务器上的PDF文件</h5>
</div>
<div class="card-body">
{% if pdf_files %}
<table class="table table-striped">
<thead>
<tr>
<th>日期</th>
<th>文件名</th>
<th>操作</th>
</tr>
</thead>
<tbody>
{% for pdf in pdf_files %}
<tr>
<td>{{ pdf.date }}</td>
<td>{{ pdf.filename }}</td>
<td>
<a href="{% url 'generate_pdf_report' pdf.date_str %}" class="btn btn-primary btn-sm" target="_blank">
<i class="bi bi-file-pdf"></i> 查看
</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p class="text-muted">服务器上没有PDF文件</p>
{% endif %}
</div>
</div>
<a href="{% url 'generate_report' %}" class="btn btn-secondary mt-3">
<i class="bi bi-arrow-left"></i> 返回报告页面
</a>
{% endblock %}

View File

@@ -4,13 +4,13 @@
<h2>家庭日报报告</h2>
<div class="mb-4">
<a href="{% url 'generate_pdf_report' today|date:'Y-m-d' %}" class="btn btn-primary">
<i class="bi bi-file-pdf"></i> 生成PDF报告
</a>
<a href="{% url 'send_email' %}" class="btn btn-success">
<i class="bi bi-envelope"></i> 发送邮件
</a>
</div>
<a href="{% url 'generate_pdf_report' today|date:'Y-m-d' %}" class="btn btn-primary" target="_blank">
<i class="bi bi-file-pdf"></i> 预览PDF模板
</a>
<a href="{% url 'send_email' %}" class="btn btn-success">
<i class="bi bi-envelope"></i> 发送邮件
</a>
</div>
<div class="card">
<div class="card-header bg-primary text-white">
@@ -182,6 +182,13 @@
</a>
</div>
{% endfor %}
{% if has_earlier_pdfs %}
<div class="col-md-3 mb-2">
<a href="{% url 'pdf_list' %}" class="btn btn-outline-secondary btn-sm btn-block">
更早的
</a>
</div>
{% endif %}
</div>
</div>
</div>