Files
mailova/app/templates/postcard_form.html

52 lines
3.0 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{% extends "base.html" %}
{% block title %}{{ '编辑' if postcard else '新建' }}明信片 - Postcard Manager{% endblock %}
{% block content %}
<div class="section-header">
<h1>{{ '编辑' if postcard else '新建' }}明信片</h1>
</div>
<form method="post" action="{{ '/postcards/%d/edit' % postcard.id if postcard else '/profiles/%d/postcards' % profile.id }}" class="form-card">
<label>编号 * <span style="font-weight:400;color:var(--text-muted);font-size:.8rem">格式AB-1234567</span></label>
<input type="text" name="card_number" value="{{ postcard.card_number if postcard else '' }}" required pattern="[A-Za-z]{2}-\d{7}" title="两个字母 + 短横线 + 7位数字如 AB-1234567">
<label>状态 *</label>
<select name="status" id="status-select" onchange="toggleFields()" required>
<option value="sent" {% if postcard and postcard.status=='sent' %}selected{% endif %}>已寄出</option>
<option value="delivered" {% if postcard and postcard.status=='delivered' %}selected{% endif %}>已送达</option>
<option value="received" {% if postcard and postcard.status=='received' %}selected{% endif %}>已收到</option>
</select>
<div id="fields-sent-delivered">
<label>收件人 *</label>
<input type="text" name="recipient_name" value="{{ postcard.recipient_name if postcard else '' }}" required>
<label>国家/地区 *</label>
<input type="text" name="country" value="{{ postcard.country if postcard else '' }}" required pattern="[A-Z]{2}" title="两个大写字母(如 JP、US" maxlength="2" style="width:80px;text-transform:uppercase">
<label>寄出时间 *</label>
<input type="date" name="send_time" value="{{ postcard.send_time.strftime('%Y-%m-%d') if postcard and postcard.send_time else '' }}" required>
<label>到达时间 *</label>
<input type="date" name="arrival_time" value="{{ postcard.arrival_time.strftime('%Y-%m-%d') if postcard and postcard.arrival_time else '' }}" required>
</div>
<div id="fields-received" style="display:none">
<label>发件人 *</label>
<input type="text" name="sender_name" value="{{ postcard.sender_name if postcard else '' }}" required>
<label>收到时间 *</label>
<input type="date" name="receive_time" value="{{ postcard.receive_time.strftime('%Y-%m-%d') if postcard and postcard.receive_time else '' }}" required>
</div>
<div class="form-actions">
<button type="submit" class="btn btn-primary">保存</button>
<a href="/profiles/{{ profile.id }}/postcards" class="btn">取消</a>
</div>
</form>
<script>
function toggleFields() {
var s = document.getElementById('status-select').value;
var sd = document.getElementById('fields-sent-delivered');
var rc = document.getElementById('fields-received');
sd.style.display = (s === 'received') ? 'none' : '';
rc.style.display = (s === 'received') ? '' : 'none';
}
toggleFields();
</script>
{% endblock %}