v4.4 数据报表/操作日志/系统设置与月度分排行
1. 月度分排行:管理端首页支持总分/月度分切换与月份选择,新增排行榜导出CSV 2. 数据报表:新增考勤/作业统计页(日期范围、汇总与每人明细、CSV导出) 3. 操作日志:新增查看页(操作类型/操作人/日期筛选,分页) 4. 系统设置:密码策略可配置(长度/字符种类),全站改密与重置统一校验、前端提示同步;策略通过公开配置下发 5. 学期归档对比:查看归档时展示与上一学期的分数变化与名次升降 6. 历史记录导出支持按学生分表(每人一段,便于发家长) 7. 移动端适配:导航横向滚动、表格触控滚动、字号与弹窗优化 8. 版本升级至4.4(无数据库结构变更)
This commit is contained in:
1 parent
9a19add6c1
commit
768ea281e0
54 files changed
+1782
-90
No files matched your search
@@ -0,0 +1,155 @@
|
||||
/**
|
||||
* 班级操行分管理系统 - 数据报表页JS
|
||||
*
|
||||
* 开发者: Canglan
|
||||
* 版权归属: Sea Network Technology Studio
|
||||
*
|
||||
* 版权所有 © Sea Network Technology Studio
|
||||
*/
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
let attendanceCache = null;
|
||||
let homeworkCache = null;
|
||||
|
||||
function formatDateValue(date) {
|
||||
return date.getFullYear() + '-' + String(date.getMonth() + 1).padStart(2, '0') + '-' + String(date.getDate()).padStart(2, '0');
|
||||
}
|
||||
|
||||
async function initReportDates() {
|
||||
const startInput = document.getElementById('reportStartDate');
|
||||
const endInput = document.getElementById('reportEndDate');
|
||||
const today = new Date();
|
||||
let start = new Date(today.getFullYear(), today.getMonth(), 1);
|
||||
|
||||
try {
|
||||
const res = await apiGet('/api/semester/active');
|
||||
if (res && res.success && res.data && res.data.start_date) {
|
||||
start = new Date(res.data.start_date);
|
||||
}
|
||||
} catch (e) { /* 使用默认月初 */ }
|
||||
|
||||
startInput.value = formatDateValue(start);
|
||||
endInput.value = formatDateValue(today);
|
||||
}
|
||||
|
||||
async function loadReports() {
|
||||
const startDate = document.getElementById('reportStartDate').value;
|
||||
const endDate = document.getElementById('reportEndDate').value;
|
||||
if (!startDate || !endDate) {
|
||||
showToast('请选择开始和结束日期', 'warning');
|
||||
return;
|
||||
}
|
||||
if (startDate > endDate) {
|
||||
showToast('开始日期不能晚于结束日期', 'warning');
|
||||
return;
|
||||
}
|
||||
|
||||
document.getElementById('reportRangeHint').textContent = `统计范围:${startDate} ~ ${endDate}`;
|
||||
|
||||
const [attendanceRes, homeworkRes] = await Promise.all([
|
||||
apiGet('/api/report/attendance', { start_date: startDate, end_date: endDate }),
|
||||
apiGet('/api/report/homework', { start_date: startDate, end_date: endDate })
|
||||
]);
|
||||
|
||||
if (attendanceRes && attendanceRes.success) {
|
||||
attendanceCache = attendanceRes.data;
|
||||
renderAttendance(attendanceRes.data);
|
||||
} else {
|
||||
showToast((attendanceRes && attendanceRes.message) || '考勤报表加载失败', 'error');
|
||||
}
|
||||
if (homeworkRes && homeworkRes.success) {
|
||||
homeworkCache = homeworkRes.data;
|
||||
renderHomework(homeworkRes.data);
|
||||
} else {
|
||||
showToast((homeworkRes && homeworkRes.message) || '作业报表加载失败', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
function rateText(rate) {
|
||||
return (rate === null || rate === undefined) ? '-' : rate + '%';
|
||||
}
|
||||
|
||||
function renderAttendance(data) {
|
||||
const rows = data.rows || [];
|
||||
const summary = data.summary || {};
|
||||
document.getElementById('attendanceSummary').textContent =
|
||||
`共 ${rows.length} 人,${summary.total || 0} 条记录:出勤 ${summary.present || 0}、缺勤 ${summary.absent || 0}、迟到 ${summary.late || 0}、请假 ${summary.leave || 0},出勤率 ${rateText(summary.rate)}`;
|
||||
|
||||
let html = '';
|
||||
rows.forEach((row, index) => {
|
||||
html += `<tr>
|
||||
<td>${index + 1}</td>
|
||||
<td>${escapeHtml(row.student_no)}</td>
|
||||
<td>${escapeHtml(row.name)}</td>
|
||||
<td class="plus">${row.present}</td>
|
||||
<td class="minus">${row.absent}</td>
|
||||
<td>${row.late}</td>
|
||||
<td>${row.leave}</td>
|
||||
<td>${row.total}</td>
|
||||
<td>${rateText(row.rate)}</td>
|
||||
</tr>`;
|
||||
});
|
||||
if (rows.length === 0) {
|
||||
html = '<tr><td colspan="9" style="text-align:center;">暂无数据</td></tr>';
|
||||
}
|
||||
document.getElementById('attendanceReportList').innerHTML = html;
|
||||
}
|
||||
|
||||
function renderHomework(data) {
|
||||
const rows = data.rows || [];
|
||||
const summary = data.summary || {};
|
||||
document.getElementById('homeworkSummary').textContent =
|
||||
`共 ${rows.length} 人,${summary.total || 0} 条记录:已交 ${summary.submitted || 0}、未交 ${summary.not_submitted || 0}、迟交 ${summary.late || 0},未交率 ${rateText(summary.miss_rate)}`;
|
||||
|
||||
let html = '';
|
||||
rows.forEach((row, index) => {
|
||||
html += `<tr>
|
||||
<td>${index + 1}</td>
|
||||
<td>${escapeHtml(row.student_no)}</td>
|
||||
<td>${escapeHtml(row.name)}</td>
|
||||
<td class="plus">${row.submitted}</td>
|
||||
<td class="minus">${row.not_submitted}</td>
|
||||
<td>${row.late}</td>
|
||||
<td>${row.total}</td>
|
||||
<td>${rateText(row.miss_rate)}</td>
|
||||
</tr>`;
|
||||
});
|
||||
if (rows.length === 0) {
|
||||
html = '<tr><td colspan="8" style="text-align:center;">暂无数据</td></tr>';
|
||||
}
|
||||
document.getElementById('homeworkReportList').innerHTML = html;
|
||||
}
|
||||
|
||||
function exportReport(type) {
|
||||
const data = type === 'attendance' ? attendanceCache : homeworkCache;
|
||||
if (!data || !data.rows || data.rows.length === 0) {
|
||||
showToast('请先查询报表数据', 'warning');
|
||||
return;
|
||||
}
|
||||
let csv = '';
|
||||
if (type === 'attendance') {
|
||||
csv += '序号,学号,姓名,出勤,缺勤,迟到,请假,记录数,出勤率(%)\n';
|
||||
data.rows.forEach((row, index) => {
|
||||
csv += [index + 1, row.student_no, row.name, row.present, row.absent, row.late, row.leave, row.total,
|
||||
(row.rate === null || row.rate === undefined) ? '' : row.rate].map(csvEscape).join(',') + '\n';
|
||||
});
|
||||
} else {
|
||||
csv += '序号,学号,姓名,已交,未交,迟交,记录数,未交率(%)\n';
|
||||
data.rows.forEach((row, index) => {
|
||||
csv += [index + 1, row.student_no, row.name, row.submitted, row.not_submitted, row.late, row.total,
|
||||
(row.miss_rate === null || row.miss_rate === undefined) ? '' : row.miss_rate].map(csvEscape).join(',') + '\n';
|
||||
});
|
||||
}
|
||||
const label = type === 'attendance' ? '考勤统计' : '作业统计';
|
||||
downloadCsv(`${label}_${data.start_date}_${data.end_date}.csv`, csv);
|
||||
showToast('导出成功,共' + data.rows.length + '人');
|
||||
}
|
||||
|
||||
initReportDates().then(loadReports);
|
||||
|
||||
window.loadReports = loadReports;
|
||||
window.exportReport = exportReport;
|
||||
|
||||
})();
|
||||
Reference in new issue
Block a user