v1.1更新家长端可查看历史记录

This commit is contained in:
2026-04-20 09:54:26 +08:00
parent 5b47b5f60f
commit 3a9abf83b8
11 changed files with 289 additions and 16 deletions

View File

@@ -23,6 +23,7 @@ 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">历史记录</a>
<a href="/parent/attendance.php" class="nav-item active">考勤记录</a>
</div>

View File

@@ -23,6 +23,7 @@ include __DIR__ . '/../includes/header.php';
<div class="nav">
<a href="/parent/dashboard.php" class="nav-item active">首页</a>
<a href="/parent/history.php" class="nav-item">历史记录</a>
<a href="/parent/attendance.php" class="nav-item">考勤记录</a>
</div>
@@ -31,12 +32,17 @@ include __DIR__ . '/../includes/header.php';
<div class="child-name" id="childName">--</div>
<div class="child-no" id="childNo">--</div>
</div>
<div class="card">
<div class="conduct-score">
<div class="score-number" id="totalPoints">--</div>
<div class="score-label">当前操行分</div>
<div class="stats-grid">
<div class="stat-card">
<div class="stat-label">当前操行分</div>
<div class="stat-value" id="totalPoints">--</div>
</div>
<div class="stat-card">
<div class="stat-label">班级排名</div>
<div class="stat-value" id="studentRank">--</div>
</div>
</div>
<div class="initial-points-hint" id="initialPointsHint"></div>
</div>
<style>
@@ -50,7 +56,12 @@ include __DIR__ . '/../includes/header.php';
}
.child-name { font-size: 24px; font-weight: bold; margin-bottom: 8px; }
.child-no { font-size: 14px; opacity: 0.9; }
.score-number { font-size: 72px; font-weight: bold; color: #667eea; text-align: center; }
.initial-points-hint {
text-align: center;
color: #999;
font-size: 13px;
margin-top: 8px;
}
</style>
<script>
@@ -61,6 +72,18 @@ async function loadDashboard() {
document.getElementById('childNo').textContent = res.data.student_no;
document.getElementById('totalPoints').textContent = res.data.total_points;
}
// 加载排名信息
const rankRes = await apiGet('/api/parent/child/ranking');
if (rankRes && rankRes.success) {
const rank = rankRes.data.rank;
const total = rankRes.data.total_students;
document.getElementById('studentRank').textContent = rank ? `第${rank}名` : '--';
}
// 显示初始分提示
const initialPoints = window.STUDENT_INITIAL_POINTS || 60;
document.getElementById('initialPointsHint').textContent = `初始操行分为 ${initialPoints} 分`;
}
loadDashboard();
</script>

118
frontend/parent/history.php Normal file
View 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'; ?>