v4.5 考勤默认出勤/校历、作业按次登记与权限体系完善
1. 考勤默认出勤:按日期范围给缺失学生批量补"出勤"(跳过周末/法定节假日,调休补班与手动补课日照常,已有记录不覆盖) 2. 节假日/补课校历:法定节假日与调休补班来自在线接口(缓存+失败降级),支持手动添加放假/补课(存 system_settings,优先于接口) 3. 作业按次登记:一次登记覆盖多次作业,配置总提交次数,按每人缺交次数自动扣分(单次缺交扣分x次数),并写入作业提交数据供"数据报表-作业统计"使用 4. 权限体系:新增 homework_register/default_attendance/manage_calendar 权限项;数据报表/操作日志/系统设置拆分为 view_reports/view_logs/manage_settings,共20项功能权限可配置;预置组默认值与 init.sql 同步 5. 权限审计修复:学生端接口管理员越权修复(管理员查看需 view_all_records,学生仅本人);学生列表手机号仅向学生管理/导出名单权限下发;操行分管理页与导航补权限门控 6. v4.5.sql:为预置权限组补充新权限默认值(JSON_SET,幂等可重复执行)
This commit is contained in:
1 parent
4c57ba3a30
commit
4c1ca13a3f
34 files changed
+1438
-48
No files matched your search
@@ -21,6 +21,10 @@ document.querySelectorAll('.hw-max').forEach(el => el.textContent = describeScor
|
||||
// 更新输入框的 min/max(按权限组动态上限)
|
||||
applyScoreLimits(document.getElementById('pointsChange'));
|
||||
|
||||
// 按次登记默认单次缺交扣分
|
||||
const regPerInput = document.getElementById('hwRegPerDeduction');
|
||||
if (regPerInput) regPerInput.value = hwNotSubmit;
|
||||
|
||||
// 加载科目列表(学习委员)
|
||||
async function loadSubjectsForHomework() {
|
||||
const subjectSelect = document.getElementById('hwSubjectSelect');
|
||||
@@ -259,6 +263,114 @@ async function submitEditSubject() {
|
||||
}
|
||||
}
|
||||
|
||||
// ========== 作业按次登记 ==========
|
||||
|
||||
async function showHomeworkRegisterModal() {
|
||||
const checked = Array.from(document.querySelectorAll('.student-checkbox:checked'));
|
||||
if (checked.length === 0) {
|
||||
showToast('请先在学生列表中勾选缺交学生', 'warning');
|
||||
return;
|
||||
}
|
||||
|
||||
// 科目下拉(值为科目ID)
|
||||
const subjectSelect = document.getElementById('hwRegSubject');
|
||||
const subRes = await apiGet('/api/subject/list', { is_active: true });
|
||||
let options = '<option value="">请选择科目</option>';
|
||||
if (subRes && subRes.success && subRes.data && subRes.data.subjects) {
|
||||
subRes.data.subjects.forEach(s => {
|
||||
options += `<option value="${s.subject_id}">${escapeHtml(s.subject_name)}</option>`;
|
||||
});
|
||||
}
|
||||
subjectSelect.innerHTML = options;
|
||||
|
||||
// 缺交学生列表(每人可填缺交次数)
|
||||
let html = '';
|
||||
checked.forEach(cb => {
|
||||
const row = cb.closest('tr');
|
||||
const no = row ? row.children[1].textContent.trim() : '';
|
||||
const name = row ? row.children[2].textContent.trim() : '';
|
||||
html += `<div class="hw-reg-item">
|
||||
<span class="hw-reg-name">${escapeHtml(name)} <small>${escapeHtml(no)}</small></span>
|
||||
<span class="hw-reg-miss-label" style="margin-left:auto;">缺交</span>
|
||||
<input type="number" class="hw-reg-miss" data-id="${cb.dataset.id}" min="1" value="1" style="width:64px;">
|
||||
<span class="hw-reg-miss-label">次</span>
|
||||
</div>`;
|
||||
});
|
||||
document.getElementById('hwRegStudentList').innerHTML = html;
|
||||
|
||||
const deadlineInput = document.getElementById('hwRegDeadline');
|
||||
if (!deadlineInput.value) {
|
||||
const now = new Date();
|
||||
deadlineInput.value = now.getFullYear() + '-' +
|
||||
String(now.getMonth() + 1).padStart(2, '0') + '-' +
|
||||
String(now.getDate()).padStart(2, '0');
|
||||
}
|
||||
|
||||
document.getElementById('homeworkRegisterModal').style.display = 'flex';
|
||||
}
|
||||
|
||||
async function submitHomeworkRegister() {
|
||||
const subjectId = parseInt(document.getElementById('hwRegSubject').value);
|
||||
const title = document.getElementById('hwRegTitle').value.trim();
|
||||
const deadline = document.getElementById('hwRegDeadline').value;
|
||||
const totalTimes = parseInt(document.getElementById('hwRegTotal').value);
|
||||
const perDeductionRaw = document.getElementById('hwRegPerDeduction').value;
|
||||
const note = document.getElementById('hwRegNote').value.trim();
|
||||
|
||||
if (!subjectId) { showToast('请选择科目', 'warning'); return; }
|
||||
if (!deadline) { showToast('请选择缴交/截止日期', 'warning'); return; }
|
||||
if (!totalTimes || totalTimes < 1 || totalTimes > 99) {
|
||||
showToast('总提交次数需在1-99之间', 'warning');
|
||||
return;
|
||||
}
|
||||
|
||||
const inputs = Array.from(document.querySelectorAll('.hw-reg-miss'));
|
||||
if (inputs.length === 0) {
|
||||
showToast('请先在学生列表中勾选缺交学生', 'warning');
|
||||
return;
|
||||
}
|
||||
|
||||
const records = [];
|
||||
for (const input of inputs) {
|
||||
const miss = parseInt(input.value);
|
||||
if (!miss || miss < 1 || miss > totalTimes) {
|
||||
showToast('缺交次数需在1~总提交次数之间', 'warning');
|
||||
return;
|
||||
}
|
||||
records.push({ student_id: parseInt(input.dataset.id), miss_count: miss });
|
||||
}
|
||||
|
||||
const payload = {
|
||||
subject_id: subjectId,
|
||||
deadline: deadline,
|
||||
total_times: totalTimes,
|
||||
records: records
|
||||
};
|
||||
if (title) payload.title = title;
|
||||
if (perDeductionRaw) payload.per_deduction = parseInt(perDeductionRaw);
|
||||
if (note) payload.note = note;
|
||||
|
||||
const btn = document.getElementById('hwRegisterSubmitBtn');
|
||||
btn.disabled = true;
|
||||
btn.textContent = '提交中...';
|
||||
try {
|
||||
const res = await apiPost('/api/admin/homework/register', payload);
|
||||
if (res && res.success) {
|
||||
showToast(res.message || '登记完成');
|
||||
closeModal('homeworkRegisterModal');
|
||||
document.querySelectorAll('.student-checkbox').forEach(cb => cb.checked = false);
|
||||
const selectAll = document.getElementById('selectAll');
|
||||
if (selectAll) selectAll.checked = false;
|
||||
loadStudents();
|
||||
} else {
|
||||
showToast((res && res.message) || '登记失败', 'error');
|
||||
}
|
||||
} finally {
|
||||
btn.disabled = false;
|
||||
btn.textContent = '确认登记';
|
||||
}
|
||||
}
|
||||
|
||||
// 绑定科目管理折叠面板
|
||||
var subjectHeader = document.getElementById('subjectPanelHeader');
|
||||
if (subjectHeader) {
|
||||
@@ -278,5 +390,7 @@ window.deleteSubject = deleteSubject;
|
||||
window.showEditSubjectModal = showEditSubjectModal;
|
||||
window.submitEditSubject = submitEditSubject;
|
||||
window.moveSubject = moveSubject;
|
||||
window.showHomeworkRegisterModal = showHomeworkRegisterModal;
|
||||
window.submitHomeworkRegister = submitHomeworkRegister;
|
||||
|
||||
})();
|
||||
Reference in new issue
Block a user