v1.1更新家长端可查看历史记录
This commit is contained in:
118
frontend/parent/history.php
Normal file
118
frontend/parent/history.php
Normal file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
/**
|
||||
* 班级操行分管理系统 - 家长端历史记录
|
||||
*
|
||||
* 开发者: Canglan
|
||||
* 联系方式: admin@sea-studio.top
|
||||
* 版权归属: Sea Network Technology Studio
|
||||
* 许可证: MIT License
|
||||
*
|
||||
* 版权所有 © 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>
|
||||
</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>
|
||||
<th>记录人</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="historyList">
|
||||
<tr><td colspan="5" 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="5" 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>${escapeHtml(record.related_type || '手动')}</td>
|
||||
<td>${escapeHtml(record.reason || '-')}</td>
|
||||
<td><span class="record-points ${pointsClass}">${pointsText}</span></td>
|
||||
<td>${escapeHtml(record.recorder_name || '-')}</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'; ?>
|
||||
Reference in New Issue
Block a user