默认出勤按学校作息生成;新增"请假(整天)"按钮
1. 默认出勤:返校日仅生成晚修、放假前一天仅生成上午(中午离校,无下午/晚修)、其余上课日按所选时段;校历多取一天用于判断次日是否上课 2. 考勤页新增"请假(整天)":选中学生一键提交早/中/晚三条请假记录(各按请假扣分,配置1分时共3分/天) 3. 文档更新:请假(整天)用法与默认出勤作息规则
This commit is contained in:
1 parent
928c86bd5a
commit
d9dd7bf7e8
4 files changed
+130
-23
No files matched your search
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user