优化考勤记录

This commit is contained in:
2026-04-27 01:36:23 +08:00
parent 439c074534
commit 17cc08071c
7 changed files with 119 additions and 47 deletions

View File

@@ -41,9 +41,9 @@ include __DIR__ . '/../includes/header.php';
<div class="form-group" style="margin:0">
<label>时段</label>
<select id="attendanceSlot">
<option value="morning">早 8:15</option>
<option value="afternoon">午 14:00</option>
<option value="evening">晚 19:30</option>
<option value="morning">早上 7:15</option>
<option value="afternoon">午 14:00</option>
<option value="evening">晚 19:30</option>
</select>
</div>
<div class="status-group">
@@ -124,7 +124,7 @@ function renderStudentGrid() {
const currentSlot = document.getElementById('attendanceSlot').value;
let html = '';
studentsData.forEach(student => {
const hasRecord = existingRecords.some(r => r.student_id === student.student_id && (!r.slot || r.slot === currentSlot));
const hasRecord = existingRecords.some(r => r.student_id === student.student_id && r.slot === currentSlot);
html += `<div class="student-cell${hasRecord ? ' has-record' : ''}"
data-id="${student.student_id}"
data-name="${escapeHtml(student.name)}"
@@ -178,17 +178,19 @@ async function submitAttendance() {
}
const date = document.getElementById('attendanceDate').value;
const slot = document.getElementById('attendanceSlot').value;
const reason = document.getElementById('attendanceReason').value;
const customDeduction = document.getElementById('customDeduction').value;
const customDeductionValue = customDeduction ? parseInt(customDeduction) : null;
// 批量提交(不再检查已有记录,允许同一学生同一天多次考勤)
// 批量提交
const promises = [];
selectedCells.forEach(cell => {
const studentId = parseInt(cell.dataset.id);
const payload = {
student_id: studentId,
date: date,
slot: slot,
status: currentStatus,
reason: reason,
apply_deduction: true