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
@@ -47,6 +47,12 @@ include __DIR__ . '/../includes/header.php';
|
||||
<button class="status-btn" data-status="late" onclick="selectStatus(this)" id="btnLate">迟到</button>
|
||||
<button class="status-btn" data-status="leave" onclick="selectStatus(this)" id="btnLeave">请假</button>
|
||||
</div>
|
||||
<?php if (has_perm('default_attendance')): ?>
|
||||
<button class="btn btn-success" onclick="openDefaultAttendanceModal()">默认出勤</button>
|
||||
<?php endif; ?>
|
||||
<?php if (has_perm('manage_calendar')): ?>
|
||||
<button class="btn btn-ghost" onclick="openCalendarModal()">节假日/补课</button>
|
||||
<?php endif; ?>
|
||||
<button class="btn btn-danger" onclick="submitAttendance()">提交考勤</button>
|
||||
</div>
|
||||
<div class="attendance-toolbar">
|
||||
@@ -90,6 +96,74 @@ include __DIR__ . '/../includes/header.php';
|
||||
.student-cell-name { font-size: 14px; font-weight: 500; }
|
||||
.student-cell-no { font-size: 11px; color: #999; }
|
||||
</style>
|
||||
|
||||
<!-- 默认出勤模态框 -->
|
||||
<div id="defaultAttendanceModal" class="modal">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h3>默认出勤(批量补全)</h3>
|
||||
<button class="modal-close" onclick="closeModal('defaultAttendanceModal')">×</button>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>日期范围</label>
|
||||
<div style="display:flex; align-items:center; gap:8px; flex-wrap:wrap;">
|
||||
<input type="date" id="defaultStartDate" style="width:auto;">
|
||||
<span style="color:#999;">至</span>
|
||||
<input type="date" id="defaultEndDate" style="width:auto;">
|
||||
</div>
|
||||
<small>跳过周末与法定节假日(在线接口获取),调休补班与手动补课日照常;已有的考勤记录(含异常)不会被覆盖</small>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>时段</label>
|
||||
<div class="check-grid" style="grid-template-columns: repeat(3, 1fr);">
|
||||
<label class="check-item"><input type="checkbox" class="defaultSlot" value="morning" checked> 早上 7:15</label>
|
||||
<label class="check-item"><input type="checkbox" class="defaultSlot" value="afternoon" checked> 中午 14:00</label>
|
||||
<label class="check-item"><input type="checkbox" class="defaultSlot" value="evening" checked> 晚修 19:30</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary" id="defaultAttendanceBtn" onclick="submitDefaultAttendance()">开始补全</button>
|
||||
<button type="button" class="btn" onclick="closeModal('defaultAttendanceModal')">取消</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 节假日/补课模态框 -->
|
||||
<div id="calendarModal" class="modal">
|
||||
<div class="modal-content" style="width: 640px;">
|
||||
<div class="modal-header">
|
||||
<h3>节假日 / 补课设置</h3>
|
||||
<button class="modal-close" onclick="closeModal('calendarModal')">×</button>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>查询范围</label>
|
||||
<div style="display:flex; align-items:center; gap:8px; flex-wrap:wrap;">
|
||||
<input type="date" id="calendarStartDate" style="width:auto;">
|
||||
<span style="color:#999;">至</span>
|
||||
<input type="date" id="calendarEndDate" style="width:auto;">
|
||||
<button type="button" class="btn btn-sm btn-secondary" onclick="loadCalendar()">查询</button>
|
||||
</div>
|
||||
<small>法定节假日与调休补班来自在线接口(只读);手动添加用于学校自己的安排,优先于接口</small>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>手动添加</label>
|
||||
<div style="display:flex; align-items:center; gap:8px; flex-wrap:wrap;">
|
||||
<input type="date" id="calendarNewDate" style="width:auto;">
|
||||
<select id="calendarNewType" style="width:auto;">
|
||||
<option value="makeup">补课(按上课)</option>
|
||||
<option value="holiday">放假(按休息)</option>
|
||||
</select>
|
||||
<input type="text" id="calendarNewNote" placeholder="备注(选填)" maxlength="100" style="flex:1; min-width:120px;">
|
||||
<button type="button" class="btn btn-sm btn-primary" onclick="addCalendarDay()">添加</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="calendarListArea" style="max-height:320px; overflow-y:auto; border:1px solid var(--color-border-light); border-radius:8px;"></div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn" onclick="closeModal('calendarModal')">关闭</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="/assets/js/modules/modal-utils.js"></script>
|
||||
<script src="/assets/js/attendance-manage.js"></script>
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ if (!isset($_SESSION['user_id']) || $_SESSION['user_type'] !== 'admin') {
|
||||
|
||||
$page_title = '操行分管理';
|
||||
$role = current_group_name();
|
||||
require_perm('manage_conduct');
|
||||
|
||||
include __DIR__ . '/../includes/header.php';
|
||||
?>
|
||||
|
||||
@@ -46,7 +46,9 @@ include __DIR__ . '/../includes/header.php';
|
||||
<span class="ranking-tip">% 的学生</span>
|
||||
<button class="btn btn-sm btn-primary" onclick="applyPercentileFilter()">筛选</button>
|
||||
<button class="btn btn-sm btn-ghost" onclick="resetPercentileFilter()">显示全部</button>
|
||||
<?php if (has_perm('export_data')): ?>
|
||||
<button class="btn btn-sm btn-secondary" onclick="exportRanking()">导出</button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<table class="table">
|
||||
<thead>
|
||||
|
||||
@@ -47,6 +47,9 @@ include __DIR__ . '/../includes/header.php';
|
||||
<div class="action-bar">
|
||||
<div class="action-buttons">
|
||||
<button class="btn btn-primary" onclick="showBatchPointsModal()">批量加减分</button>
|
||||
<?php if (has_perm('homework_register')): ?>
|
||||
<button class="btn btn-success" onclick="showHomeworkRegisterModal()">按次登记</button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="table-wrapper">
|
||||
@@ -119,6 +122,57 @@ include __DIR__ . '/../includes/header.php';
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 作业按次登记模态框 -->
|
||||
<div id="homeworkRegisterModal" class="modal">
|
||||
<div class="modal-content" style="width: 560px;">
|
||||
<div class="modal-header">
|
||||
<h3>作业按次登记</h3>
|
||||
<button class="modal-close" onclick="closeModal('homeworkRegisterModal')">×</button>
|
||||
</div>
|
||||
<form onsubmit="event.preventDefault(); submitHomeworkRegister()">
|
||||
<div class="form-group">
|
||||
<label>科目 <span class="text-danger">*</span></label>
|
||||
<select id="hwRegSubject" required>
|
||||
<option value="">请选择科目</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>作业名称</label>
|
||||
<input type="text" id="hwRegTitle" maxlength="100" placeholder="选填,如:第5周数学作业">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>缴交/截止日期</label>
|
||||
<input type="date" id="hwRegDeadline">
|
||||
<small>作业统计按该日期归属</small>
|
||||
</div>
|
||||
<div class="form-group" style="display:flex; gap:12px;">
|
||||
<div style="flex:1;">
|
||||
<label>总提交次数</label>
|
||||
<input type="number" id="hwRegTotal" min="1" max="99" value="5" required>
|
||||
</div>
|
||||
<div style="flex:1;">
|
||||
<label>单次缺交扣分</label>
|
||||
<input type="number" id="hwRegPerDeduction" min="1" max="20">
|
||||
<small>默认取系统配置</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>缺交学生与次数</label>
|
||||
<div id="hwRegStudentList" class="hw-reg-list"></div>
|
||||
<small>缺交次数不超过总提交次数,其他学生自动记为已交</small>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>备注</label>
|
||||
<input type="text" id="hwRegNote" maxlength="100" placeholder="选填">
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="submit" class="btn btn-primary" id="hwRegisterSubmitBtn">确认登记</button>
|
||||
<button type="button" class="btn" onclick="closeModal('homeworkRegisterModal')">取消</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 添加科目模态框 -->
|
||||
<div id="addSubjectModal" class="modal">
|
||||
<div class="modal-content">
|
||||
|
||||
@@ -19,7 +19,7 @@ if (!isset($_SESSION['user_id']) || $_SESSION['user_type'] !== 'admin') {
|
||||
|
||||
$page_title = '操作日志';
|
||||
$role = current_group_name();
|
||||
require_perm('manage_admins');
|
||||
require_perm('view_logs');
|
||||
|
||||
include __DIR__ . '/../includes/header.php';
|
||||
?>
|
||||
|
||||
@@ -19,7 +19,7 @@ if (!isset($_SESSION['user_id']) || $_SESSION['user_type'] !== 'admin') {
|
||||
|
||||
$page_title = '数据报表';
|
||||
$role = current_group_name();
|
||||
require_perm('view_all_records');
|
||||
require_perm('view_reports');
|
||||
|
||||
include __DIR__ . '/../includes/header.php';
|
||||
?>
|
||||
|
||||
@@ -19,7 +19,7 @@ if (!isset($_SESSION['user_id']) || $_SESSION['user_type'] !== 'admin') {
|
||||
|
||||
$page_title = '系统设置';
|
||||
$role = current_group_name();
|
||||
require_perm('manage_admins');
|
||||
require_perm('manage_settings');
|
||||
|
||||
include __DIR__ . '/../includes/header.php';
|
||||
?>
|
||||
|
||||
@@ -368,3 +368,68 @@
|
||||
padding: 8px 12px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
/* 校历(节假日/补课)列表 */
|
||||
.calendar-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 8px 12px;
|
||||
border-bottom: 1px solid var(--color-border-light);
|
||||
font-size: 13px;
|
||||
}
|
||||
.calendar-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
.calendar-date {
|
||||
font-weight: 600;
|
||||
min-width: 92px;
|
||||
}
|
||||
.calendar-name {
|
||||
color: var(--color-text-secondary);
|
||||
}
|
||||
.calendar-source {
|
||||
color: #bbb;
|
||||
font-size: 12px;
|
||||
}
|
||||
.calendar-tag {
|
||||
padding: 1px 8px;
|
||||
border-radius: 10px;
|
||||
font-size: 12px;
|
||||
}
|
||||
.calendar-tag-holiday {
|
||||
background: var(--color-danger-light);
|
||||
color: var(--color-danger-dark);
|
||||
}
|
||||
.calendar-tag-makeup {
|
||||
background: var(--color-primary-light);
|
||||
color: var(--color-primary);
|
||||
}
|
||||
|
||||
/* 作业按次登记-缺交学生列表 */
|
||||
.hw-reg-list {
|
||||
max-height: 220px;
|
||||
overflow-y: auto;
|
||||
border: 1px solid var(--color-border-light);
|
||||
border-radius: 8px;
|
||||
padding: 6px 10px;
|
||||
background: var(--color-hover);
|
||||
}
|
||||
.hw-reg-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 6px 0;
|
||||
border-bottom: 1px solid var(--color-border-light);
|
||||
font-size: 13px;
|
||||
}
|
||||
.hw-reg-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
.hw-reg-name small {
|
||||
color: var(--color-text-muted);
|
||||
margin-left: 4px;
|
||||
}
|
||||
.hw-reg-miss-label {
|
||||
color: var(--color-text-secondary);
|
||||
}
|
||||
@@ -18,20 +18,27 @@ const PERMISSION_LABELS = {
|
||||
revoke_own: '撤销自己的记录',
|
||||
restore_records: '反撤销记录',
|
||||
manage_homework: '作业扣分',
|
||||
homework_register: '作业按次登记',
|
||||
manage_attendance: '考勤管理',
|
||||
default_attendance: '考勤默认出勤',
|
||||
manage_calendar: '节假日/补课设置',
|
||||
manage_subjects: '科目管理',
|
||||
manage_admins: '管理员/权限组管理',
|
||||
manage_semesters: '学期管理',
|
||||
view_all_records: '查看全班/个人查询',
|
||||
view_reports: '数据报表查看',
|
||||
export_data: '导出德育分/历史',
|
||||
view_logs: '操作日志查看',
|
||||
manage_settings: '系统设置',
|
||||
manage_upgrade: '系统升级'
|
||||
};
|
||||
|
||||
const PERMISSION_SECTIONS = [
|
||||
{ title: '学生', keys: ['manage_students', 'export_students'] },
|
||||
{ title: '操行分', keys: ['manage_conduct', 'revoke_any', 'revoke_own', 'restore_records', 'view_all_records', 'export_data'] },
|
||||
{ title: '教务', keys: ['manage_homework', 'manage_attendance', 'manage_subjects'] },
|
||||
{ title: '系统管理', keys: ['manage_admins', 'manage_semesters', 'manage_upgrade'] }
|
||||
{ title: '教务', keys: ['manage_homework', 'homework_register', 'manage_attendance', 'default_attendance', 'manage_calendar', 'manage_subjects'] },
|
||||
{ title: '报表与审计', keys: ['view_reports', 'view_logs'] },
|
||||
{ title: '系统管理', keys: ['manage_admins', 'manage_semesters', 'manage_settings', 'manage_upgrade'] }
|
||||
];
|
||||
|
||||
let currentEditUserId = null;
|
||||
|
||||
@@ -190,6 +190,189 @@ document.getElementById('attendanceSlot').addEventListener('change', function()
|
||||
loadExistingRecords();
|
||||
});
|
||||
|
||||
// ========== 日期工具 ==========
|
||||
|
||||
function formatDateValue(d) {
|
||||
const y = d.getFullYear();
|
||||
const m = String(d.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(d.getDate()).padStart(2, '0');
|
||||
return y + '-' + m + '-' + day;
|
||||
}
|
||||
|
||||
// ========== 默认出勤(批量补全) ==========
|
||||
|
||||
function openDefaultAttendanceModal() {
|
||||
const startInput = document.getElementById('defaultStartDate');
|
||||
const endInput = document.getElementById('defaultEndDate');
|
||||
if (!startInput.value) {
|
||||
const today = new Date();
|
||||
startInput.value = formatDateValue(new Date(today.getFullYear(), today.getMonth(), 1));
|
||||
endInput.value = formatDateValue(today);
|
||||
}
|
||||
document.getElementById('defaultAttendanceModal').style.display = 'flex';
|
||||
}
|
||||
|
||||
async function submitDefaultAttendance() {
|
||||
const startDate = document.getElementById('defaultStartDate').value;
|
||||
const endDate = document.getElementById('defaultEndDate').value;
|
||||
const slots = Array.from(document.querySelectorAll('.defaultSlot:checked')).map(el => el.value);
|
||||
|
||||
if (!startDate || !endDate) {
|
||||
showToast('请选择日期范围', 'warning');
|
||||
return;
|
||||
}
|
||||
if (startDate > endDate) {
|
||||
showToast('开始日期不能晚于结束日期', 'warning');
|
||||
return;
|
||||
}
|
||||
if (slots.length === 0) {
|
||||
showToast('请至少选择一个时段', 'warning');
|
||||
return;
|
||||
}
|
||||
|
||||
const btn = document.getElementById('defaultAttendanceBtn');
|
||||
btn.disabled = true;
|
||||
btn.textContent = '补全中...';
|
||||
|
||||
try {
|
||||
const res = await apiPost('/api/admin/attendance/default', {
|
||||
start_date: startDate,
|
||||
end_date: endDate,
|
||||
slots: slots
|
||||
});
|
||||
if (res && res.success) {
|
||||
showToast(res.message || '默认出勤完成');
|
||||
if (res.data && res.data.api_ok === false) {
|
||||
setTimeout(function() {
|
||||
showToast('节假日接口暂时不可用,本次仅按周末与手动设置判断', 'warning');
|
||||
}, 500);
|
||||
}
|
||||
closeModal('defaultAttendanceModal');
|
||||
await loadExistingRecords();
|
||||
loadAttendanceRecords();
|
||||
} else {
|
||||
showToast((res && res.message) || '默认出勤失败', 'error');
|
||||
}
|
||||
} finally {
|
||||
btn.disabled = false;
|
||||
btn.textContent = '开始补全';
|
||||
}
|
||||
}
|
||||
|
||||
// ========== 校历(节假日/补课) ==========
|
||||
|
||||
function openCalendarModal() {
|
||||
const startInput = document.getElementById('calendarStartDate');
|
||||
const endInput = document.getElementById('calendarEndDate');
|
||||
if (!startInput.value) {
|
||||
const year = new Date().getFullYear();
|
||||
startInput.value = year + '-01-01';
|
||||
endInput.value = year + '-12-31';
|
||||
}
|
||||
document.getElementById('calendarModal').style.display = 'flex';
|
||||
loadCalendar();
|
||||
}
|
||||
|
||||
async function loadCalendar() {
|
||||
const startDate = document.getElementById('calendarStartDate').value;
|
||||
const endDate = document.getElementById('calendarEndDate').value;
|
||||
const area = document.getElementById('calendarListArea');
|
||||
|
||||
if (!startDate || !endDate || startDate > endDate) {
|
||||
area.innerHTML = '<div style="padding:16px;text-align:center;color:#999;font-size:13px;">请选择正确的日期范围</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
area.innerHTML = '<div style="padding:16px;text-align:center;color:#999;font-size:13px;">加载中...</div>';
|
||||
const res = await apiGet('/api/admin/attendance/calendar', { start_date: startDate, end_date: endDate });
|
||||
if (!res || !res.success) {
|
||||
area.innerHTML = '<div style="padding:16px;text-align:center;color:#c33;font-size:13px;">' +
|
||||
escapeHtml((res && res.message) || '加载失败') + '</div>';
|
||||
return;
|
||||
}
|
||||
renderCalendar(res.data);
|
||||
}
|
||||
|
||||
function renderCalendar(data) {
|
||||
const holidays = (data && data.holidays) || {};
|
||||
const workdays = (data && data.workdays) || {};
|
||||
const manual = (data && data.manual) || {};
|
||||
const items = [];
|
||||
|
||||
Object.keys(holidays).forEach(function(d) {
|
||||
items.push({ date: d, type: 'holiday', label: '放假', name: holidays[d], manual: false });
|
||||
});
|
||||
Object.keys(workdays).forEach(function(d) {
|
||||
items.push({ date: d, type: 'makeup', label: '调休', name: workdays[d], manual: false });
|
||||
});
|
||||
Object.keys(manual).forEach(function(d) {
|
||||
items.push({
|
||||
date: d,
|
||||
type: manual[d].type,
|
||||
label: manual[d].type === 'holiday' ? '放假' : '补课',
|
||||
name: manual[d].note || '',
|
||||
manual: true
|
||||
});
|
||||
});
|
||||
|
||||
items.sort(function(a, b) { return a.date < b.date ? -1 : (a.date > b.date ? 1 : 0); });
|
||||
|
||||
const area = document.getElementById('calendarListArea');
|
||||
let html = '';
|
||||
if (data && data.api_ok === false) {
|
||||
html += '<div style="padding:6px 12px;color:#ad6800;font-size:12px;border-bottom:1px solid var(--color-border-light);">节假日接口暂时不可用,仅显示手动设置</div>';
|
||||
}
|
||||
if (items.length === 0) {
|
||||
html += '<div style="padding:16px;text-align:center;color:#999;font-size:13px;">范围内没有节假日/补课记录</div>';
|
||||
}
|
||||
items.forEach(function(item) {
|
||||
const tagClass = item.type === 'holiday' ? 'calendar-tag-holiday' : 'calendar-tag-makeup';
|
||||
html += '<div class="calendar-item">' +
|
||||
'<span class="calendar-date">' + escapeHtml(item.date) + '</span>' +
|
||||
'<span class="calendar-tag ' + tagClass + '">' + item.label + '</span>' +
|
||||
'<span class="calendar-name">' + escapeHtml(item.name) + '</span>' +
|
||||
(item.manual
|
||||
? '<span class="calendar-source">手动</span>' +
|
||||
'<button class="btn btn-sm btn-ghost" style="margin-left:auto;" onclick="deleteCalendarDay(\'' + item.date + '\')">删除</button>'
|
||||
: '<span class="calendar-source" style="margin-left:auto;">接口</span>') +
|
||||
'</div>';
|
||||
});
|
||||
area.innerHTML = html;
|
||||
}
|
||||
|
||||
async function addCalendarDay() {
|
||||
const day = document.getElementById('calendarNewDate').value;
|
||||
const dayType = document.getElementById('calendarNewType').value;
|
||||
const note = document.getElementById('calendarNewNote').value.trim();
|
||||
|
||||
if (!day) {
|
||||
showToast('请选择日期', 'warning');
|
||||
return;
|
||||
}
|
||||
const res = await apiPost('/api/admin/attendance/calendar', {
|
||||
date: day,
|
||||
day_type: dayType,
|
||||
note: note
|
||||
});
|
||||
if (res && res.success) {
|
||||
showToast('已保存');
|
||||
document.getElementById('calendarNewNote').value = '';
|
||||
loadCalendar();
|
||||
} else {
|
||||
showToast((res && res.message) || '保存失败', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteCalendarDay(day) {
|
||||
const res = await apiDelete('/api/admin/attendance/calendar?date=' + encodeURIComponent(day));
|
||||
if (res && res.success) {
|
||||
showToast('已删除');
|
||||
loadCalendar();
|
||||
} else {
|
||||
showToast((res && res.message) || '删除失败', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
// 页面初始化
|
||||
initAttendanceButtons();
|
||||
loadStudents();
|
||||
@@ -202,5 +385,11 @@ window.selectAllStudents = selectAllStudents;
|
||||
window.deselectAllStudents = deselectAllStudents;
|
||||
window.submitAttendance = submitAttendance;
|
||||
window.loadAttendanceRecords = loadAttendanceRecords;
|
||||
window.openDefaultAttendanceModal = openDefaultAttendanceModal;
|
||||
window.submitDefaultAttendance = submitDefaultAttendance;
|
||||
window.openCalendarModal = openCalendarModal;
|
||||
window.loadCalendar = loadCalendar;
|
||||
window.addCalendarDay = addCalendarDay;
|
||||
window.deleteCalendarDay = deleteCalendarDay;
|
||||
|
||||
})();
|
||||
@@ -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;
|
||||
|
||||
})();
|
||||
@@ -20,6 +20,10 @@ const OPERATION_TYPES = {
|
||||
revoke_record: '撤销记录',
|
||||
restore_record: '反撤销记录',
|
||||
add_attendance: '添加考勤',
|
||||
default_attendance: '默认出勤',
|
||||
add_calendar_day: '添加校历设置',
|
||||
remove_calendar_day: '删除校历设置',
|
||||
homework_register: '作业按次登记',
|
||||
add_admin: '添加管理员',
|
||||
reactivate_admin: '重新激活管理员',
|
||||
update_admin: '编辑管理员',
|
||||
@@ -43,6 +47,7 @@ const TARGET_TYPES = {
|
||||
admin: '管理员',
|
||||
conduct: '操行分',
|
||||
attendance: '考勤',
|
||||
homework: '作业',
|
||||
semester: '学期',
|
||||
subject: '科目',
|
||||
permission_group: '权限组',
|
||||
|
||||
@@ -1,24 +1,28 @@
|
||||
<div class="nav">
|
||||
<a href="/admin/dashboard.php" class="nav-item<?php echo $current_page === 'dashboard' ? ' active' : ''; ?>">首页</a>
|
||||
<a href="/admin/students.php" class="nav-item<?php echo $current_page === 'students' ? ' active' : ''; ?>">学生管理</a>
|
||||
<?php if (has_perm('manage_conduct')): ?>
|
||||
<a href="/admin/conduct.php" class="nav-item<?php echo $current_page === 'conduct' ? ' active' : ''; ?>">操行分管理</a>
|
||||
<?php endif; ?>
|
||||
<?php if (has_perm('manage_homework')): ?>
|
||||
<a href="/admin/homework.php" class="nav-item<?php echo $current_page === 'homework' ? ' active' : ''; ?>">作业扣分</a>
|
||||
<?php endif; ?>
|
||||
<?php if (has_perm('manage_attendance')): ?>
|
||||
<a href="/admin/attendance.php" class="nav-item<?php echo $current_page === 'attendance' ? ' active' : ''; ?>">考勤管理</a>
|
||||
<?php endif; ?>
|
||||
<?php if (has_perm('view_all_records')): ?>
|
||||
<?php if (has_perm('view_reports')): ?>
|
||||
<a href="/admin/reports.php" class="nav-item<?php echo $current_page === 'reports' ? ' active' : ''; ?>">数据报表</a>
|
||||
<?php endif; ?>
|
||||
<?php if (has_perm('manage_admins')): ?>
|
||||
<a href="/admin/admins.php" class="nav-item<?php echo $current_page === 'admins' ? ' active' : ''; ?>">管理员管理</a>
|
||||
<?php endif; ?>
|
||||
<?php if (has_perm('view_logs')): ?>
|
||||
<a href="/admin/logs.php" class="nav-item<?php echo $current_page === 'logs' ? ' active' : ''; ?>">操作日志</a>
|
||||
<?php endif; ?>
|
||||
<?php if (has_perm('manage_semesters')): ?>
|
||||
<a href="/admin/semesters.php" class="nav-item<?php echo $current_page === 'semesters' ? ' active' : ''; ?>">学期管理</a>
|
||||
<?php endif; ?>
|
||||
<?php if (has_perm('manage_admins')): ?>
|
||||
<?php if (has_perm('manage_settings')): ?>
|
||||
<a href="/admin/settings.php" class="nav-item<?php echo $current_page === 'settings' ? ' active' : ''; ?>">系统设置</a>
|
||||
<?php endif; ?>
|
||||
<a href="/admin/history.php" class="nav-item<?php echo $current_page === 'history' ? ' active' : ''; ?>">历史记录</a>
|
||||
|
||||
Reference in new issue
Block a user