feat: 实现教师资料更新、操作日志和系统设置功能
新增教师资料更新功能,包括个人信息修改和密码更新 添加操作日志记录系统,记录用户关键操作 实现系统设置模块,支持动态配置系统参数 重构数据库模型,新增教师表和系统设置表 优化成绩录入逻辑,支持平时分、期中和期末成绩计算 添加数据导出功能,支持学生、教师和成绩数据导出 完善管理员后台,增加统计图表和操作日志查看
This commit is contained in:
@@ -3,439 +3,327 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>学生管理 - XX学校成绩管理系统</title>
|
||||
<link rel="stylesheet" href="/public/css/style.css">
|
||||
<title>学生管理 - 管理员端</title>
|
||||
<!-- Bootstrap 5 CSS -->
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- Font Awesome -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
||||
<!-- Google Fonts -->
|
||||
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;500;700&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
:root {
|
||||
--sidebar-width: 260px;
|
||||
--primary-color: #4e73df;
|
||||
--secondary-color: #858796;
|
||||
--light-bg: #f8f9fc;
|
||||
--admin-gradient: linear-gradient(135deg, #4e73df 0%, #224abe 100%);
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Noto Sans SC', sans-serif;
|
||||
background-color: var(--light-bg);
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* 侧边栏样式 */
|
||||
.sidebar {
|
||||
width: var(--sidebar-width);
|
||||
height: 100vh;
|
||||
position: fixed;
|
||||
left: 0;
|
||||
top: 0;
|
||||
background: var(--admin-gradient);
|
||||
color: white;
|
||||
z-index: 1000;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.sidebar-header {
|
||||
padding: 2rem 1.5rem;
|
||||
text-align: center;
|
||||
border-bottom: 1px solid rgba(255,255,255,0.1);
|
||||
}
|
||||
|
||||
.sidebar-brand {
|
||||
font-size: 1.25rem;
|
||||
font-weight: 700;
|
||||
color: white;
|
||||
text-decoration: none;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.user-profile {
|
||||
padding: 2rem 1rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.user-avatar {
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
background: rgba(255,255,255,0.2);
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin: 0 auto 1rem;
|
||||
font-size: 2rem;
|
||||
}
|
||||
|
||||
.user-info h6 { margin-bottom: 0.25rem; font-weight: 600; }
|
||||
.user-info p { font-size: 0.85rem; opacity: 0.8; margin-bottom: 0; }
|
||||
|
||||
.nav-menu { padding: 1rem 0; }
|
||||
.nav-item { padding: 0.25rem 1rem; }
|
||||
|
||||
.nav-link {
|
||||
color: rgba(255,255,255,0.8);
|
||||
padding: 0.8rem 1.25rem;
|
||||
border-radius: 0.5rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
transition: all 0.2s;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.nav-link:hover, .nav-link.active {
|
||||
color: white;
|
||||
background: rgba(255,255,255,0.15);
|
||||
}
|
||||
|
||||
.nav-link i { width: 20px; text-align: center; }
|
||||
|
||||
/* 主内容区 */
|
||||
.main-content {
|
||||
margin-left: var(--sidebar-width);
|
||||
padding: 2rem;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.top-navbar {
|
||||
background: white;
|
||||
padding: 1rem 2rem;
|
||||
border-radius: 1rem;
|
||||
box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.1);
|
||||
margin-bottom: 2rem;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.page-heading h4 { margin-bottom: 0; font-weight: 700; color: #333; }
|
||||
|
||||
@media (max-width: 992px) {
|
||||
.sidebar { left: -var(--sidebar-width); }
|
||||
.main-content { margin-left: 0; }
|
||||
.sidebar.active { left: 0; }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<!-- 导航<EFBFBD><EFBFBD>?-->
|
||||
<nav class="navbar">
|
||||
<div class="container">
|
||||
<div class="navbar-brand">
|
||||
<a href="/">
|
||||
<i class="fas fa-graduation-cap"></i>
|
||||
<span>XX学校成绩管理系统</span>
|
||||
<!-- 侧边栏 -->
|
||||
<div class="sidebar">
|
||||
<div class="sidebar-header">
|
||||
<a href="#" class="sidebar-brand">
|
||||
<i class="fas fa-graduation-cap"></i>
|
||||
<span>成绩管理系统</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="user-profile">
|
||||
<div class="user-avatar">
|
||||
<i class="fas fa-user-shield"></i>
|
||||
</div>
|
||||
<div class="user-info text-white">
|
||||
<h6 id="adminName">加载中...</h6>
|
||||
<p>管理员</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<nav class="nav-menu">
|
||||
<div class="nav-item">
|
||||
<a href="/admin/dashboard" class="nav-link">
|
||||
<i class="fas fa-tachometer-alt"></i>
|
||||
<span>仪表板</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="navbar-menu">
|
||||
<a href="/" class="navbar-item">
|
||||
<i class="fas fa-home"></i>
|
||||
<span>主页</span>
|
||||
</a>
|
||||
<a href="/admin/dashboard" class="navbar-item">
|
||||
<i class="fas fa-tachometer-alt"></i>
|
||||
<span>控制面板</span>
|
||||
</a>
|
||||
<a href="/admin/student_management" class="navbar-item active">
|
||||
<div class="nav-item">
|
||||
<a href="/admin/user_management" class="nav-link">
|
||||
<i class="fas fa-users"></i>
|
||||
<span>学生管理</span>
|
||||
</a>
|
||||
<a href="/teacher/grade_management" class="navbar-item">
|
||||
<i class="fas fa-chart-bar"></i>
|
||||
<span>成绩管理</span>
|
||||
</a>
|
||||
<a href="/admin/user_management" class="navbar-item">
|
||||
<i class="fas fa-user-cog"></i>
|
||||
<span>用户管理</span>
|
||||
</a>
|
||||
<div class="navbar-user">
|
||||
<i class="fas fa-user-circle"></i>
|
||||
<span>管理<EFBFBD><EFBFBD>?/span>
|
||||
<div class="user-dropdown">
|
||||
<a href="#"><i class="fas fa-user"></i> 个人资料</a>
|
||||
<a href="#"><i class="fas fa-cog"></i> 设置</a>
|
||||
<a href="/login"><i class="fas fa-sign-out-alt"></i> 退出登<E587BA><E799BB>?/a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="nav-item">
|
||||
<a href="/admin/student_management" class="nav-link active">
|
||||
<i class="fas fa-user-graduate"></i>
|
||||
<span>学生管理</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="nav-item">
|
||||
<a href="/admin/teacher_management" class="nav-link">
|
||||
<i class="fas fa-chalkboard-teacher"></i>
|
||||
<span>教师管理</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="nav-item">
|
||||
<a href="/admin/grade_statistics" class="nav-link">
|
||||
<i class="fas fa-chart-bar"></i>
|
||||
<span>成绩统计</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="nav-item">
|
||||
<a href="/admin/system_settings" class="nav-link">
|
||||
<i class="fas fa-cog"></i>
|
||||
<span>系统设置</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="nav-item">
|
||||
<a href="/admin/data_export" class="nav-link">
|
||||
<i class="fas fa-download"></i>
|
||||
<span>数据导出</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="nav-item">
|
||||
<a href="/admin/operation_logs" class="nav-link">
|
||||
<i class="fas fa-history"></i>
|
||||
<span>操作日志</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="nav-item mt-4">
|
||||
<a href="javascript:void(0)" id="logoutBtn" class="nav-link text-warning">
|
||||
<i class="fas fa-sign-out-alt"></i>
|
||||
<span>退出登录</span>
|
||||
</a>
|
||||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
<!-- 主内容 -->
|
||||
<div class="main-content">
|
||||
<!-- 顶部导航 -->
|
||||
<div class="top-navbar">
|
||||
<div class="page-heading">
|
||||
<h4>学生管理</h4>
|
||||
</div>
|
||||
<div class="d-flex align-items-center gap-3">
|
||||
<div class="text-end d-none d-md-block">
|
||||
<div class="small text-muted" id="currentTime"></div>
|
||||
<div class="fw-bold" id="userName">加载中...</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<!-- 主要内容<EFBFBD><EFBFBD>?-->
|
||||
<main class="main-content">
|
||||
<div class="container">
|
||||
<div class="student-management">
|
||||
<!-- 页面标题 -->
|
||||
<div class="page-header">
|
||||
<h1><i class="fas fa-users"></i> 学生管理</h1>
|
||||
<p>管理学生基本信息,支持添加、编辑、删除和查询学生信息</p>
|
||||
</div>
|
||||
|
||||
<!-- 筛选区<E98089><E58CBA>?-->
|
||||
<div class="filter-section">
|
||||
<div class="filter-row">
|
||||
<div class="filter-group">
|
||||
<label for="student-id"><i class="fas fa-id-card"></i> 学号</label>
|
||||
<input type="text" id="student-id" placeholder="请输入学<E585A5><E5ADA6>?>
|
||||
</div>
|
||||
<div class="filter-group">
|
||||
<label for="student-name"><i class="fas fa-user"></i> 姓名</label>
|
||||
<input type="text" id="student-name" placeholder="请输入姓<E585A5><E5A793>?>
|
||||
</div>
|
||||
<div class="filter-group">
|
||||
<label for="class-select"><i class="fas fa-school"></i> 班级</label>
|
||||
<select id="class-select">
|
||||
<option value="">全部班级</option>
|
||||
<option value="计算机科学与技<E4B88E><E68A80>?<3F><>?>计算机科学与技<E4B88E><E68A80>?<3F><>?/option>
|
||||
<option value="计算机科学与技<EFBFBD><EFBFBD>?<EFBFBD><EFBFBD>?>计算机科学与技<EFBFBD><EFBFBD>?<3F><>?/option>
|
||||
<option value="软件工程1<E7A88B><31>?>软件工程1<E7A88B><31>?/option>
|
||||
<option value="软件工程2<EFBFBD><EFBFBD>?>软件工程2<EFBFBD><EFBFBD>?/option>
|
||||
<option value="网络工程1<E7A88B><31>?>网络工程1<E7A88B><31>?/option>
|
||||
<option value="网络工程2<EFBFBD><EFBFBD>?>网络工程2<EFBFBD><EFBFBD>?/option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="filter-group">
|
||||
<label for="gender-select"><i class="fas fa-venus-mars"></i> 性别</label>
|
||||
<select id="gender-select">
|
||||
<option value="">全部性别</option>
|
||||
<option value="<22><>?><3E><>?/option>
|
||||
<option value="<EFBFBD><EFBFBD>?><EFBFBD><EFBFBD>?/option>
|
||||
</select>
|
||||
<!-- 筛选栏 -->
|
||||
<div class="card border-0 shadow-sm mb-4">
|
||||
<div class="card-body">
|
||||
<form id="studentFilterForm" class="row g-3 align-items-end">
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">搜索学生</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fas fa-search"></i></span>
|
||||
<input type="text" class="form-control" id="studentSearch" placeholder="学号、姓名或班级">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="action-buttons">
|
||||
<button id="add-btn" class="btn-add">
|
||||
<i class="fas fa-plus"></i>
|
||||
添加学生
|
||||
</button>
|
||||
<button id="search-btn" class="btn-search">
|
||||
<i class="fas fa-search"></i>
|
||||
查询学生
|
||||
</button>
|
||||
<button id="reset-btn" class="btn-reset">
|
||||
<i class="fas fa-redo"></i>
|
||||
重置条件
|
||||
</button>
|
||||
<button id="export-btn" class="btn-export">
|
||||
<i class="fas fa-file-export"></i>
|
||||
导出数据
|
||||
<!--
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">班级筛选</label>
|
||||
<select class="form-select" id="classFilter">
|
||||
<option value="">全部班级</option>
|
||||
</select>
|
||||
</div>
|
||||
-->
|
||||
<div class="col-md-9 text-md-end">
|
||||
<button type="button" class="btn btn-primary" id="addStudentBtn">
|
||||
<i class="fas fa-plus me-1"></i> 新增学生
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 学生表格 -->
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 学生列表 -->
|
||||
<div class="card border-0 shadow-sm">
|
||||
<div class="card-body p-0">
|
||||
<div class="table-responsive">
|
||||
<table class="student-table">
|
||||
<thead>
|
||||
<table class="table table-hover align-middle mb-0">
|
||||
<thead class="bg-light">
|
||||
<tr>
|
||||
<th>学号</th>
|
||||
<th class="ps-4">学号</th>
|
||||
<th>姓名</th>
|
||||
<th>性别</th>
|
||||
<th>班级</th>
|
||||
<th>联系电话</th>
|
||||
<th>邮箱</th>
|
||||
<th>入学时间</th>
|
||||
<th>操作</th>
|
||||
<th>专业</th>
|
||||
<th>年级</th>
|
||||
<th>联系方式</th>
|
||||
<th class="text-end pe-4">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="student-table-body">
|
||||
<!-- 数据将通过JavaScript动态加<E68081><E58AA0>?-->
|
||||
<tr>
|
||||
<td colspan="8" class="loading">
|
||||
<i class="fas fa-spinner fa-spin"></i>
|
||||
<p>正在加载学生数据...</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tbody id="studentTableBody">
|
||||
<tr><td colspan="7" class="text-center py-5">加载中...</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- 分页控件 -->
|
||||
<div class="pagination" id="pagination">
|
||||
<button id="prev-btn" disabled>
|
||||
<i class="fas fa-chevron-left"></i>
|
||||
上一<E4B88A><E4B880>? </button>
|
||||
<button class="active">1</button>
|
||||
<button>2</button>
|
||||
<button>3</button>
|
||||
<button id="next-btn">
|
||||
下一<E4B88B><E4B880>? <i class="fas fa-chevron-right"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="card-footer bg-white border-0 py-3">
|
||||
<nav>
|
||||
<ul class="pagination justify-content-center mb-0" id="studentPagination">
|
||||
<!-- Pagination rendered by JS -->
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Add/Edit Student Modal -->
|
||||
<div class="modal fade" id="studentModal" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="studentModalTitle">新增学生</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="studentForm">
|
||||
<input type="hidden" name="isEdit" id="studentIsEdit" value="false">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">学号</label>
|
||||
<input type="text" class="form-control" name="id" id="studentId" required>
|
||||
<div class="form-text">学号将作为登录账号,默认密码同账号</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">姓名</label>
|
||||
<input type="text" class="form-control" name="name" id="studentNameInput" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">班级</label>
|
||||
<input type="text" class="form-control" name="class" id="studentClass" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">专业</label>
|
||||
<input type="text" class="form-control" name="major" id="studentMajor">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">年级</label>
|
||||
<input type="number" class="form-control" name="grade" id="studentGrade" placeholder="例如:2023">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">联系方式</label>
|
||||
<input type="text" class="form-control" name="contact_info" id="studentContact">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
|
||||
<button type="button" class="btn btn-primary" id="saveStudentBtn">保存</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<!-- 页脚 -->
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p>© 2023 XX学校成绩管理系统. 版权所<E69D83><E68980>?</p>
|
||||
<p>技术支<EFBFBD><EFBFBD>? 计算机科学与技术学<E69CAF><E5ADA6>?/p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<script>
|
||||
// 模拟学生数据
|
||||
const mockStudents = [
|
||||
{
|
||||
id: '20230001',
|
||||
name: '张三',
|
||||
gender: '<27><>?,
|
||||
class: '计算机科学与技<EFBFBD><EFBFBD>?<EFBFBD><EFBFBD>?,
|
||||
phone: '13800138001',
|
||||
email: 'zhangsan@example.com',
|
||||
enrollmentDate: '2023-09-01'
|
||||
},
|
||||
{
|
||||
id: '20230002',
|
||||
name: '李四',
|
||||
gender: '<27><>?,
|
||||
class: '计算机科学与技<EFBFBD><EFBFBD>?<EFBFBD><EFBFBD>?,
|
||||
phone: '13800138002',
|
||||
email: 'lisi@example.com',
|
||||
enrollmentDate: '2023-09-01'
|
||||
},
|
||||
{
|
||||
id: '20230003',
|
||||
name: '王五',
|
||||
gender: '<27><>?,
|
||||
class: '计算机科学与技<EFBFBD><EFBFBD>?<EFBFBD><EFBFBD>?,
|
||||
phone: '13800138003',
|
||||
email: 'wangwu@example.com',
|
||||
enrollmentDate: '2023-09-01'
|
||||
},
|
||||
{
|
||||
id: '20230004',
|
||||
name: '赵六',
|
||||
gender: '<27><>?,
|
||||
class: '软件工程1<EFBFBD><EFBFBD>?,
|
||||
phone: '13800138004',
|
||||
email: 'zhaoliu@example.com',
|
||||
enrollmentDate: '2023-09-01'
|
||||
},
|
||||
{
|
||||
id: '20230005',
|
||||
name: '钱七',
|
||||
gender: '<27><>?,
|
||||
class: '软件工程2<EFBFBD><EFBFBD>?,
|
||||
phone: '13800138005',
|
||||
email: 'qianqi@example.com',
|
||||
enrollmentDate: '2023-09-01'
|
||||
},
|
||||
{
|
||||
id: '20230006',
|
||||
name: '孙八',
|
||||
gender: '<27><>?,
|
||||
class: '网络工程1<EFBFBD><EFBFBD>?,
|
||||
phone: '13800138006',
|
||||
email: 'sunba@example.com',
|
||||
enrollmentDate: '2023-09-01'
|
||||
},
|
||||
{
|
||||
id: '20230007',
|
||||
name: '周九',
|
||||
gender: '<27><>?,
|
||||
class: '网络工程2<EFBFBD><EFBFBD>?,
|
||||
phone: '13800138007',
|
||||
email: 'zhoujiu@example.com',
|
||||
enrollmentDate: '2023-09-01'
|
||||
},
|
||||
{
|
||||
id: '20230008',
|
||||
name: '吴十',
|
||||
gender: '<27><>?,
|
||||
class: '计算机科学与技<EFBFBD><EFBFBD>?<EFBFBD><EFBFBD>?,
|
||||
phone: '13800138008',
|
||||
email: 'wushi@example.com',
|
||||
enrollmentDate: '2023-09-01'
|
||||
}
|
||||
];
|
||||
|
||||
// 当前页数<E9A1B5><E695B0>? let currentPage = 1;
|
||||
const pageSize = 5;
|
||||
let filteredStudents = [...mockStudents];
|
||||
|
||||
// DOM元素
|
||||
const studentTableBody = document.getElementById('student-table-body');
|
||||
const pagination = document.getElementById('pagination');
|
||||
const prevBtn = document.getElementById('prev-btn');
|
||||
const nextBtn = document.getElementById('next-btn');
|
||||
const searchBtn = document.getElementById('search-btn');
|
||||
const resetBtn = document.getElementById('reset-btn');
|
||||
const addBtn = document.getElementById('add-btn');
|
||||
const exportBtn = document.getElementById('export-btn');
|
||||
|
||||
// 渲染学生表格
|
||||
function renderStudentTable() {
|
||||
const startIndex = (currentPage - 1) * pageSize;
|
||||
const endIndex = startIndex + pageSize;
|
||||
const pageStudents = filteredStudents.slice(startIndex, endIndex);
|
||||
|
||||
if (pageStudents.length === 0) {
|
||||
studentTableBody.innerHTML = `
|
||||
<tr>
|
||||
<td colspan="8" class="no-results">
|
||||
<i class="fas fa-user-slash"></i>
|
||||
<h3>没有找到学生信息</h3>
|
||||
<p>请尝试调整筛选条件或添加新学<E696B0><E5ADA6>?/p>
|
||||
</td>
|
||||
</tr>
|
||||
`;
|
||||
return;
|
||||
}
|
||||
|
||||
let tableHTML = '';
|
||||
pageStudents.forEach(student => {
|
||||
tableHTML += `
|
||||
<tr>
|
||||
<td>${student.id}</td>
|
||||
<td>${student.name}</td>
|
||||
<td>${student.gender}</td>
|
||||
<td>${student.class}</td>
|
||||
<td>${student.phone}</td>
|
||||
<td>${student.email}</td>
|
||||
<td>${student.enrollmentDate}</td>
|
||||
<td>
|
||||
<div class="action-buttons-cell">
|
||||
<button class="btn-edit" onclick="editStudent('${student.id}')">
|
||||
<i class="fas fa-edit"></i>
|
||||
编辑
|
||||
</button>
|
||||
<button class="btn-delete" onclick="deleteStudent('${student.id}')">
|
||||
<i class="fas fa-trash"></i>
|
||||
删除
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
`;
|
||||
});
|
||||
|
||||
studentTableBody.innerHTML = tableHTML;
|
||||
}
|
||||
|
||||
// 更新分页控件
|
||||
function updatePagination() {
|
||||
const totalPages = Math.ceil(filteredStudents.length / pageSize);
|
||||
const paginationButtons = pagination.querySelectorAll('button:not(#prev-btn):not(#next-btn)');
|
||||
|
||||
// 更新页码按钮
|
||||
paginationButtons.forEach((btn, index) => {
|
||||
if (index < totalPages) {
|
||||
btn.textContent = index + 1;
|
||||
btn.style.display = 'inline-block';
|
||||
btn.classList.toggle('active', index + 1 === currentPage);
|
||||
} else {
|
||||
btn.style.display = 'none';
|
||||
}
|
||||
});
|
||||
|
||||
// 更新上一<E4B88A><E4B880>?下一页按钮状<E992AE><E78AB6>? prevBtn.disabled = currentPage === 1;
|
||||
nextBtn.disabled = currentPage === totalPages || totalPages === 0;
|
||||
}
|
||||
|
||||
// 筛选学<E98089><E5ADA6>? function filterStudents() {
|
||||
const studentId = document.getElementById('student-id').value.trim();
|
||||
const studentName = document.getElementById('student-name').value.trim();
|
||||
const selectedClass = document.getElementById('class-select').value;
|
||||
const selectedGender = document.getElementById('gender-select').value;
|
||||
|
||||
filteredStudents = mockStudents.filter(student => {
|
||||
const matchesId = !studentId || student.id.includes(studentId);
|
||||
const matchesName = !studentName || student.name.includes(studentName);
|
||||
const matchesClass = !selectedClass || student.class === selectedClass;
|
||||
const matchesGender = !selectedGender || student.gender === selectedGender;
|
||||
|
||||
return matchesId && matchesName && matchesClass && matchesGender;
|
||||
});
|
||||
|
||||
currentPage = 1;
|
||||
renderStudentTable();
|
||||
updatePagination();
|
||||
}
|
||||
|
||||
// 重置筛选条<E98089><E69DA1>? function resetFilters() {
|
||||
document.getElementById('student-id').value = '';
|
||||
document.getElementById('student-name').value = '';
|
||||
document.getElementById('class-select').value = '';
|
||||
document.getElementById('gender-select').value = '';
|
||||
|
||||
filteredStudents = [...mockStudents];
|
||||
currentPage = 1;
|
||||
renderStudentTable();
|
||||
updatePagination();
|
||||
}
|
||||
|
||||
// 添加学生
|
||||
function addStudent() {
|
||||
alert('添加学生功能将在后端API完成后实<E5908E><E5AE9E>?);
|
||||
// 这里可以打开一个模态框来添加学生信<E7949F><E4BFA1>? }
|
||||
|
||||
// 编辑学生
|
||||
function editStudent(studentId) {
|
||||
alert(`编辑学生 ${studentId} 功能将在后端API完成后实现`);
|
||||
// 这里可以打开一个模态框来编辑学生信<E7949F><E4BFA1>? }
|
||||
|
||||
// 删除学生
|
||||
function deleteStudent(studentId) {
|
||||
if (confirm(`确定要删除学号为 ${studentId} 的学生吗?`)) {
|
||||
alert(`删除学生 ${studentId} 功能将在后端API完成后实现`);
|
||||
// 这里可以调用API删除学生
|
||||
}
|
||||
}
|
||||
|
||||
// 导出数据
|
||||
function exportData() {
|
||||
alert('导出数据功能将在后端API完成后实<EFBFBD><EFBFBD>?);
|
||||
// 这里可以调用API导出Excel或CSV文件
|
||||
}
|
||||
|
||||
// 页面切换
|
||||
function goToPage(page) {
|
||||
currentPage = page;
|
||||
renderStudentTable();
|
||||
updatePagination();
|
||||
}
|
||||
|
||||
// 初始化事件监<E4BBB6><E79B91>? function initEventListeners() {
|
||||
searchBtn.addEventListener('click', filterStudents);
|
||||
resetBtn.addEventListener('click', resetFilters);
|
||||
addBtn.addEventListener('click', addStudent);
|
||||
exportBtn.addEventListener('click', exportData);
|
||||
|
||||
prevBtn.addEventListener('click', () => {
|
||||
if (currentPage > 1) {
|
||||
goToPage(currentPage - 1);
|
||||
}
|
||||
});
|
||||
|
||||
nextBtn.addEventListener('click', () => {
|
||||
const totalPages = Math.ceil(filteredStudents.length / pageSize);
|
||||
if (currentPage < totalPages) {
|
||||
goToPage(currentPage + 1);
|
||||
}
|
||||
});
|
||||
|
||||
// 页码按钮点击事件
|
||||
pagination.addEventListener('click', (e) => {
|
||||
if (e.target.tagName === 'BUTTON' &&
|
||||
!e.target.id &&
|
||||
!e.target.classList.contains('active')) {
|
||||
const page = parseInt(e.target.textContent);
|
||||
goToPage(page);
|
||||
}
|
||||
});
|
||||
|
||||
// 输入框回车搜<E8BDA6><E6909C>? document.getElementById('student-id').addEventListener('keypress', (e) => {
|
||||
if (e.key === 'Enter') filterStudents();
|
||||
});
|
||||
|
||||
document.getElementById('student-name').addEventListener('keypress', (e) => {
|
||||
if (e.key === 'Enter') filterStudents();
|
||||
});
|
||||
}
|
||||
|
||||
// 页面加载完成后初始化
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
// 模拟API延迟加载
|
||||
setTimeout(() => {
|
||||
renderStudentTable();
|
||||
updatePagination();
|
||||
initEventListeners();
|
||||
}, 500);
|
||||
});
|
||||
</script>
|
||||
<!-- Bootstrap 5 JS -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="/public/js/admin.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user