改进课表校对为缩小原图和半透明按钮浮层
This commit is contained in:
+1
-1
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
程序根据星期列、节次以及课程块覆盖范围整理周一至周五20个时段。完整定位的彩色课表可根据留白建议“无课”,仅保存 `busy` / `free`;课程名、教师、教室和识别原文留空。表格未完整展示、缺少可靠定位或不是彩色课表时,回退文字位置判断,无法确定的时段保持 `unknown`,不会把识别失败当作无课。节次与星期仅有少量漏字时可参考相邻标签定位;边界或行位置不可靠则交由本人核对。晚间和周末课程不参与当前四个值班时段判断。
|
程序根据星期列、节次以及课程块覆盖范围整理周一至周五20个时段。完整定位的彩色课表可根据留白建议“无课”,仅保存 `busy` / `free`;课程名、教师、教室和识别原文留空。表格未完整展示、缺少可靠定位或不是彩色课表时,回退文字位置判断,无法确定的时段保持 `unknown`,不会把识别失败当作无课。节次与星期仅有少量漏字时可参考相邻标签定位;边界或行位置不可靠则交由本人核对。晚间和周末课程不参与当前四个值班时段判断。
|
||||||
|
|
||||||
本人在校对页面只需选择“有课 / 无课”,定位失败时保留“待确认”。界面显示有课、无课及待确认时段数,不再要求填写课程备注。核对后可将其余待确认设为无课。保存草稿不等于确认;只有20个时段均已明确,才能点击“核对无误并确认”。识别组件异常时仍保存图片并提供手动整理。自动结果始终需要核对,只有已确认的无课时段才可供排班使用。
|
校对页面默认缩小显示完整原图,校对表先收起。点击“校对课表”后,在原图上显示半透明校对层;点击时段按钮即可切换“有课 / 无课”,定位失败时保留“待确认”。有课按钮用红色标注,可随时收起校对层或放大原图;收起、放大不丢失当前修改。界面显示有课、无课及待确认时段数,不再要求填写课程备注。核对后可将其余待确认设为无课。保存草稿不等于确认;只有20个时段均已明确,才能点击“核对无误并确认”。识别组件异常时仍保存图片并提供手动整理。自动结果始终需要核对,只有已确认的无课时段才可供排班使用。
|
||||||
|
|
||||||
这次仅收取和整理数据,不会自动修改已有值班表或发送额外邮件。
|
这次仅收取和整理数据,不会自动修改已有值班表或发送额外邮件。
|
||||||
|
|
||||||
|
|||||||
Vendored
+35
-3
@@ -608,9 +608,34 @@ button:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 3px s
|
|||||||
.timetable-card .form-actions { justify-content:flex-start; flex-wrap:wrap; }
|
.timetable-card .form-actions { justify-content:flex-start; flex-wrap:wrap; }
|
||||||
.timetable-member { display:flex; justify-content:space-between; align-items:center; gap:16px; padding:18px 22px; }
|
.timetable-member { display:flex; justify-content:space-between; align-items:center; gap:16px; padding:18px 22px; }
|
||||||
.timetable-member .acard-actions { flex-wrap:wrap; }
|
.timetable-member .acard-actions { flex-wrap:wrap; }
|
||||||
.timetable-editor { max-width:1100px; width:100%; }
|
.timetable-editor { max-width:860px; width:100%; }
|
||||||
.timetable-source { max-height:50vh; overflow:auto; margin:16px 0; border:1px solid var(--line); border-radius:8px; }
|
.timetable-review-toolbar { display:flex; align-items:center; flex-wrap:wrap; gap:10px; margin:16px 0; }
|
||||||
.timetable-source img { display:block; width:100%; height:auto; }
|
.timetable-review-toolbar .muted { margin-left:auto; }
|
||||||
|
.timetable-review-stage { display:grid; align-items:center; position:relative; }
|
||||||
|
.timetable-source { grid-area:1 / 1; display:grid; justify-items:center; max-height:66vh; min-height:200px; overflow:auto; margin:0; padding:8px; border:1px solid var(--line); border-radius:12px; background:#f5f7f5; }
|
||||||
|
.timetable-source img { display:block; width:auto; height:auto; max-width:100%; max-height:calc(66vh - 20px); object-fit:contain; }
|
||||||
|
.timetable-review-stage.is-expanded .timetable-source { display:block; }
|
||||||
|
.timetable-review-stage.is-expanded .timetable-source img { width:100%; max-height:none; }
|
||||||
|
.timetable-review-panel { grid-area:1 / 1; z-index:1; width:calc(100% - 16px); max-height:calc(66vh - 16px); overflow:auto; justify-self:center; padding:14px; border:1px solid rgba(255,255,255,.85); border-radius:12px; background:rgba(255,255,255,.48); box-shadow:0 8px 28px rgba(38,60,53,.12); }
|
||||||
|
.timetable-review-panel[hidden] { display:none; }
|
||||||
|
.timetable-review-panel .timetable-grid-wrap { margin:0 0 10px; }
|
||||||
|
.timetable-review-panel .timetable-grid { min-width:0; table-layout:fixed; }
|
||||||
|
.timetable-review-panel .timetable-grid th,.timetable-review-panel .timetable-grid td { padding:6px; min-width:0; border-color:rgba(38,60,53,.18); }
|
||||||
|
.timetable-review-panel .timetable-grid th { background:rgba(234,243,237,.65); }
|
||||||
|
.timetable-review-panel .timetable-grid small { display:block; font-size:10px; font-weight:400; }
|
||||||
|
.timetable-review-panel td[data-status=busy] { background:rgba(255,241,242,.35); }
|
||||||
|
.timetable-review-panel td[data-status=free] { background:rgba(234,243,237,.3); }
|
||||||
|
.timetable-review-panel td[data-status=unknown] { background:rgba(255,247,231,.4); }
|
||||||
|
.timetable-status-button { display:block; width:100%; min-height:42px; padding:6px 3px; border:1px solid rgba(40,102,79,.35); border-radius:8px; background:rgba(234,243,237,.76); color:var(--primary); font-size:13px; font-weight:600; }
|
||||||
|
.timetable-grid td[data-status=busy] .timetable-status-button { border-color:rgba(185,28,28,.5); background:rgba(254,226,226,.8); color:#991b1b; }
|
||||||
|
.timetable-grid td[data-status=unknown] .timetable-status-button { border-color:rgba(180,83,9,.45); background:rgba(255,247,231,.8); color:#92400e; }
|
||||||
|
.timetable-status-button:hover { outline:2px solid currentColor; outline-offset:1px; }
|
||||||
|
.timetable-status-button:focus-visible { outline:3px solid var(--primary); outline-offset:2px; }
|
||||||
|
.timetable-status-button:disabled { opacity:1; cursor:default; }
|
||||||
|
.timetable-review-panel #timetable-confirmation-state { padding:4px 6px; border-radius:4px; color:var(--ink); background:rgba(255,255,255,.7); }
|
||||||
|
.timetable-review-panel .form-actions { margin-top:10px; }
|
||||||
|
.timetable-recognition-notes { margin-top:12px; font-size:13px; }
|
||||||
|
.timetable-recognition-notes summary { cursor:pointer; color:var(--muted); }
|
||||||
.timetable-grid-wrap { overflow-x:auto; margin:16px 0; }
|
.timetable-grid-wrap { overflow-x:auto; margin:16px 0; }
|
||||||
.timetable-grid { border-collapse:collapse; width:100%; min-width:680px; font-size:13px; }
|
.timetable-grid { border-collapse:collapse; width:100%; min-width:680px; font-size:13px; }
|
||||||
.timetable-grid th,.timetable-grid td { border:1px solid var(--line); padding:10px; vertical-align:top; }
|
.timetable-grid th,.timetable-grid td { border:1px solid var(--line); padding:10px; vertical-align:top; }
|
||||||
@@ -628,6 +653,13 @@ button:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 3px s
|
|||||||
.timetable-warnings { padding:12px 14px; background:#fff7e7; border-radius:8px; font-size:13px; }
|
.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; }
|
.timetable-text { white-space:pre-wrap; overflow-wrap:anywhere; max-height:220px; overflow:auto; }
|
||||||
@media (max-width:600px) { .timetable-mine { grid-template-columns:1fr; } .timetable-member { flex-wrap:wrap; } .timetable-member .acard-actions { width:100%; } }
|
@media (max-width:600px) { .timetable-mine { grid-template-columns:1fr; } .timetable-member { flex-wrap:wrap; } .timetable-member .acard-actions { width:100%; } }
|
||||||
|
@media (max-width:600px) {
|
||||||
|
.timetable-review-toolbar .muted { flex-basis:100%; margin-left:0; }
|
||||||
|
.timetable-review-panel { width:calc(100% - 8px); padding:7px; }
|
||||||
|
.timetable-review-panel .timetable-grid th,.timetable-review-panel .timetable-grid td { padding:4px 2px; font-size:11px; }
|
||||||
|
.timetable-review-panel .timetable-grid small { font-size:9px; }
|
||||||
|
.timetable-status-button { font-size:12px; }
|
||||||
|
}
|
||||||
.center-history { margin-top:28px; }
|
.center-history { margin-top:28px; }
|
||||||
.center-history summary { cursor:pointer; padding:12px 0; }
|
.center-history summary { cursor:pointer; padding:12px 0; }
|
||||||
.center-history .acard { margin-top:12px; }
|
.center-history .acard { margin-top:12px; }
|
||||||
|
|||||||
Vendored
+2
-2
@@ -5,7 +5,7 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>WorkLog · 活动记录</title>
|
<title>WorkLog · 活动记录</title>
|
||||||
<meta name="theme-color" content="#f5f7f5" />
|
<meta name="theme-color" content="#f5f7f5" />
|
||||||
<link rel="stylesheet" href="/assets/styles.css?v=21" />
|
<link rel="stylesheet" href="/assets/styles.css?v=22" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app">
|
<div id="app">
|
||||||
@@ -322,7 +322,7 @@
|
|||||||
|
|
||||||
<div id="toast" class="toast hidden" role="status" aria-live="polite"></div>
|
<div id="toast" class="toast hidden" role="status" aria-live="polite"></div>
|
||||||
|
|
||||||
<script src="/js/app.js?v=32"></script>
|
<script src="/js/app.js?v=33"></script>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Vendored
+51
-19
@@ -1253,18 +1253,22 @@
|
|||||||
const cells = item.structure.cells;
|
const cells = item.structure.cells;
|
||||||
const slots = timetableData.slots, days = timetableData.days;
|
const slots = timetableData.slots, days = timetableData.days;
|
||||||
const statusLabels = { unknown: '待确认', busy: '有课', free: '无课' };
|
const statusLabels = { unknown: '待确认', busy: '有课', free: '无课' };
|
||||||
const counts = {busy:0, free:0, unknown:0}; cells.forEach(cell => counts[cell.status]++);
|
modal(`<h3>${weekLabel(item.week_type)}课表 · ${editable ? '核对与修改' : '查看'}</h3><p class="modal-sub muted">${editable ? '点击“校对课表”打开半透明校对层,再点时段按钮切换有课/无课。' : '点击“查看时段”对照原图查看有课/无课状态。'}</p>
|
||||||
const recognitionSummary = `${counts.busy}个有课时段 · ${counts.free}个无课时段${counts.unknown ? ' · ' + counts.unknown + '个待确认' : ''}`;
|
<div class="timetable-review-toolbar"><button class="btn primary" type="button" id="timetable-review-toggle" aria-expanded="false" aria-controls="timetable-review-panel">${editable ? '校对课表' : '查看时段'}</button><button class="btn" type="button" id="timetable-image-zoom" aria-pressed="false">放大原图</button><span class="muted" id="timetable-recognition-summary" role="status"></span></div>
|
||||||
modal(`<h3>${weekLabel(item.week_type)}课表 · ${editable ? '核对与修改' : '查看'}</h3><p class="modal-sub muted">只记录周一至周五四个值班时段的有课/无课状态。请对照原图核对后确认。</p>
|
<div class="timetable-review-stage" id="timetable-review-stage">
|
||||||
<div class="timetable-source"><img id="timetable-source-image" alt="课表原图" /><p class="muted" id="timetable-image-status">正在加载原图…</p></div>
|
<div class="timetable-source"><img id="timetable-source-image" alt="课表原图" /><p class="muted" id="timetable-image-status">正在加载原图…</p></div>
|
||||||
<p class="muted">${recognitionSummary}</p><div class="timetable-warnings">${item.structure.warnings.map(esc).join('<br />')}</div>
|
<form id="timetable-correction-form" class="timetable-review-panel" hidden><div id="timetable-review-panel">
|
||||||
<form id="timetable-correction-form"><div class="timetable-grid-wrap"><table class="timetable-grid"><thead><tr><th scope="col">值班时段</th>${days.map(day => `<th scope="col">${esc(day)}</th>`).join('')}</tr></thead><tbody>${slots.map(slot => `<tr><th scope="row">${esc(slot.label)}<br />${slot.start}–${slot.end}</th>${days.map((_, i) => {
|
<div class="timetable-grid-wrap"><table class="timetable-grid"><thead><tr><th scope="col">值班时段</th>${days.map(day => `<th scope="col">${esc(day)}</th>`).join('')}</tr></thead><tbody>${slots.map(slot => `<tr><th scope="row">${esc(slot.label)}<small>${slot.start}<br />${slot.end}</small></th>${days.map((_, i) => {
|
||||||
const index = cells.findIndex(cell => cell.day === i+1 && cell.slot === slot.id), cell = cells[index];
|
const index = cells.findIndex(cell => cell.day === i+1 && cell.slot === slot.id), cell = cells[index];
|
||||||
return `<td data-status="${cell.status}">${editable ? `<select aria-label="${days[i]}${slot.label}状态" data-cell="${index}">${Object.entries(statusLabels).map(([value,label]) => `<option value="${value}" ${cell.status === value ? 'selected' : ''}>${label}</option>`).join('')}</select>` : `<strong>${statusLabels[cell.status]}</strong>`}</td>`;
|
return `<td data-status="${cell.status}"><button type="button" class="timetable-status-button" aria-label="${days[i]}${slot.label}:${statusLabels[cell.status]}" aria-pressed="${cell.status === 'unknown' ? 'mixed' : cell.status === 'busy'}" data-cell="${index}" data-value="${cell.status}" ${editable ? '' : 'disabled'}>${statusLabels[cell.status]}</button></td>`;
|
||||||
}).join('')}</tr>`).join('')}</tbody></table></div>
|
}).join('')}</tr>`).join('')}</tbody></table></div>
|
||||||
${editable ? '<button class="btn sm" type="button" id="timetable-fill-free">将其余待确认设为无课</button>' : ''}
|
${editable ? '<button class="btn sm" type="button" id="timetable-fill-free">将其余待确认设为无课</button>' : ''}
|
||||||
<div class="form-error" role="alert"></div><p class="muted" id="timetable-confirmation-state">${item.confirmed_at ? '已核对,确认时间:' + fmtDate(item.confirmed_at) : '尚未核对,暂不能作为可值班依据。'}</p>
|
<div class="form-error" role="alert"></div><p class="muted" id="timetable-confirmation-state">${item.confirmed_at ? '已核对,确认时间:' + fmtDate(item.confirmed_at) : '对照背景课表,核对后再确认。'}</p>
|
||||||
<div class="form-actions"><button class="btn" type="button" id="timetable-download-image">下载原图</button><button class="btn" type="button" id="timetable-editor-close">关闭</button>${editable ? '<button class="btn" type="submit" data-confirm="false">保存草稿</button><button class="btn primary" type="submit" data-confirm="true">核对无误并确认</button>' : ''}</div></form>`);
|
${editable ? '<div class="form-actions"><button class="btn" type="submit" data-confirm="false">保存草稿</button><button class="btn primary" type="submit" data-confirm="true">核对无误并确认</button></div>' : ''}
|
||||||
|
</div></form>
|
||||||
|
</div>
|
||||||
|
<details class="timetable-recognition-notes"><summary>识别说明</summary><p class="muted">${item.structure.warnings.map(esc).join('<br />')}</p></details>
|
||||||
|
<div class="form-actions"><button class="btn" type="button" id="timetable-download-image">下载原图</button><button class="btn" type="button" id="timetable-editor-close">关闭</button></div>`);
|
||||||
$('#modal-root .modal').classList.add('timetable-editor');
|
$('#modal-root .modal').classList.add('timetable-editor');
|
||||||
const form = $('#timetable-correction-form'), img = $('#timetable-source-image'), imageStatus = $('#timetable-image-status');
|
const form = $('#timetable-correction-form'), img = $('#timetable-source-image'), imageStatus = $('#timetable-image-status');
|
||||||
$('#timetable-editor-close').addEventListener('click', closeModal);
|
$('#timetable-editor-close').addEventListener('click', closeModal);
|
||||||
@@ -1279,28 +1283,56 @@
|
|||||||
fetch(item.image_url, { headers: { Authorization: `Bearer ${getToken()}` } }).then(async response => {
|
fetch(item.image_url, { headers: { Authorization: `Bearer ${getToken()}` } }).then(async response => {
|
||||||
if (!response.ok) throw new Error('原图暂不可用,请关闭后重新打开');
|
if (!response.ok) throw new Error('原图暂不可用,请关闭后重新打开');
|
||||||
const blob = await response.blob(); if (!img.isConnected) return;
|
const blob = await response.blob(); if (!img.isConnected) return;
|
||||||
imageUrl = URL.createObjectURL(blob); img.src = imageUrl; imageStatus.textContent = '';
|
imageUrl = URL.createObjectURL(blob); img.src = imageUrl; imageStatus.textContent = ''; imageStatus.classList.add('hidden');
|
||||||
}).catch(error => { imageStatus.textContent = error.message; });
|
}).catch(error => { imageStatus.textContent = error.message; });
|
||||||
|
const stage = $('#timetable-review-stage'), reviewButton = $('#timetable-review-toggle');
|
||||||
|
reviewButton.addEventListener('click', () => {
|
||||||
|
const open = form.hidden;
|
||||||
|
form.hidden = !open; stage.classList.toggle('is-reviewing', open);
|
||||||
|
reviewButton.setAttribute('aria-expanded', String(open));
|
||||||
|
reviewButton.textContent = open ? (editable ? '收起校对' : '收起时段') : (editable ? '校对课表' : '查看时段');
|
||||||
|
});
|
||||||
|
$('#timetable-image-zoom').addEventListener('click', event => {
|
||||||
|
const expanded = stage.classList.toggle('is-expanded');
|
||||||
|
event.currentTarget.setAttribute('aria-pressed', String(expanded));
|
||||||
|
event.currentTarget.textContent = expanded ? '缩小原图' : '放大原图';
|
||||||
|
});
|
||||||
|
const updateSummary = () => {
|
||||||
|
const counts = {busy:0, free:0, unknown:0};
|
||||||
|
form.querySelectorAll('[data-cell]').forEach(button => counts[button.dataset.value]++);
|
||||||
|
$('#timetable-recognition-summary').textContent = `${counts.busy}个有课 · ${counts.free}个无课${counts.unknown ? ' · ' + counts.unknown + '个待确认' : ''}`;
|
||||||
|
if (editable) $('#timetable-fill-free').classList.toggle('hidden', counts.unknown === 0);
|
||||||
|
};
|
||||||
|
updateSummary();
|
||||||
if (!editable) return;
|
if (!editable) return;
|
||||||
form.querySelectorAll('[data-cell]').forEach(select => select.addEventListener('change', () => {
|
const setCellStatus = (button, status) => {
|
||||||
select.closest('td').dataset.status = select.value;
|
button.dataset.value = status; button.textContent = statusLabels[status];
|
||||||
|
button.closest('td').dataset.status = status;
|
||||||
|
form.querySelector('.form-error').textContent = '';
|
||||||
|
const cell = cells[Number(button.dataset.cell)], slot = slots.find(slot => slot.id === cell.slot);
|
||||||
|
button.setAttribute('aria-label', `${days[cell.day-1]}${slot.label}:${statusLabels[status]}`);
|
||||||
|
button.setAttribute('aria-pressed', String(status === 'busy'));
|
||||||
form.querySelector('#timetable-confirmation-state').textContent = '有未保存修改,请重新保存并确认。';
|
form.querySelector('#timetable-confirmation-state').textContent = '有未保存修改,请重新保存并确认。';
|
||||||
|
updateSummary();
|
||||||
|
};
|
||||||
|
form.querySelectorAll('[data-cell]').forEach(button => button.addEventListener('click', () => {
|
||||||
|
setCellStatus(button, button.dataset.value === 'busy' ? 'free' : 'busy');
|
||||||
}));
|
}));
|
||||||
$('#timetable-fill-free').addEventListener('click', () => {
|
$('#timetable-fill-free').addEventListener('click', () => {
|
||||||
form.querySelectorAll('[data-cell]').forEach(select => { if (select.value === 'unknown') { select.value = 'free'; select.dispatchEvent(new Event('change')); } });
|
form.querySelectorAll('[data-cell]').forEach(button => { if (button.dataset.value === 'unknown') setCellStatus(button, 'free'); });
|
||||||
});
|
});
|
||||||
let saving = false;
|
let saving = false;
|
||||||
form.addEventListener('submit', async event => {
|
form.addEventListener('submit', async event => {
|
||||||
event.preventDefault(); if (saving) return;
|
event.preventDefault(); if (saving) return;
|
||||||
const confirm = event.submitter?.dataset.confirm === 'true';
|
const confirm = event.submitter?.dataset.confirm === 'true';
|
||||||
const edited = cells.map((cell,index) => ({ day: cell.day, slot: cell.slot, status: form.querySelector(`[data-cell="${index}"]`).value, courses: '' }));
|
const edited = cells.map((cell,index) => ({ day: cell.day, slot: cell.slot, status: form.querySelector(`[data-cell="${index}"]`).dataset.value, courses: '' }));
|
||||||
const errorBox = form.querySelector('.form-error'); errorBox.textContent = '';
|
const errorBox = form.querySelector('.form-error'); errorBox.textContent = '';
|
||||||
if (confirm && edited.some(cell => cell.status === 'unknown')) { errorBox.textContent = '仍有待确认时段,请核对后再确认'; return; }
|
if (confirm && edited.some(cell => cell.status === 'unknown')) { errorBox.textContent = '仍有待确认时段,请核对后再确认'; return; }
|
||||||
saving = true; form.querySelectorAll('[type=submit]').forEach(button => button.disabled = true);
|
saving = true; form.querySelectorAll('button').forEach(button => button.disabled = true);
|
||||||
try {
|
try {
|
||||||
await api('/timetables/me/' + item.week_type, { method: 'PATCH', body: { revision: item.revision, cells: edited, confirm } });
|
await api('/timetables/me/' + item.week_type, { method: 'PATCH', body: { revision: item.revision, cells: edited, confirm } });
|
||||||
closeModal(); toast(confirm ? '课表已核对确认' : '草稿已保存'); loadTimetables();
|
closeModal(); toast(confirm ? '课表已核对确认' : '草稿已保存'); loadTimetables();
|
||||||
} catch (error) { errorBox.textContent = error.message; saving = false; form.querySelectorAll('[type=submit]').forEach(button => button.disabled = false); }
|
} catch (error) { errorBox.textContent = error.message; saving = false; form.querySelectorAll('button').forEach(button => button.disabled = false); }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user