- 后端从 Python FastAPI 重写为 Go Gin(端口 56789) - 多班级完全隔离 - 超级管理员独立登录 - 课代表作业管理、排行榜分项排行 - 角色加减分上下限可配置 - 家长改密功能(可开关) - 周度/月度重置功能 - MySQL 5.7 兼容 - 43轮代码审查+全部修复 - Apache 2.0 许可证
118 lines
3.9 KiB
PHP
118 lines
3.9 KiB
PHP
<?php
|
|
/**
|
|
* 多班级版班级管理系统 - 家长端历史记录
|
|
*
|
|
* 开发者: Canglan
|
|
* 联系方式: admin@sea-studio.top
|
|
* 版权归属: Sea Network Technology Studio
|
|
* 许可证: Apache License 2.0
|
|
*
|
|
* 版权所有 © Sea Network Technology Studio
|
|
*/
|
|
|
|
require_once __DIR__ . '/../config.php';
|
|
|
|
if (!isset($_SESSION['user_id']) || $_SESSION['user_type'] !== 'parent') {
|
|
header('Location: /index.php');
|
|
exit();
|
|
}
|
|
|
|
$page_title = '历史记录';
|
|
include __DIR__ . '/../includes/header.php';
|
|
?>
|
|
|
|
<div class="nav">
|
|
<a href="/parent/dashboard.php" class="nav-item">首页</a>
|
|
<a href="/parent/history.php" class="nav-item active">历史记录</a>
|
|
<a href="/parent/attendance.php" class="nav-item">考勤记录</a>
|
|
<a href="/parent/password.php" class="nav-item">修改密码</a>
|
|
</div>
|
|
|
|
<div class="container">
|
|
<div class="card">
|
|
<div class="card-title">操行分历史记录</div>
|
|
<div class="table-wrapper">
|
|
<table class="table">
|
|
<thead>
|
|
<tr>
|
|
<th>日期</th>
|
|
<th>原因</th>
|
|
<th>分值</th>
|
|
<th>记录人</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="historyList">
|
|
<tr><td colspan="4" style="text-align:center;">加载中...</td></tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<div class="pagination" id="pagination" style="display:none;">
|
|
<button class="btn btn-sm" id="prevBtn" onclick="changePage(-1)">上一页</button>
|
|
<span id="pageInfo">1 / 1</span>
|
|
<button class="btn btn-sm" id="nextBtn" onclick="changePage(1)">下一页</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<style>
|
|
.pagination {
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
gap: 15px;
|
|
margin-top: 15px;
|
|
padding: 10px 0;
|
|
}
|
|
.pagination .btn { padding: 6px 16px; font-size: 13px; }
|
|
.pagination span { color: #666; font-size: 14px; }
|
|
</style>
|
|
|
|
<script>
|
|
let currentPage = 1;
|
|
const pageSize = 20;
|
|
|
|
async function loadHistory(page) {
|
|
const res = await apiGet('/api/parent/child/history', { page: page, page_size: pageSize });
|
|
if (res && res.success) {
|
|
let html = '';
|
|
if (res.data.records.length === 0) {
|
|
html = '<tr><td colspan="4" style="text-align:center;">暂无记录</td></tr>';
|
|
} else {
|
|
res.data.records.forEach(record => {
|
|
const pointsClass = record.points_change > 0 ? 'plus' : 'minus';
|
|
const pointsText = record.points_change > 0 ? `+${record.points_change}` : record.points_change;
|
|
html += `<tr>
|
|
<td>${formatDateTime(record.created_at)}</td>
|
|
<td class="history-reason">${escapeHtml(record.reason || '-')}</td>
|
|
<td><span class="record-points ${pointsClass}">${pointsText}</span></td>
|
|
<td>班主任</td>
|
|
</tr>`;
|
|
});
|
|
}
|
|
document.getElementById('historyList').innerHTML = html;
|
|
|
|
// 分页
|
|
const totalPages = Math.ceil(res.data.total / pageSize);
|
|
if (totalPages > 1) {
|
|
document.getElementById('pagination').style.display = 'flex';
|
|
document.getElementById('pageInfo').textContent = `${res.data.page} / ${totalPages}`;
|
|
document.getElementById('prevBtn').disabled = res.data.page <= 1;
|
|
document.getElementById('nextBtn').disabled = res.data.page >= totalPages;
|
|
} else {
|
|
document.getElementById('pagination').style.display = 'none';
|
|
}
|
|
}
|
|
}
|
|
|
|
function changePage(delta) {
|
|
currentPage += delta;
|
|
if (currentPage < 1) currentPage = 1;
|
|
loadHistory(currentPage);
|
|
}
|
|
|
|
loadHistory(1);
|
|
</script>
|
|
<script src="/assets/js/parent.js"></script>
|
|
|
|
<?php include __DIR__ . '/../includes/footer.php'; ?>
|