Files
ClassManager/frontend/admin/students.php
T
canglan ed3189096d 权限组全自定义、月度分独立、绑定邮箱免密与样式统一
1. 权限组:去掉锁定/预置限制,所有组可编辑/删除/分配;管理员新增/编辑可选任意组;管理员列表不再显示锁定徽标
2. 个人查询:月度分独立计算(当月净得分,与基础分无关),总分=基础分+加分-减分
3. 绑定邮箱:发送验证码与确认绑定不再需要密码(解绑仍需密码)
4. 权限组编辑UI:权限项按 学生/操行分/教务/系统管理 分区,支持全选/清空,上限两行布局,弹窗加宽
5. 样式统一:颜色变量化(硬编码色值清零)、check-grid/check-item 统一复选框网格、cell-wrap、subject-status 全局化、success-msg
6. 旧库升级期兼容保留(登录/权限降级、待升级提示)
7. 文档同步更新
2026-09-18 09:56:39 +08:00

240 lines
10 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?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'] !== 'admin') {
header('Location: /index.php');
exit();
}
$page_title = '学生管理';
$role = current_group_name();
include __DIR__ . '/../includes/header.php';
?>
<?php include __DIR__ . '/../includes/nav.php'; ?>
<div class="container">
<div class="card">
<div class="action-bar">
<div class="action-buttons">
<?php if (has_perm('manage_students')): ?>
<button class="btn btn-primary" onclick="showImportModal()">导入学生</button>
<button class="btn btn-primary" onclick="showAddStudentModal()">新增学生</button>
<?php endif; ?>
<?php if (has_perm('export_students')): ?>
<button class="btn btn-secondary" onclick="showExportStudentsModal()">导出学生名单</button>
<?php endif; ?>
</div>
<div class="search-bar">
<input type="text" id="searchInput" placeholder="搜索姓名/学号">
<button class="btn btn-primary" onclick="loadStudents(1)">搜索</button>
</div>
</div>
<div class="table-wrapper">
<table class="table">
<thead>
<tr>
<th><input type="checkbox" id="selectAll" onclick="toggleSelectAll()"></th>
<th>学号</th>
<th>姓名</th>
<th>宿舍号</th>
<th>操行分</th>
<?php if (has_perm('manage_students')): ?><th>家长手机号</th><?php endif; ?>
<th>操作</th>
</tr>
</thead>
<tbody id="studentList"></tbody>
</table>
</div>
<div class="pagination" id="pagination"></div>
</div>
</div>
<!-- 导入学生模态框 -->
<div id="importModal" class="modal">
<div class="modal-content">
<div class="modal-header">
<h3>导入学生</h3>
<button class="modal-close" onclick="closeModal('importModal')">&times;</button>
</div>
<div class="import-area" onclick="document.getElementById('importFile').click()">
<p>点击选择JSON文件</p>
<p class="import-label">或点击此处上传</p>
<input type="file" id="importFile" accept=".json">
<p style="margin-top: 10px; font-size: 12px; color: var(--color-text-muted);">
<a href="/assets/uploads/sample_import.json" download class="link">下载示例文件</a>
</p>
</div>
<div id="importPreview" class="preview-table" style="display: none;"></div>
<div class="modal-footer">
<button class="btn btn-primary" onclick="doImport()" id="importBtn" style="display: none;">确认导入</button>
</div>
</div>
</div>
<!-- 新增学生模态框 -->
<div id="addStudentModal" class="modal">
<div class="modal-content">
<div class="modal-header">
<h3>新增学生</h3>
<button class="modal-close" onclick="closeModal('addStudentModal')">&times;</button>
</div>
<form onsubmit="event.preventDefault(); submitAddStudent()">
<div class="form-group">
<label>学号 <span style="color:red;">*</span></label>
<input type="text" id="studentNo" required placeholder="4-20位字母数字组合">
<small>学号将作为学生登录账号</small>
</div>
<div class="form-group">
<label>姓名 <span style="color:red;">*</span></label>
<input type="text" id="studentName" required>
</div>
<div class="form-group">
<label>家长手机号</label>
<input type="tel" id="parentPhone" placeholder="11位手机号">
<small>填写后将自动创建家长账号(密码同学生初始密码123456)</small>
</div>
<div class="form-group">
<label>宿舍号</label>
<input type="text" id="addDormitoryNumber" placeholder="选填">
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">确认添加</button>
<button type="button" class="btn" onclick="closeModal('addStudentModal')">取消</button>
</div>
</form>
</div>
</div>
<!-- 编辑学生模态框 -->
<div id="editStudentModal" class="modal">
<div class="modal-content">
<div class="modal-header">
<h3>编辑学生信息</h3>
<button class="modal-close" onclick="closeModal('editStudentModal')">&times;</button>
</div>
<form onsubmit="event.preventDefault(); submitEditStudent()">
<input type="hidden" id="editStudentId">
<div class="form-group">
<label>学号</label>
<input type="text" id="editStudentNo" disabled>
</div>
<div class="form-group">
<label>姓名</label>
<input type="text" id="editStudentName" required maxlength="50">
</div>
<div class="form-group">
<label>家长手机号</label>
<input type="text" id="editStudentPhone" maxlength="20">
</div>
<div class="form-group">
<label>宿舍号</label>
<input type="text" id="editDormitoryNumber" placeholder="选填">
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">保存修改</button>
<button type="button" class="btn" onclick="closeModal('editStudentModal')">取消</button>
</div>
</form>
</div>
</div>
<!-- 重置学生密码模态框 -->
<div id="resetStudentPasswordModal" class="modal">
<div class="modal-content">
<div class="modal-header">
<h3>重置学生密码</h3>
<button class="modal-close" onclick="closeModal('resetStudentPasswordModal')">&times;</button>
</div>
<form onsubmit="event.preventDefault(); submitResetStudentPassword()">
<input type="hidden" id="resetStudentId">
<p id="resetStudentInfo" style="margin: 10px 0;"></p>
<div class="form-group">
<label>新密码</label>
<input type="password" id="newStudentPassword" required minlength="6" maxlength="20">
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-warning">确认重置</button>
<button type="button" class="btn" onclick="closeModal('resetStudentPasswordModal')">取消</button>
</div>
</form>
</div>
</div>
<script>window.PAGE_CONFIG = { role: '<?php echo htmlspecialchars($role, ENT_QUOTES, 'UTF-8'); ?>' };</script>
<script src="/assets/js/modules/modal-utils.js"></script>
<script src="/assets/js/modules/utils.js"></script>
<script src="/assets/js/modules/student-mgmt.js"></script>
<script src="/assets/js/modules/points-mgmt.js"></script>
<script src="/assets/js/students-manage.js"></script>
<!-- 导出学生名单模态框 -->
<div id="exportStudentsModal" class="modal">
<div class="modal-content">
<div class="modal-header">
<h3>导出学生名单</h3>
<button class="modal-close" onclick="closeModal('exportStudentsModal')">&times;</button>
</div>
<div class="form-group">
<label>导出字段</label>
<div class="check-grid">
<label class="check-item"><input type="checkbox" class="export-student-col" value="student_no" checked disabled> 学号</label>
<label class="check-item"><input type="checkbox" class="export-student-col" value="name" checked disabled> 姓名</label>
<label class="check-item"><input type="checkbox" class="export-student-col" value="dormitory_number" checked> 宿舍号</label>
<label class="check-item"><input type="checkbox" class="export-student-col" value="total_points" checked> 当前操行分</label>
<?php if (has_perm('manage_students')): ?>
<label class="check-item"><input type="checkbox" class="export-student-col" value="parent_phone"> 家长手机号</label>
<?php endif; ?>
<label class="check-item"><input type="checkbox" class="export-student-col" value="status" checked> 状态</label>
</div>
<small>导出全班学生名单(CSV,可用Excel打开)</small>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" onclick="exportStudents()">开始导出</button>
<button type="button" class="btn" onclick="closeModal('exportStudentsModal')">取消</button>
</div>
</div>
</div>
<!-- 批量加减分模态框(共用) -->
<div id="batchPointsModal" class="modal">
<div class="modal-content">
<div class="modal-header">
<h3>批量加减分</h3>
<button class="modal-close" onclick="closeModal('batchPointsModal')">&times;</button>
</div>
<form onsubmit="event.preventDefault(); submitBatchPoints()">
<div class="form-group">
<label>选中学生</label>
<div id="selectedStudentsCount">0 人</div>
</div>
<div class="form-group">
<label>分数变动</label>
<input type="number" id="pointsChange" required placeholder="正数为加分,负数为扣分">
<small id="pointsLimitHint"></small>
</div>
<div class="form-group">
<label>原因</label>
<textarea id="pointsReason" required rows="3" placeholder="请填写加减分原因"></textarea>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">确认提交</button>
<button type="button" class="btn" onclick="closeModal('batchPointsModal')">取消</button>
</div>
</form>
</div>
</div>
<?php include __DIR__ . '/../includes/footer.php'; ?>