v1.1更新家长端可查看历史记录
This commit is contained in:
@@ -12,7 +12,8 @@
|
||||
- 修改个人登录密码(首次登录强制修改)
|
||||
|
||||
### 家长端
|
||||
- 查询子女当前操行总分
|
||||
- 查询子女当前操行总分和班级排名
|
||||
- 查看子女操行分历史记录(加分/减分明细)
|
||||
- 查看子女考勤记录
|
||||
|
||||
### 管理端
|
||||
@@ -169,7 +170,8 @@ classmanager/
|
||||
│ │
|
||||
│ ├── parent/ # 家长端
|
||||
│ │ ├── attendance.php # 考勤记录
|
||||
│ │ └── dashboard.php # 家长端首页
|
||||
│ │ ├── dashboard.php # 家长端首页
|
||||
│ │ └── history.php # 历史记录
|
||||
│ │
|
||||
│ └── student/ # 学生端
|
||||
│ ├── attendance.php # 考勤记录
|
||||
|
||||
@@ -64,3 +64,47 @@ async def get_child_attendance(request: Request):
|
||||
result = await ParentService.get_child_attendance(user["user_id"])
|
||||
|
||||
return success_response(data=result)
|
||||
|
||||
|
||||
@router.get("/child/ranking")
|
||||
async def get_child_ranking(request: Request):
|
||||
"""
|
||||
获取子女排名信息
|
||||
"""
|
||||
user = await get_current_user(request)
|
||||
|
||||
if user["user_type"] != "parent":
|
||||
return error_response(message="仅限家长访问", code=403)
|
||||
|
||||
result = await ParentService.get_child_ranking(user["user_id"])
|
||||
|
||||
if "error" in result:
|
||||
return error_response(message=result["error"], code=400)
|
||||
|
||||
return success_response(data=result)
|
||||
|
||||
|
||||
@router.get("/child/history")
|
||||
async def get_child_history(
|
||||
request: Request,
|
||||
page: int = Query(1, ge=1),
|
||||
page_size: int = Query(20, ge=1, le=100)
|
||||
):
|
||||
"""
|
||||
获取子女操行分历史记录
|
||||
"""
|
||||
user = await get_current_user(request)
|
||||
|
||||
if user["user_type"] != "parent":
|
||||
return error_response(message="仅限家长访问", code=403)
|
||||
|
||||
result = await ParentService.get_child_history(
|
||||
parent_id=user["user_id"],
|
||||
page=page,
|
||||
page_size=page_size
|
||||
)
|
||||
|
||||
if "error" in result:
|
||||
return error_response(message=result["error"], code=400)
|
||||
|
||||
return success_response(data=result)
|
||||
@@ -9,7 +9,7 @@
|
||||
# 版权所有 © Sea Network Technology Studio
|
||||
# ===========================================
|
||||
|
||||
from typing import Dict, Any, Optional
|
||||
from typing import Dict, Any, Optional, List
|
||||
|
||||
from models.user import UserModel
|
||||
from models.student import StudentModel
|
||||
@@ -61,7 +61,6 @@ class ParentService:
|
||||
"student_name": student["name"],
|
||||
"homework": homework
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
async def get_child_attendance(parent_id: int) -> Dict[str, Any]:
|
||||
"""获取子女考勤记录"""
|
||||
@@ -80,3 +79,66 @@ class ParentService:
|
||||
"student_name": student["name"],
|
||||
"records": records
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
async def get_child_ranking(parent_id: int) -> Dict[str, Any]:
|
||||
"""获取子女排名信息"""
|
||||
user = await UserModel.get_by_user_id(parent_id)
|
||||
if not user or not user["student_id"]:
|
||||
return {"error": "未关联学生"}
|
||||
|
||||
student = await StudentModel.get_by_id(user["student_id"])
|
||||
if not student:
|
||||
return {"error": "学生不存在"}
|
||||
|
||||
# 获取全班排名
|
||||
ranking = await StudentModel.get_ranking(limit=1000)
|
||||
|
||||
# 查找当前学生排名
|
||||
student_rank = None
|
||||
total_students = 0
|
||||
for r in ranking:
|
||||
total_students += 1
|
||||
if r["student_id"] == user["student_id"]:
|
||||
student_rank = r["rank"]
|
||||
|
||||
return {
|
||||
"student_id": student["student_id"],
|
||||
"student_name": student["name"],
|
||||
"student_no": student["student_no"],
|
||||
"total_points": student["total_points"],
|
||||
"rank": student_rank,
|
||||
"total_students": total_students
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
async def get_child_history(parent_id: int, page: int = 1, page_size: int = 20) -> Dict[str, Any]:
|
||||
"""获取子女操行分历史记录"""
|
||||
user = await UserModel.get_by_user_id(parent_id)
|
||||
if not user or not user["student_id"]:
|
||||
return {"error": "未关联学生"}
|
||||
|
||||
student = await StudentModel.get_by_id(user["student_id"])
|
||||
if not student:
|
||||
return {"error": "学生不存在"}
|
||||
|
||||
offset = (page - 1) * page_size
|
||||
records = await ConductModel.get_student_records(
|
||||
student_id=user["student_id"],
|
||||
limit=page_size,
|
||||
offset=offset
|
||||
)
|
||||
|
||||
# 获取总数
|
||||
all_records = await ConductModel.get_student_records(user["student_id"], limit=10000)
|
||||
total = len(all_records)
|
||||
|
||||
return {
|
||||
"student_id": student["student_id"],
|
||||
"student_name": student["name"],
|
||||
"total_points": student["total_points"],
|
||||
"records": records,
|
||||
"total": total,
|
||||
"page": page,
|
||||
"page_size": page_size
|
||||
}
|
||||
@@ -24,13 +24,28 @@
|
||||
| 子女姓名 | 显示关联学生的姓名 |
|
||||
| 学号 | 显示关联学生的学号 |
|
||||
| 当前操行分 | 显示子女当前的总操行分 |
|
||||
| 班级排名 | 显示子女在全班的排名 |
|
||||
|
||||
页面顶部以紫色渐变卡片展示子女基本信息,下方大字号显示当前操行分。
|
||||
页面顶部以紫色渐变卡片展示子女基本信息,下方以统计卡片形式展示操行分和班级排名,底部提示初始操行分值。
|
||||
|
||||
### 2. 考勤记录
|
||||
### 2. 历史记录
|
||||
|
||||
查看子女的操行分历史明细:
|
||||
|
||||
- 按时间显示操行分变动记录
|
||||
- 每条记录包含:
|
||||
- 日期时间
|
||||
- 类型(手动/考勤/作业等)
|
||||
- 原因
|
||||
- 分值变动(加分绿色、减分红色)
|
||||
- 记录人
|
||||
- 支持分页浏览
|
||||
|
||||
### 3. 考勤记录
|
||||
|
||||
查看子女的考勤记录:
|
||||
|
||||
- 顶部统计卡片显示出勤、缺勤、迟到、请假次数
|
||||
- 按日期显示考勤记录列表
|
||||
- 每条记录包含:
|
||||
- 日期
|
||||
@@ -45,7 +60,8 @@
|
||||
|
||||
| 导航项 | 页面 | 说明 |
|
||||
|-------|------|------|
|
||||
| 首页 | /parent/dashboard.php | 子女信息和操行分概览 |
|
||||
| 首页 | /parent/dashboard.php | 子女信息、操行分和排名概览 |
|
||||
| 历史记录 | /parent/history.php | 子女操行分变动历史明细 |
|
||||
| 考勤记录 | /parent/attendance.php | 子女考勤记录明细 |
|
||||
|
||||
---
|
||||
@@ -55,5 +71,5 @@
|
||||
### Q: 忘记密码怎么办?
|
||||
请联系班主任重置密码。
|
||||
|
||||
### Q: 为什么只能看到总分,看不到加减分详情?
|
||||
家长端目前仅展示子女的总操行分,如需了解详细加减分情况,请联系班主任或通过学生端查看。
|
||||
### Q: 初始操行分是多少?
|
||||
学生初始操行分默认为60分,可在系统配置中调整。首页底部会显示当前系统的初始分设定值。
|
||||
|
||||
@@ -50,3 +50,6 @@ DEDUCTION_ATTENDANCE_ABSENT=5
|
||||
DEDUCTION_ATTENDANCE_LATE=2
|
||||
# 考勤-请假扣分
|
||||
DEDUCTION_ATTENDANCE_LEAVE=1
|
||||
|
||||
# 学生初始操行分
|
||||
STUDENT_INITIAL_POINTS=60
|
||||
@@ -69,6 +69,9 @@ define('DEDUCTION_ATTENDANCE_ABSENT', (int)($config['DEDUCTION_ATTENDANCE_ABSENT
|
||||
define('DEDUCTION_ATTENDANCE_LATE', (int)($config['DEDUCTION_ATTENDANCE_LATE'] ?? 2));
|
||||
define('DEDUCTION_ATTENDANCE_LEAVE', (int)($config['DEDUCTION_ATTENDANCE_LEAVE'] ?? 1));
|
||||
|
||||
// 学生初始操行分
|
||||
define('STUDENT_INITIAL_POINTS', (int)($config['STUDENT_INITIAL_POINTS'] ?? 60));
|
||||
|
||||
// 会话配置
|
||||
ini_set('session.cookie_httponly', 1);
|
||||
ini_set('session.use_only_cookies', 1);
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
*/
|
||||
?>
|
||||
<div class="footer">
|
||||
<p>© <?php echo date('Y'); ?> Sea Network Technology Studio<?php if (defined('ICP_ENABLED') && ICP_ENABLED && defined('ICP_NUMBER') && ICP_NUMBER): ?> | <a href="https://beian.miit.gov.cn/" target="_blank" rel="noopener noreferrer"><?php echo htmlspecialchars(ICP_NUMBER); ?></a><?php endif; ?></p>
|
||||
<p>© <?php echo date('Y'); ?> Sea Network Technology Studio</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -51,5 +51,6 @@ $page_title = $page_title ?? '首页';
|
||||
window.DEDUCTION_ATTENDANCE_ABSENT = <?php echo DEDUCTION_ATTENDANCE_ABSENT; ?>;
|
||||
window.DEDUCTION_ATTENDANCE_LATE = <?php echo DEDUCTION_ATTENDANCE_LATE; ?>;
|
||||
window.DEDUCTION_ATTENDANCE_LEAVE = <?php echo DEDUCTION_ATTENDANCE_LEAVE; ?>;
|
||||
window.STUDENT_INITIAL_POINTS = <?php echo STUDENT_INITIAL_POINTS; ?>;
|
||||
</script>
|
||||
<script src="/assets/js/common.js"></script>
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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
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