feat: 多班级版班级管理系统 v2.0
技术栈:Go (Gin + GORM) + PHP + MySQL 5.7 + Redis 主要功能: - 多班级完全隔离(class_id 贯穿全系统) - 后端 Go Gin(端口 56789),Nginx 反代 - 超级管理员独立登录(env 配置,默认账密 admin/Admin123) - bcrypt 密码加密(无 PASSWORD_SALT) - 科任老师/课代表新角色 - 课代表作业管理页面 - 排行榜分项排行(操行分/考勤/作业) - 角色加减分上下限由班主任配置 - 家长改密功能(可开关) - 班级角色按需开关 - 宿舍号格式:南0-000 - 周度/月度重置功能 - MySQL 5.7 兼容 - 43 轮代码审查 + 全部修复 开发者: Canglan 版权归属: Sea Network Technology Studio 许可证: Apache License 2.0
This commit is contained in:
84
frontend/parent/attendance.php
Normal file
84
frontend/parent/attendance.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?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">历史记录</a>
|
||||
<a href="/parent/attendance.php" class="nav-item active">考勤记录</a>
|
||||
<a href="/parent/password.php" class="nav-item">修改密码</a>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<div class="stats-grid">
|
||||
<div class="stat-card"><div class="stat-label">出勤</div><div class="stat-value" id="attPresent">0</div></div>
|
||||
<div class="stat-card"><div class="stat-label">缺勤</div><div class="stat-value" id="attAbsent">0</div></div>
|
||||
<div class="stat-card"><div class="stat-label">迟到</div><div class="stat-value" id="attLate">0</div></div>
|
||||
<div class="stat-card"><div class="stat-label">请假</div><div class="stat-value" id="attLeave">0</div></div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-title">考勤记录明细</div>
|
||||
<div class="table-wrapper">
|
||||
<table class="table">
|
||||
<thead><tr><th>日期</th><th>状态</th><th>原因</th></tr></thead>
|
||||
<tbody id="attendanceList"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
async function loadAttendance() {
|
||||
const res = await apiGet('/api/parent/child/attendance');
|
||||
if (res && res.success) {
|
||||
let present = 0, absent = 0, late = 0, leave = 0;
|
||||
let html = '';
|
||||
res.data.records.forEach(record => {
|
||||
html += `<tr>
|
||||
<td>${record.date}</td>
|
||||
<td>${getStatusBadge(record.status, 'attendance')}</td>
|
||||
<td>${escapeHtml(record.reason || '-')}</td>
|
||||
</tr>`;
|
||||
switch(record.status) {
|
||||
case 'present': present++; break;
|
||||
case 'absent': absent++; break;
|
||||
case 'late': late++; break;
|
||||
case 'leave': leave++; break;
|
||||
}
|
||||
});
|
||||
document.getElementById('attPresent').textContent = present;
|
||||
document.getElementById('attAbsent').textContent = absent;
|
||||
document.getElementById('attLate').textContent = late;
|
||||
document.getElementById('attLeave').textContent = leave;
|
||||
|
||||
if (res.data.records.length === 0) {
|
||||
html = '<tr><td colspan="3" style="text-align:center;">暂无记录</td></tr>';
|
||||
}
|
||||
document.getElementById('attendanceList').innerHTML = html;
|
||||
}
|
||||
}
|
||||
loadAttendance();
|
||||
</script>
|
||||
<script src="/assets/js/parent.js"></script>
|
||||
|
||||
<?php include __DIR__ . '/../includes/footer.php'; ?>
|
||||
101
frontend/parent/dashboard.php
Normal file
101
frontend/parent/dashboard.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<?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 active">首页</a>
|
||||
<a href="/parent/history.php" class="nav-item">历史记录</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="child-info">
|
||||
<div class="child-name" id="childName">--</div>
|
||||
<div class="child-no" id="childNo">--</div>
|
||||
<div class="child-no" id="childDormitory" style="display:none;"></div>
|
||||
</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>
|
||||
.child-info {
|
||||
text-align: center;
|
||||
padding: 20px;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
border-radius: 12px;
|
||||
color: white;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.child-name { font-size: 24px; font-weight: bold; margin-bottom: 8px; }
|
||||
.child-no { font-size: 14px; opacity: 0.9; }
|
||||
.initial-points-hint {
|
||||
text-align: center;
|
||||
color: #999;
|
||||
font-size: 13px;
|
||||
margin-top: 8px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
async function loadDashboard() {
|
||||
const res = await apiGet('/api/parent/child/conduct');
|
||||
if (res && res.success) {
|
||||
document.getElementById('childName').textContent = res.data.student_name;
|
||||
document.getElementById('childNo').textContent = res.data.student_no;
|
||||
document.getElementById('totalPoints').textContent = res.data.total_points;
|
||||
if (res.data.dormitory_number) {
|
||||
document.getElementById('childDormitory').textContent = '宿舍号: ' + res.data.dormitory_number;
|
||||
document.getElementById('childDormitory').style.display = '';
|
||||
}
|
||||
}
|
||||
|
||||
// 加载排名信息
|
||||
const rankRes = await apiGet('/api/parent/child/ranking');
|
||||
if (rankRes && rankRes.success) {
|
||||
const rank = rankRes.data.rank;
|
||||
if (rank) {
|
||||
document.getElementById('studentRank').textContent = `第${rank}名`;
|
||||
} else {
|
||||
document.getElementById('studentRank').textContent = '--';
|
||||
}
|
||||
}
|
||||
|
||||
// 显示初始分提示
|
||||
const initialPoints = window.STUDENT_INITIAL_POINTS || 60;
|
||||
document.getElementById('initialPointsHint').textContent = `初始操行分为 ${initialPoints} 分`;
|
||||
}
|
||||
loadDashboard();
|
||||
</script>
|
||||
<script src="/assets/js/parent.js"></script>
|
||||
|
||||
<?php include __DIR__ . '/../includes/footer.php'; ?>
|
||||
117
frontend/parent/history.php
Normal file
117
frontend/parent/history.php
Normal file
@@ -0,0 +1,117 @@
|
||||
<?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'; ?>
|
||||
106
frontend/parent/password.php
Normal file
106
frontend/parent/password.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
/**
|
||||
* 多班级版班级管理系统 - 家长修改密码页
|
||||
*
|
||||
* 开发者: Canglan
|
||||
* 联系方式: admin@sea-studio.top
|
||||
* 版权归属: Sea Network Technology Studio
|
||||
* 许可证: Apache License 2.0
|
||||
*
|
||||
* 版权所有 © Sea Network Technology Studio
|
||||
*/
|
||||
|
||||
$page_title = '修改密码';
|
||||
require_once __DIR__ . '/../config.php';
|
||||
|
||||
if (!isset($_SESSION['user_id']) || $_SESSION['user_type'] !== 'parent') {
|
||||
header('Location: /index.php');
|
||||
exit();
|
||||
}
|
||||
|
||||
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">考勤记录</a>
|
||||
<a href="/parent/password.php" class="nav-item active">修改密码</a>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<div class="card">
|
||||
<div class="card-title">修改密码</div>
|
||||
<div id="featureDisabled" style="display:none;">
|
||||
<p style="text-align:center;color:#999;padding:30px 0;">该功能暂未开放,请联系班主任启用"家长改密"功能开关。</p>
|
||||
</div>
|
||||
<form id="passwordForm" style="display:none;">
|
||||
<div class="form-group">
|
||||
<label>原密码 <span style="color:red;">*</span></label>
|
||||
<input type="password" id="oldPassword" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>新密码 <span style="color:red;">*</span></label>
|
||||
<input type="password" id="newPassword" required>
|
||||
<small>密码长度6-20位,需包含大写字母、小写字母、数字、特殊符号中的至少3种</small>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>确认新密码 <span style="color:red;">*</span></label>
|
||||
<input type="password" id="confirmPassword" required>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">确认修改</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
async function checkFeature() {
|
||||
var res = await apiGet('/api/class/features');
|
||||
if (res && res.success && res.data && res.data.features) {
|
||||
var val = res.data.features.parent_password_change_enabled;
|
||||
var enabled = val === 1 || val === '1' || val === true;
|
||||
if (enabled) {
|
||||
document.getElementById('passwordForm').style.display = '';
|
||||
} else {
|
||||
document.getElementById('featureDisabled').style.display = '';
|
||||
}
|
||||
} else {
|
||||
document.getElementById('featureDisabled').style.display = '';
|
||||
}
|
||||
}
|
||||
|
||||
document.getElementById('passwordForm').addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
var oldPassword = document.getElementById('oldPassword').value;
|
||||
var newPassword = document.getElementById('newPassword').value;
|
||||
var confirmPassword = document.getElementById('confirmPassword').value;
|
||||
|
||||
if (newPassword !== confirmPassword) {
|
||||
showToast('两次输入的新密码不一致', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
if (newPassword.length < 6 || newPassword.length > 20) {
|
||||
showToast('密码长度需为6-20位', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
var res = await apiPost('/api/parent/password', {
|
||||
old_password: oldPassword,
|
||||
new_password: newPassword
|
||||
});
|
||||
|
||||
if (res && res.success) {
|
||||
showToast('密码修改成功,请重新登录');
|
||||
setTimeout(function() { logout(); }, 1500);
|
||||
} else {
|
||||
showToast(res && res.message ? res.message : '密码修改失败', 'error');
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener('DOMContentLoaded', checkFeature);
|
||||
</script>
|
||||
<script src="/assets/js/parent.js"></script>
|
||||
|
||||
<?php include __DIR__ . '/../includes/footer.php'; ?>
|
||||
Reference in New Issue
Block a user