增加课表管理员密钥导出
This commit is contained in:
Vendored
+2
@@ -649,6 +649,8 @@ button:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 3px s
|
||||
.timetable-grid textarea { margin-top:6px; font-size:12px; min-width:0; }
|
||||
.timetable-editor .form-actions { flex-wrap:wrap; }
|
||||
#timetables-view .center-export .checkline { flex-direction:row; align-items:center; align-self:center; margin:0; }
|
||||
#timetables-view .timetable-admin-key-field { flex:1 1 230px; min-width:190px; }
|
||||
#timetables-view #timetable-admin-key { width:100%; }
|
||||
#timetable-confirmed-only { min-width:18px; min-height:18px; width:18px; height:18px; flex:0 0 18px; padding:0; }
|
||||
.timetable-warnings { padding:12px 14px; background:#fff7e7; border-radius:8px; font-size:13px; }
|
||||
.timetable-text { white-space:pre-wrap; overflow-wrap:anywhere; max-height:220px; overflow:auto; }
|
||||
|
||||
Vendored
+3
-3
@@ -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=23" />
|
||||
<link rel="stylesheet" href="/assets/styles.css?v=24" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">
|
||||
@@ -185,7 +185,7 @@
|
||||
<div class="page-head center-subhead"><div><h3>收取进度</h3><p class="muted" id="timetable-summary" role="status"></p></div></div>
|
||||
<div class="filters center-toolbar"><input id="timetable-q" type="search" aria-label="搜索课表成员" placeholder="搜索姓名 / 部门" /><select id="timetable-filter" aria-label="课表提交状态"><option value="all">全部成员</option><option value="complete">单双周已交齐</option><option value="incomplete">尚未交齐</option><option value="missing">均未提交</option></select><button id="timetable-refresh" class="btn">刷新</button></div>
|
||||
<div id="timetable-members" class="card-list"></div>
|
||||
<details class="center-export center-subhead"><summary>导出排班数据</summary><p class="muted" id="timetable-export-note"></p><div class="filters"><label>格式<select id="timetable-export-format"><option value="json">JSON</option><option value="csv">CSV</option></select></label><label class="checkline"><input id="timetable-confirmed-only" type="checkbox" checked /> 仅导出已核对课表</label><button id="timetable-export" class="btn primary">下载数据</button></div><p class="muted" id="timetable-export-status" role="status"></p></details>
|
||||
<details class="center-export center-subhead"><summary>导出排班数据</summary><p class="muted" id="timetable-export-note"></p><div class="filters"><label>格式<select id="timetable-export-format"><option value="json">JSON</option><option value="csv">CSV</option></select></label><label class="checkline"><input id="timetable-confirmed-only" type="checkbox" checked /> 仅导出已核对课表</label><label class="timetable-admin-key-field">管理员密钥<input id="timetable-admin-key" type="password" autocomplete="off" autocapitalize="none" spellcheck="false" placeholder="输入后导出全部课表" required /></label><button id="timetable-export" class="btn primary">下载数据</button></div><p class="muted" id="timetable-export-status" role="status"></p></details>
|
||||
</div>
|
||||
</main>
|
||||
<main id="mine-view" class="view hidden">
|
||||
@@ -322,7 +322,7 @@
|
||||
|
||||
<div id="toast" class="toast hidden" role="status" aria-live="polite"></div>
|
||||
|
||||
<script src="/js/app.js?v=34"></script>
|
||||
<script src="/js/app.js?v=35"></script>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Vendored
+21
-5
@@ -1215,7 +1215,7 @@
|
||||
const label = `${weekLabel(week)}:${item.submitted ? item.confirmed ? '已核对' : '已交待核对' : '未交'}`;
|
||||
return item.submitted && person.can_read ? `<button class="btn sm" data-timetable-view="${week}" data-user-id="${person.id}">${label}</button>` : `<span class="tag ${item.submitted ? 'attended' : ''}">${label}</span>`;
|
||||
}).join('')}</div></article>`).join('') || '<div class="empty">没有符合筛选条件的成员。</div>';
|
||||
$('#timetable-export-note').textContent = (data.can_collect ? '你可以导出所有成员的课表。' : '你可以导出自己的课表;收取负责人可统一导出全部。') + '只有已核对课表中的空闲时段可列为可值班,待确认不能当作空闲。';
|
||||
$('#timetable-export-note').textContent = '输入管理员密钥后可导出全部课表。只有已核对课表中的空闲时段可列为可值班,待确认不能当作空闲。';
|
||||
} catch (error) { if (version === timetableRequest) toast(error.message, true); }
|
||||
}
|
||||
|
||||
@@ -1364,14 +1364,30 @@
|
||||
$('#timetable-export').addEventListener('click', async () => {
|
||||
const button = $('#timetable-export'); button.disabled = true;
|
||||
const format = $('#timetable-export-format').value;
|
||||
try { await downloadCenterFile('/api/timetables/export?format=' + format + '&confirmed_only=' + $('#timetable-confirmed-only').checked, 'timetables.' + format); $('#timetable-export-status').textContent = '数据已下载。'; }
|
||||
catch (error) { $('#timetable-export-status').textContent = error.message; }
|
||||
const keyInput = $('#timetable-admin-key');
|
||||
const key = keyInput.value;
|
||||
$('#timetable-export-status').textContent = '';
|
||||
if (!key) {
|
||||
$('#timetable-export-status').textContent = '请输入管理员密钥';
|
||||
keyInput.focus();
|
||||
button.disabled = false;
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await downloadCenterFile('/api/timetables/export?format=' + format + '&confirmed_only=' + $('#timetable-confirmed-only').checked, 'timetables.' + format, { 'X-Timetable-Admin-Key': key });
|
||||
$('#timetable-export-status').textContent = '全部课表已下载。';
|
||||
keyInput.value = '';
|
||||
}
|
||||
catch (error) {
|
||||
$('#timetable-export-status').textContent = error.message;
|
||||
if (/密钥/.test(error.message)) { keyInput.value = ''; keyInput.focus(); }
|
||||
}
|
||||
finally { button.disabled = false; }
|
||||
});
|
||||
|
||||
let centerTab = 'records';
|
||||
async function downloadCenterFile(path, fallback) {
|
||||
const response = await fetch(path, { headers: { Authorization: `Bearer ${getToken()}` } });
|
||||
async function downloadCenterFile(path, fallback, extraHeaders = {}) {
|
||||
const response = await fetch(path, { headers: { ...extraHeaders, Authorization: `Bearer ${getToken()}` } });
|
||||
if (!response.ok) {
|
||||
const error = await response.json().catch(() => ({}));
|
||||
throw new Error(typeof error.detail === 'string' ? error.detail : '下载失败,请检查筛选条件或重新登录');
|
||||
|
||||
Reference in New Issue
Block a user