默认出勤按学校作息生成;新增"请假(整天)"按钮

1. 默认出勤:返校日仅生成晚修、放假前一天仅生成上午(中午离校,无下午/晚修)、其余上课日按所选时段;校历多取一天用于判断次日是否上课
2. 考勤页新增"请假(整天)":选中学生一键提交早/中/晚三条请假记录(各按请假扣分,配置1分时共3分/天)
3. 文档更新:请假(整天)用法与默认出勤作息规则
This commit is contained in:
canglan committed 2026-11-26 09:39:57 +08:00
1 parent 928c86bd5a
commit d9dd7bf7e8
4 files changed
+130 -23

No files matched your search

+2 -1
View File
@@ -53,6 +53,7 @@ include __DIR__ . '/../includes/header.php';
<?php if (has_perm('manage_calendar')): ?>
<button class="btn btn-ghost" onclick="openCalendarModal()">节假日/补课</button>
<?php endif; ?>
<button class="btn btn-secondary" onclick="submitFullDayLeave()">请假(整天)</button>
<button class="btn btn-danger" onclick="submitAttendance()">提交考勤</button>
</div>
<div class="attendance-toolbar">
@@ -111,7 +112,7 @@ include __DIR__ . '/../includes/header.php';
<span style="color:#999;">至</span>
<input type="date" id="defaultEndDate" style="width:auto;">
</div>
<small>跳过周末与法定节假日(在线接口获取),调休补班与手动补课日照常;已有的考勤记录(含异常)不会被覆盖</small>
<small>按学校常规作息生成:返校日晚修、放假前一天仅上午(中午离校)、其余上课日按所选时段;跳过周末与法定节假日(调休补课日照常),已有记录不覆盖</small>
</div>
<div class="form-group">
<label>时段</label>
+60
View File
@@ -375,6 +375,65 @@ async function deleteCalendarDay(day) {
}
}
// ========== 请假(整天) ==========
async function submitFullDayLeave() {
const selectedCells = document.querySelectorAll('.student-cell.selected');
if (selectedCells.length === 0) {
showToast('请先选择请假的学生', 'warning');
return;
}
const date = document.getElementById('attendanceDate').value;
if (!date) {
showToast('请选择日期', 'warning');
return;
}
// 整天请假 = 早/中/晚 三个时段,各按"请假"扣分
const perDeduction = attendanceDeductionMap.leave || 0;
const totalPerStudent = perDeduction * 3;
const confirmText = perDeduction > 0
? '确定为选中的学生提交整天请假吗?(早/中/晚各扣' + perDeduction + '分,共' + totalPerStudent + '分/人)'
: '确定为选中的学生提交整天请假吗?(早/中/晚三个时段)';
if (!confirm(confirmText)) return;
const reason = document.getElementById('attendanceReason').value;
const slots = ['morning', 'afternoon', 'evening'];
const promises = [];
selectedCells.forEach(cell => {
const studentId = parseInt(cell.dataset.id);
slots.forEach(slot => {
const payload = {
student_id: studentId,
date: date,
slot: slot,
status: 'leave',
reason: reason,
apply_deduction: true
};
if (perDeduction > 0) {
payload.custom_deduction = perDeduction;
}
promises.push(apiPost('/api/admin/attendance', payload));
});
});
const results = await Promise.allSettled(promises);
const succeeded = results.filter(r => r.status === 'fulfilled' && r.value?.success).length;
const failed = results.length - succeeded;
if (failed === 0) {
showToast(`整天请假提交成功(${succeeded}条` + (perDeduction > 0 ? `,${totalPerStudent}分/人` : '') + ')');
} else {
showToast(`提交完成:成功${succeeded}条,失败${failed}条`, 'error');
}
deselectAllStudents();
await loadExistingRecords();
loadAttendanceRecords();
}
// 页面初始化
initAttendanceButtons();
loadStudents();
@@ -389,6 +448,7 @@ window.submitAttendance = submitAttendance;
window.loadAttendanceRecords = loadAttendanceRecords;
window.openDefaultAttendanceModal = openDefaultAttendanceModal;
window.submitDefaultAttendance = submitDefaultAttendance;
window.submitFullDayLeave = submitFullDayLeave;
window.openCalendarModal = openCalendarModal;
window.loadCalendar = loadCalendar;
window.addCalendarDay = addCalendarDay;