- 修改视图逻辑,将未完成事项分为即将到期(一个月内)和远期事项 - 即将到期的事项显示完整详情表格 - 超过一个月的远期事项只显示数量,不显示详情 - 支持显示已过期的事项(红色标记)
125 lines
5.2 KiB
HTML
125 lines
5.2 KiB
HTML
{% extends 'core/base.html' %}
|
|
|
|
{% block content %}
|
|
<!-- 页面标题 -->
|
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
|
<h2 class="mb-0">
|
|
<i class="bi bi-list-check me-2 text-warning"></i>家庭事项 <small class="text-muted fs-5">(未完成)</small>
|
|
</h2>
|
|
<div>
|
|
<a href="{% url 'add_family_task' %}" class="btn btn-primary">
|
|
<i class="bi bi-plus-lg me-1"></i>添加家庭事项
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 即将到期的事项(一个月内) -->
|
|
<div class="card mb-4">
|
|
<div class="card-header bg-primary text-white d-flex justify-content-between align-items-center">
|
|
<h5 class="card-title mb-0">
|
|
<i class="bi bi-house-door me-2"></i>即将到期的事项
|
|
</h5>
|
|
<span class="badge bg-light text-primary">{{ upcoming_tasks|length }} 项</span>
|
|
</div>
|
|
<div class="card-body">
|
|
{% if upcoming_tasks %}
|
|
<div class="table-responsive">
|
|
<table class="table table-hover">
|
|
<thead>
|
|
<tr>
|
|
<th style="width: 100px;">类型</th>
|
|
<th>内容</th>
|
|
<th style="width: 100px;">优先级</th>
|
|
<th style="width: 100px;">状态</th>
|
|
<th style="width: 120px;">截止日期</th>
|
|
<th style="width: 100px;">操作</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for task in upcoming_tasks %}
|
|
<tr>
|
|
<td>
|
|
<span class="badge bg-secondary">{{ task.get_type_display }}</span>
|
|
</td>
|
|
<td>
|
|
<strong>{{ task.content }}</strong>
|
|
</td>
|
|
<td>
|
|
<span class="badge {% if task.priority == 'high' %}bg-danger{% elif task.priority == 'medium' %}bg-warning{% else %}bg-info{% endif %}">
|
|
{{ task.get_priority_display }}
|
|
</span>
|
|
</td>
|
|
<td>
|
|
<span class="badge bg-warning">
|
|
{{ task.get_status_display }}
|
|
</span>
|
|
</td>
|
|
<td>
|
|
{% if task.deadline %}
|
|
<span class="{% if task.deadline < today %}text-danger{% else %}text-muted{% endif %}">
|
|
<i class="bi bi-calendar me-1"></i>{{ task.deadline }}
|
|
</span>
|
|
{% else %}
|
|
<span class="text-muted">-</span>
|
|
{% endif %}
|
|
</td>
|
|
<td>
|
|
<div class="btn-group">
|
|
<a href="{% url 'edit_family_task' task.id %}" class="btn btn-sm btn-warning" title="编辑">
|
|
<i class="bi bi-pencil"></i>
|
|
</a>
|
|
<a href="{% url 'delete_family_task' task.id %}" class="btn btn-sm btn-danger" title="删除">
|
|
<i class="bi bi-trash"></i>
|
|
</a>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
{% else %}
|
|
<div class="text-center py-4">
|
|
<i class="bi bi-check-all text-success" style="font-size: 3rem;"></i>
|
|
<p class="text-muted mt-2">没有即将到期的家庭事项</p>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 远期事项(超过一个月) -->
|
|
{% if future_tasks_count > 0 %}
|
|
<div class="card">
|
|
<div class="card-header bg-info text-white d-flex justify-content-between align-items-center">
|
|
<h5 class="card-title mb-0">
|
|
<i class="bi bi-calendar-event me-2"></i>远期事项
|
|
</h5>
|
|
<span class="badge bg-light text-info">{{ future_tasks_count }} 项</span>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="alert alert-info mb-0">
|
|
<i class="bi bi-info-circle-fill me-2"></i>
|
|
还有 <strong>{{ future_tasks_count }}</strong> 个将在一个月后到期的家庭事项
|
|
<span class="text-muted">(这些事项较远,暂不显示详情)</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- 全部完成的状态 -->
|
|
{% if not upcoming_tasks and future_tasks_count == 0 %}
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<div class="text-center py-5">
|
|
<i class="bi bi-check-all text-success" style="font-size: 5rem;"></i>
|
|
<h5 class="text-muted mt-3">太棒了!没有未完成的家庭事项</h5>
|
|
<p class="text-muted">所有家庭事项都已完成,可以添加新的家庭事项</p>
|
|
<a href="{% url 'add_family_task' %}" class="btn btn-primary">
|
|
<i class="bi bi-plus-lg me-1"></i>添加家庭事项
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
{% endblock %}
|