赋能中心新增展厅使用登记实时读取

This commit is contained in:
2026-11-20 11:59:02 +08:00
parent 21e7881344
commit 1d4d148560
4 changed files with 157 additions and 4 deletions
+14 -2
View File
@@ -1538,11 +1538,12 @@
let centerRecords = [];
function openCenterFromHash() {
if (state.me && location.hash === '#timetables') { show('timetables'); return true; }
if (!state.me || !['#center', '#center-records', '#center-assets'].includes(location.hash)) return false;
centerTab = location.hash === '#center-assets' ? 'assets' : 'records';
if (!state.me || !['#center', '#center-records', '#center-assets', '#center-hall'].includes(location.hash)) return false;
centerTab = location.hash === '#center-assets' ? 'assets' : location.hash === '#center-hall' ? 'hall' : 'records';
$$('[data-center-tab]').forEach(button => button.classList.toggle('active', button.dataset.centerTab === centerTab));
$('#center-records').classList.toggle('hidden', centerTab !== 'records');
$('#center-assets').classList.toggle('hidden', centerTab !== 'assets');
$('#center-hall').classList.toggle('hidden', centerTab !== 'hall');
show('center');
return true;
}
@@ -1561,6 +1562,13 @@
const data = await api(`/activities?${p}`); centerRecords = data.items;
$('#center-record-list').innerHTML = data.items.map(a => activityCard(a)).join('') || '<div class="empty">暂无匹配的一楼活动,记录活动时请上传照片。</div>';
bindCardEvents($('#center-record-list'));
} else if (centerTab === 'hall') {
$('#center-hall-status').textContent = '正在读取金山文档登记表…';
const hall = await api('/center/hall-log');
$('#center-hall-link').href = hall.link;
$('#center-hall-link').classList.toggle('hidden', !hall.link);
$('#center-hall-status').textContent = hall.ok ? `共 ${hall.count} 条登记,更新于 ${fmtDate(hall.fetched_at)}(60 秒缓存)` : `读取失败:${hall.error}`;
$('#center-hall-list').innerHTML = hall.records.map(r => `<div class="acard"><b>${esc(r['使用事项'] || '未填写使用事项')}</b> <span class="tag joined">${esc(r['使用场地'] || '')}</span><p class="muted">${esc(r['日期'] || '')} ${esc(r['时间'] || '')} · ${esc(r['使用单位'] || '')}</p><p>参加人数:${esc(r['参加人数'] || '—')};赋能部值班:${esc(r['赋能部值班人员及联系方式'] || '—')}</p>${r['备注'] ? `<p class="muted">备注:${esc(r['备注'])}</p>` : ''}${r['使用单位联系人及联系方式'] ? `<p class="muted">联系人:${esc(r['使用单位联系人及联系方式'])}</p>` : ''}</div>`).join('') || '<div class="empty">登记表暂无数据。</div>';
} else {
const data = await api(`/center/items?q=${encodeURIComponent($('#center-item-q').value)}`);
$('#center-check-status').textContent = `${data.day} · ${data.checked_today ? '今日清点已完成' : '今日待清点,请逐项核对实际在库数量'}`;
@@ -1586,9 +1594,13 @@
$$('[data-center-tab]').forEach(b => b.classList.toggle('active', b === button));
$('#center-records').classList.toggle('hidden', centerTab !== 'records');
$('#center-assets').classList.toggle('hidden', centerTab !== 'assets');
$('#center-hall').classList.toggle('hidden', centerTab !== 'hall');
loadCenter();
}));
$('#center-new').addEventListener('click', () => openActivityForm(null, 'center'));
$('#center-hall-refresh').addEventListener('click', async () => {
try { await api('/center/hall-log?refresh=true'); } finally { await loadCenter(); }
});
function openLoanForm() {
centerForm('登记借出',
`<p class="muted">这里只保存借出记录,不占用库存,也不要求物品已加入库存清单。借出理由全员可见,联系方式仅本人可见。</p>