fix(postcard): remove auto option from status dropdown, auto-select silently by date

This commit is contained in:
2026-07-15 19:16:41 +08:00
parent 5ec21f0e3f
commit 05168fb1ca
3 changed files with 16 additions and 33 deletions

View File

@@ -122,7 +122,6 @@
"pc_form.number": "Number", "pc_form.number": "Number",
"pc_form.number_hint": "Format: AB-1234567", "pc_form.number_hint": "Format: AB-1234567",
"pc_form.status": "Status", "pc_form.status": "Status",
"pc_form.status_auto": "Auto (based on date)",
"pc_form.recipient": "Recipient", "pc_form.recipient": "Recipient",
"pc_form.country": "Country", "pc_form.country": "Country",
"pc_form.country_from": "From", "pc_form.country_from": "From",

View File

@@ -122,7 +122,6 @@
"pc_form.number": "编号", "pc_form.number": "编号",
"pc_form.number_hint": "格式AB-1234567", "pc_form.number_hint": "格式AB-1234567",
"pc_form.status": "状态", "pc_form.status": "状态",
"pc_form.status_auto": "自动(根据日期)",
"pc_form.recipient": "收件人", "pc_form.recipient": "收件人",
"pc_form.country": "国家/地区", "pc_form.country": "国家/地区",
"pc_form.country_from": "寄出地", "pc_form.country_from": "寄出地",

View File

@@ -37,16 +37,11 @@
{% if is_new %} {% if is_new %}
{# 新建寄出:状态默认由日期自动判定,可手动覆盖 #} {# 新建寄出:状态默认由日期自动判定,可手动覆盖 #}
<label>{{ 'pc_form.status'|t(user.language) }}</label> <label>{{ 'pc_form.status'|t(user.language) }}</label>
<div style="display:flex;align-items:center;gap:.5rem"> <select name="status" id="status-select">
<select name="status" id="status-select" onchange="onStatusChange()">
<option value="auto">{{ 'pc_form.status_auto'|t(user.language) }}</option>
<option value="pending">{{ 'status.pending'|t(user.language) }}</option> <option value="pending">{{ 'status.pending'|t(user.language) }}</option>
<option value="sent">{{ 'status.sent'|t(user.language) }}</option> <option value="sent">{{ 'status.sent'|t(user.language) }}</option>
<option value="delivered">{{ 'status.delivered'|t(user.language) }}</option> <option value="delivered">{{ 'status.delivered'|t(user.language) }}</option>
</select> </select>
<span id="auto-status-hint" style="font-size:.8rem;color:var(--text-muted)"></span>
</div>
<input type="hidden" name="status" id="hidden-status" value="sent">
{% else %} {% else %}
{# 编辑时:显示状态选择 #} {# 编辑时:显示状态选择 #}
<label>{{ 'pc_form.status'|t(user.language) }} *</label> <label>{{ 'pc_form.status'|t(user.language) }} *</label>
@@ -84,17 +79,17 @@
</form> </form>
<script> <script>
{% if is_new and not is_received_form %} {% if is_new and not is_received_form %}
// ── 新建寄出:根据日期自动判定状态 ── // ── 新建寄出:根据日期自动判定状态,可手动覆盖 ──
(function() { (function() {
var sendTime = document.getElementById('input-send-time'); var sendTime = document.getElementById('input-send-time');
var hiddenStatus = document.getElementById('hidden-status');
var select = document.getElementById('status-select'); var select = document.getElementById('status-select');
var hint = document.getElementById('auto-status-hint');
var arrival = document.getElementById('input-arrival'); var arrival = document.getElementById('input-arrival');
var labelArrival = document.getElementById('label-arrival'); var labelArrival = document.getElementById('label-arrival');
var today = new Date().toISOString().slice(0, 10); var today = new Date().toISOString().slice(0, 10);
if (!sendTime.value) sendTime.value = today; if (!sendTime.value) sendTime.value = today;
var userOverrode = false;
function autoFromSendTime() { function autoFromSendTime() {
var v = sendTime.value; var v = sendTime.value;
if (!v) return 'sent'; if (!v) return 'sent';
@@ -113,26 +108,16 @@
} }
} }
function syncHint() { function sync() {
var sel = select.value;
if (sel === 'auto') {
var auto = autoFromSendTime(); var auto = autoFromSendTime();
hiddenStatus.value = auto; if (!userOverrode) select.value = auto;
hint.textContent = '→ ' + (auto === 'pending' ? '{{ "status.pending"|t(user.language) }}' : '{{ "status.sent"|t(user.language) }}'); updateArrival(select.value);
updateArrival(auto);
} else {
hiddenStatus.value = sel;
hint.textContent = '';
updateArrival(sel);
}
} }
// expose for inline onchange select.addEventListener('change', function() { userOverrode = true; updateArrival(select.value); });
window.onStatusChange = syncHint; sendTime.addEventListener('change', function() { if (!userOverrode) sync(); });
sendTime.addEventListener('input', function() { if (!userOverrode) sync(); });
sendTime.addEventListener('change', syncHint); sync();
sendTime.addEventListener('input', syncHint);
syncHint();
})(); })();
{% elif is_edit and not is_received_form %} {% elif is_edit and not is_received_form %}
// ── 编辑寄出:根据状态切换 arrival 可用性 ── // ── 编辑寄出:根据状态切换 arrival 可用性 ──