新增免登录物品借出登记
This commit is contained in:
Vendored
+6
-1
@@ -282,7 +282,9 @@ textarea { width: 100%; resize: vertical; }
|
||||
.auth-title { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 24px; letter-spacing: -.8px; }
|
||||
.auth-sub { color: var(--muted); margin: 10px 0 28px; font-size: 13px; }
|
||||
.tabs { display: flex; background: var(--bg); border-radius: 10px; padding: 4px; margin-bottom: 18px; }
|
||||
.tab { flex: 1; border: none; background: transparent; padding: 8px; border-radius: 8px; font-weight: 500; color: var(--muted); }
|
||||
.tabs { overflow-x: auto; scrollbar-width: none; }
|
||||
.tabs::-webkit-scrollbar { display: none; }
|
||||
.tab { flex: 1 0 auto; border: none; background: transparent; padding: 8px 10px; border-radius: 8px; font-weight: 500; color: var(--muted); white-space: nowrap; }
|
||||
.tab.active { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
|
||||
.auth-modes { display: flex; gap: 8px; margin-top: 14px; }
|
||||
.auth-mode { flex: 1; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); padding: 8px; }
|
||||
@@ -478,6 +480,9 @@ button:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 3px s
|
||||
.face:nth-child(3n) { background: #84745c; }
|
||||
.face.more { background: #e7eee8; color: var(--muted); }
|
||||
.auth-card .btn.block { margin-top: 8px; min-height: 46px; }
|
||||
#public-loan-form h3 { margin: 4px 0 6px; }
|
||||
#public-loan-form > p:first-of-type { line-height: 1.7; margin: 0 0 18px; }
|
||||
#public-loan-form textarea { min-height: 96px; }
|
||||
.auth-card .form-error:empty, .auth-card .form-hint:empty { display: none; }
|
||||
.auth-card .form-hint { margin-top: 10px; line-height: 1.7; }
|
||||
.auth-card .auth-links { margin-bottom: 16px; }
|
||||
|
||||
Vendored
+16
-2
@@ -5,7 +5,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>WorkLog · 活动记录</title>
|
||||
<meta name="theme-color" content="#f5f7f5" />
|
||||
<link rel="stylesheet" href="/assets/styles.css?v=25" />
|
||||
<link rel="stylesheet" href="/assets/styles.css?v=26" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">
|
||||
@@ -46,6 +46,7 @@
|
||||
<div class="tabs">
|
||||
<button class="tab active" data-auth="login">登录</button>
|
||||
<button class="tab" data-auth="register">注册新账号</button>
|
||||
<button class="tab" data-auth="loan">免登录借出</button>
|
||||
</div>
|
||||
<form id="login-form">
|
||||
<label>邮箱 *<input name="email" type="email" required maxlength="255" autocomplete="email" placeholder="注册时使用的邮箱" /></label>
|
||||
@@ -104,6 +105,19 @@
|
||||
<div class="form-hint muted" id="register-hint" role="status"></div>
|
||||
<button class="btn primary block" type="submit" id="register-submit">创建账号</button>
|
||||
</form>
|
||||
<form id="public-loan-form" class="hidden">
|
||||
<h3>免登录物品借出</h3>
|
||||
<p class="muted">无需注册账号即可登记。提交后只记录本次借出,不扣减库存,也不会生成活动或账号。</p>
|
||||
<label>姓名 *<input name="name" required maxlength="64" autocomplete="name" placeholder="真实姓名" /></label>
|
||||
<label>手机号 *<input name="phone" type="tel" required minlength="11" maxlength="11" pattern="1[3-9][0-9]{9}" inputmode="numeric" autocomplete="tel-national" title="请填写正确的 11 位手机号" placeholder="11 位手机号" /></label>
|
||||
<label>学院 *<input name="college" required maxlength="100" placeholder="例如:计算机学院" /></label>
|
||||
<label>活动名称 *<input name="activity_name" required maxlength="160" placeholder="例如:社团迎新活动" /></label>
|
||||
<label>借出物品与数量 *<textarea name="note" required maxlength="500" placeholder="例如:投影仪 1 台、HDMI 线 1 根、插线板 2 个"></textarea></label>
|
||||
<p class="form-hint muted">请如实填写接触的物品和数量,归还时请现场核对。</p>
|
||||
<div class="form-error" id="public-loan-error" role="alert"></div>
|
||||
<div class="form-hint muted" id="public-loan-status" role="status"></div>
|
||||
<button class="btn primary block" type="submit" id="public-loan-submit">提交借出登记</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@@ -323,7 +337,7 @@
|
||||
|
||||
<div id="toast" class="toast hidden" role="status" aria-live="polite"></div>
|
||||
|
||||
<script src="/js/app.js?v=37"></script>
|
||||
<script src="/js/app.js?v=38"></script>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Vendored
+41
-1
@@ -369,12 +369,47 @@
|
||||
});
|
||||
bindSendCode("#send-code-btn", "#register-form [name=email]", "#register-hint", "#register-error", "register");
|
||||
|
||||
$("#public-loan-form").addEventListener("submit", async (event) => {
|
||||
event.preventDefault();
|
||||
const form = event.target;
|
||||
const button = $("#public-loan-submit");
|
||||
$("#public-loan-error").textContent = "";
|
||||
$("#public-loan-status").textContent = "";
|
||||
if (!/^1[3-9]\d{9}$/.test(form.phone.value.trim())) {
|
||||
$("#public-loan-error").textContent = "请填写正确的 11 位手机号";
|
||||
form.phone.focus();
|
||||
return;
|
||||
}
|
||||
button.disabled = true;
|
||||
button.textContent = "正在提交…";
|
||||
try {
|
||||
const data = await api("/center/public-loans", {
|
||||
method: "POST",
|
||||
body: {
|
||||
name: form.name.value.trim(),
|
||||
phone: form.phone.value.trim(),
|
||||
college: form.college.value.trim(),
|
||||
activity_name: form.activity_name.value.trim(),
|
||||
note: form.note.value.trim(),
|
||||
},
|
||||
});
|
||||
form.reset();
|
||||
$("#public-loan-status").textContent = `登记成功,编号 ${data.id.slice(-8).toUpperCase()}。请按现场要求归还物品。`;
|
||||
} catch (error) {
|
||||
$("#public-loan-error").textContent = error.message;
|
||||
} finally {
|
||||
button.disabled = false;
|
||||
button.textContent = "提交借出登记";
|
||||
}
|
||||
});
|
||||
|
||||
$$(".tab").forEach((t) =>
|
||||
t.addEventListener("click", () => {
|
||||
$$(".tab").forEach((x) => x.classList.toggle("active", x === t));
|
||||
$("#login-form").classList.toggle("hidden", t.dataset.auth !== "login");
|
||||
$("#reset-form").classList.add("hidden");
|
||||
$("#register-form").classList.toggle("hidden", t.dataset.auth !== "register");
|
||||
$("#public-loan-form").classList.toggle("hidden", t.dataset.auth !== "loan");
|
||||
})
|
||||
);
|
||||
|
||||
@@ -1533,7 +1568,12 @@
|
||||
$('#center-check').textContent = data.checked_today && canEditCheck ? '修改今日清点' : '完成今日清点';
|
||||
$('#center-items').innerHTML = data.items.map(item => `<div class="mcard"><b>${esc(item.name)}</b><p class="muted">总数 ${item.quantity}${item.borrowed ? ` · 历史借出 ${item.borrowed}` : ''} · 在库 ${item.available}</p></div>`).join('') || '<div class="empty">还没有库存物品,可点击“添加物品”建立清点清单。</div>';
|
||||
const loans = await api(`/center/loans?status=${$('#center-loan-status').value}`);
|
||||
$('#center-loans').innerHTML = loans.items.map(r => `<div class="acard"><b>${esc(r.item_name)} × ${r.quantity}</b> <span class="tag ${r.returned_at ? 'attended' : 'joined'}">${({pending:'历史待处理',approved:'历史借出中',recorded:'已登记',returned:'历史已归还',rejected:'历史未借出'})[r.status] || r.status}</span><p class="muted">${esc(r.display_name)} · ${fmtDate(r.created_at)}</p><p>${esc(r.reason)}</p>${r.contact ? `<p class="muted">联系方式:${esc(r.contact)}</p>` : ''}${r.status === 'approved' && r.item_id && r.user_id === state.me.id ? `<button class="btn sm" data-return="${r.id}">登记归还</button>` : ''}</div>`).join('') || '<div class="empty">暂无借出登记。</div>';
|
||||
$('#center-loans').innerHTML = loans.items.map(r => {
|
||||
const guest = r.user_id === null;
|
||||
const quantity = guest ? '' : ` × ${r.quantity}`;
|
||||
const context = guest ? `<p class="muted">${esc(r.guest_college || '')} · ${esc(r.guest_activity_name || '')}</p>` : '';
|
||||
return `<div class="acard"><b>${esc(r.item_name)}${quantity}</b> <span class="tag ${r.returned_at ? 'attended' : 'joined'}">${guest ? '免登录登记' : (({pending:'历史待处理',approved:'历史借出中',recorded:'已登记',returned:'历史已归还',rejected:'历史未借出'})[r.status] || r.status)}</span><p class="muted">${esc(r.display_name || '未知登记人')} · ${fmtDate(r.created_at)}</p>${context}<p>${esc(r.reason)}</p>${r.contact ? `<p class="muted">联系方式:${esc(r.contact)}</p>` : ''}${r.status === 'approved' && r.item_id && r.user_id === state.me.id ? `<button class="btn sm" data-return="${r.id}">登记归还</button>` : ''}</div>`;
|
||||
}).join('') || '<div class="empty">暂无借出登记。</div>';
|
||||
const checks = await api('/center/checks');
|
||||
$('#center-checks').innerHTML = checks.items.map(r => `<div class="acard"><b>${esc(r.day)}</b><p class="muted">${esc(r.display_name)} · ${fmtDate(r.created_at)}</p>${r.details.map(d => `<p>${esc(d.name)}:应在库 ${d.expected},实点 ${d.actual},借出 ${d.borrowed}</p>`).join('')}<p>${esc(r.note)}</p></div>`).join('') || '<p class="muted">暂无清点记录。</p>';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user