Files
ClassManager/frontend/assets/js/modules/points-mgmt.js
T
canglan d0cdb5b928 历史记录/操作日志与作业按次登记改进
1. 历史记录:批次合并视图新增"批量反撤销"(需反撤销权限);单条/批量撤销与反撤销提示更明确(说明记录去向,不会删除);操作列权限门控补充 restore_records
2. 操作日志:批量撤销/反撤销写入日志;单条撤销/反撤销/加减分日志详情补充学生姓名(学号)、分值变动、原因;新增"详情关键词"筛选(学生姓名/原因等)
3. 节假日接口:证书校验失败自动回退重试,提高服务器兼容性
4. 作业按次登记:默认列出全部学生、缺交次数默认0(0=已交),支持全员已交登记;后端允许空缺交名单
2026-10-15 20:04:41 +08:00

125 lines
4.5 KiB
JavaScript

/**
* 班级操行分管理系统 - 加减分管理函数
*
* 开发者: Canglan
* 联系方式: admin@sea-studio.top
* 版权归属: Sea Network Technology Studio
* 许可证: MIT License
*
* 版权所有 © Sea Network Technology Studio
*/
(function() {
'use strict';
// 全局变量
var selectedStudentIds = [];
var currentHistoryPage = 1;
// 显示批量加减分模态框
function showBatchPointsModal() {
selectedStudentIds = [];
document.querySelectorAll('.student-checkbox:checked').forEach(cb => {
selectedStudentIds.push(parseInt(cb.dataset.id));
});
if (selectedStudentIds.length === 0) {
showToast('请先选择学生', 'warning');
return;
}
document.getElementById('selectedStudentsCount').innerHTML = `${selectedStudentIds.length} 人`;
document.getElementById('pointsChange').value = '';
document.getElementById('pointsReason').value = '';
preparePointsLimitHint();
document.getElementById('batchPointsModal').style.display = 'flex';
}
// 应用动态加减分上限提示与输入限制
function preparePointsLimitHint() {
var inputEl = document.getElementById('pointsChange');
applyScoreLimits(inputEl);
var hintEl = document.getElementById('pointsLimitHint');
if (hintEl) hintEl.textContent = describeScoreLimits();
}
// 显示单人加减分模态框(各页面共用)
function showSinglePointsModal(studentId, studentName) {
selectedStudentIds = [studentId];
document.getElementById('selectedStudentsCount').innerHTML = `${studentName} (1人)`;
document.getElementById('pointsChange').value = '';
document.getElementById('pointsReason').value = '';
preparePointsLimitHint();
document.getElementById('batchPointsModal').style.display = 'flex';
}
// 提交批量加减分
async function submitBatchPoints(options = {}) {
const pointsChange = parseInt(document.getElementById('pointsChange').value);
const reason = document.getElementById('pointsReason').value;
const limitError = validateScoreChange(pointsChange);
if (limitError) {
showToast(limitError, 'error');
return;
}
if (!reason.trim()) {
showToast('请填写原因', 'error');
return;
}
const data = {
student_ids: selectedStudentIds,
points_change: pointsChange,
reason: reason
};
if (options.related_type) {
data.related_type = options.related_type;
}
const res = await apiPost('/api/admin/conduct/add', data);
if (res && res.success) {
showToast(`操作成功: ${res.data.success_count} 人成功`);
closeModal('batchPointsModal');
loadStudents();
if (typeof loadConductStudents === 'function') loadConductStudents();
} else {
showToast(res?.message || '操作失败', 'error');
}
}
// 撤销扣分记录
async function revokeRecord(recordId) {
if (!confirm('确定要撤销这条记录吗?撤销后学生分数将恢复。')) return;
const res = await apiPost('/api/admin/conduct/revoke', { record_id: recordId });
if (res && res.success) {
showToast('撤销成功,该记录已移入“已撤销”(可筛选查看/反撤销)');
loadHistory(currentHistoryPage);
} else {
showToast(res?.message || '撤销失败', 'error');
}
}
// 反撤销(恢复)记录
async function restoreRecord(recordId) {
if (!confirm('确定要反撤销这条记录吗?分数变动将重新生效。')) return;
const res = await apiPost('/api/admin/conduct/restore', { record_id: recordId });
if (res && res.success) {
showToast('反撤销成功,该记录已恢复正常');
loadHistory(currentHistoryPage);
} else {
showToast(res?.message || '反撤销失败', 'error');
}
}
window.showBatchPointsModal = showBatchPointsModal;
window.showSinglePointsModal = showSinglePointsModal;
window.submitBatchPoints = submitBatchPoints;
window.preparePointsLimitHint = preparePointsLimitHint;
window.revokeRecord = revokeRecord;
window.restoreRecord = restoreRecord;
})();