feat(ui): redesign postcards list with tabs, row layout, country dropdown filter

This commit is contained in:
2026-07-05 22:12:33 +08:00
parent 2aeaa560d6
commit 84e4e457db
3 changed files with 99 additions and 35 deletions

View File

@@ -7,43 +7,80 @@
</div>
<div class="filter-bar">
<form method="get" class="form-row">
<select name="status">
<option value="">全部状态</option>
<option value="sent" {% if status == 'sent' %}selected{% endif %}>已寄出</option>
<option value="delivered" {% if status == 'delivered' %}selected{% endif %}>已送达</option>
<option value="received" {% if status == 'received' %}selected{% endif %}>已收到</option>
<select name="country">
<option value="">全部国家</option>
{% for c in countries %}
<option value="{{ c }}" {% if country == c %}selected{% endif %}>{{ c|flag }} {{ c }}</option>
{% endfor %}
</select>
<input type="text" name="country" placeholder="国家/地区" value="{{ country }}">
<button type="submit" class="btn">筛选</button>
</form>
</div>
{% if postcards %}
<div class="card-grid">
{% for pc in postcards %}
<a href="/postcards/{{ pc.id }}" class="postcard-card">
<div class="tabs" id="tabs">
<button class="tab active" onclick="switchTab('sent')">寄出 ({{ sent|length }})</button>
<button class="tab" onclick="switchTab('received')">收到 ({{ received|length }})</button>
</div>
<div id="tab-sent" class="tab-panel">
{% if sent %}
{% for pc in sent %}
<a href="/postcards/{{ pc.id }}" class="postcard-row">
<div class="postcard-row-img">
{% if pc.image_front %}
<img src="{{ pc.image_front }}" alt="正面" class="thumb">
<img src="{{ pc.image_front }}" alt="正面">
{% else %}
<div class="thumb placeholder">📷</div>
{% endif %}
<div class="postcard-info">
<span class="badge badge-{{ pc.status }}">{{ {'sent':'已寄出','delivered':'已送达','received':'已收到'}.get(pc.status, pc.status) }}</span>
<strong>{{ pc.card_number }}</strong>
{% if pc.status in ('sent','delivered') %}
<span>→ {{ pc.recipient_name or '-' }} ({{ pc.country|flag }} {{ pc.country or '-' }})</span>
{% else %}
<span>← {{ pc.sender_name or '-' }}</span>
{% endif %}
{% if pc.status == 'sent' %}
<form method="post" action="/postcards/{{ pc.id }}/mark-delivered" class="inline" onclick="event.stopPropagation();">
<button type="submit" class="btn btn-sm btn-primary" onclick="return confirm('确认已送达?')">✓ 标记已送达</button>
</form>
{% endif %}
</div>
</a>
{% endfor %}
</div>
</div>
<div class="postcard-row-info">
<strong>{{ pc.card_number }}</strong>
<span>{{ pc.country|flag }} {{ pc.country or '-' }}</span>
<span>→ {{ pc.recipient_name or '-' }}</span>
<span class="badge badge-{{ pc.status }}">{{ {'sent':'已寄出','delivered':'已送达'}.get(pc.status) }}</span>
</div>
<div class="postcard-row-action">
{% if pc.status == 'sent' %}
<form method="post" action="/postcards/{{ pc.id }}/mark-delivered" onclick="event.preventDefault();event.stopPropagation();if(confirm('确认已送达?'))this.submit();">
<button type="submit" class="btn btn-sm btn-primary">✓ 标记已送达</button>
</form>
{% endif %}
</div>
</a>
{% endfor %}
{% else %}
<p class="empty">没有找到明信片。</p>
<p class="empty">没有寄出的明信片。</p>
{% endif %}
</div>
<div id="tab-received" class="tab-panel" style="display:none">
{% if received %}
{% for pc in received %}
<a href="/postcards/{{ pc.id }}" class="postcard-row">
<div class="postcard-row-img">
{% if pc.image_front %}
<img src="{{ pc.image_front }}" alt="正面">
{% else %}
<div class="thumb placeholder">📷</div>
{% endif %}
</div>
<div class="postcard-row-info">
<strong>{{ pc.card_number }}</strong>
<span>← {{ pc.sender_name or '-' }}</span>
</div>
</a>
{% endfor %}
{% else %}
<p class="empty">没有收到的明信片。</p>
{% endif %}
</div>
<script>
function switchTab(name) {
document.querySelectorAll('.tab').forEach(function(t) { t.classList.remove('active'); });
document.querySelectorAll('.tab-panel').forEach(function(p) { p.style.display = 'none'; });
event.currentTarget.classList.add('active');
document.getElementById('tab-' + name).style.display = '';
}
</script>
{% endblock %}