refactor(frontend): 重构前端目录结构并优化认证流程
将前端文件从html目录迁移到views目录,按功能模块组织 重构认证中间件和路由处理,简化页面权限控制 更新静态资源引用路径,统一使用/public前缀 添加学生仪表板页面,优化移动端显示 移除旧版html和js文件,更新样式和脚本
This commit is contained in:
342
frontend/views/admin/dashboard.html
Normal file
342
frontend/views/admin/dashboard.html
Normal file
@@ -0,0 +1,342 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>学生成绩管理系统 - 管理员仪表板</title>
|
||||
<link rel="stylesheet" href="/public/css/style.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
|
||||
</head>
|
||||
</head>
|
||||
<body>
|
||||
<!-- 顶部导航<E5AFBC><E888AA>?-->
|
||||
<nav class="navbar">
|
||||
<div class="navbar-brand">
|
||||
<i class="fas fa-graduation-cap"></i>
|
||||
<span>XX学校成绩管理系统</span>
|
||||
</div>
|
||||
<div class="navbar-menu">
|
||||
<a href="/" class="btn btn-secondary">
|
||||
<i class="fas fa-home"></i> 主页
|
||||
</a>
|
||||
<div class="navbar-user">
|
||||
<span class="user-name" id="userName">管理<EFBFBD><EFBFBD>?/span>
|
||||
<button id="logoutBtn" class="btn btn-primary">
|
||||
<i class="fas fa-sign-out-alt"></i> 退<><E98080>? </button>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<!-- 仪表板容<E69DBF><E5AEB9>?-->
|
||||
<div class="dashboard-container">
|
||||
<!-- 左侧侧边<E4BEA7><E8BEB9>?-->
|
||||
<aside class="sidebar">
|
||||
<div class="sidebar-header">
|
||||
<div class="user-info">
|
||||
<div class="user-avatar">
|
||||
<i class="fas fa-user-shield"></i>
|
||||
</div>
|
||||
<div class="user-details">
|
||||
<h3 id="adminName">管理<EFBFBD><EFBFBD>?/h3>
|
||||
<p>系统管理<EFBFBD><EFBFBD>?| 权限<E69D83><E99990>?span id="adminRole">超级管理<E7AEA1><E79086>?/span></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ul class="sidebar-menu">
|
||||
<li>
|
||||
<a href="#" class="active">
|
||||
<i class="fas fa-tachometer-alt"></i>
|
||||
<span>仪表<EFBFBD><EFBFBD>?/span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/admin/user_management">
|
||||
<i class="fas fa-users"></i>
|
||||
<span>用户管理</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/admin/student_management">
|
||||
<i class="fas fa-user-graduate"></i>
|
||||
<span>学生管理</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="teacher_management.html">
|
||||
<i class="fas fa-chalkboard-teacher"></i>
|
||||
<span>教师管理</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="grade_statistics.html">
|
||||
<i class="fas fa-chart-bar"></i>
|
||||
<span>成绩统计</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="system_settings.html">
|
||||
<i class="fas fa-cog"></i>
|
||||
<span>系统设置</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="data_export.html">
|
||||
<i class="fas fa-download"></i>
|
||||
<span>数据导出</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="audit_log.html">
|
||||
<i class="fas fa-history"></i>
|
||||
<span>操作日志</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</aside>
|
||||
|
||||
<!-- 主内容区 -->
|
||||
<main class="main-content">
|
||||
<div class="content-header">
|
||||
<div>
|
||||
<h1 class="page-title">管理员仪表板</h1>
|
||||
<div class="breadcrumb">
|
||||
<a href="/">主页</a>
|
||||
<i class="fas fa-chevron-right"></i>
|
||||
<span>管理员仪表板</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="current-time" id="currentTime"></div>
|
||||
</div>
|
||||
|
||||
<!-- 统计卡片 -->
|
||||
<div class="stats-grid">
|
||||
<div class="stat-card">
|
||||
<div class="stat-icon users">
|
||||
<i class="fas fa-users"></i>
|
||||
</div>
|
||||
<div class="stat-content">
|
||||
<div class="stat-value" id="totalUsers">1,248</div>
|
||||
<div class="stat-label">总用户数</div>
|
||||
<div class="stat-change positive">
|
||||
<i class="fas fa-arrow-up"></i> 12 本周新增
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="stat-card">
|
||||
<div class="stat-icon students">
|
||||
<i class="fas fa-user-graduate"></i>
|
||||
</div>
|
||||
<div class="stat-content">
|
||||
<div class="stat-value" id="totalStudents">3,567</div>
|
||||
<div class="stat-label">学生总数</div>
|
||||
<div class="stat-change positive">
|
||||
<i class="fas fa-arrow-up"></i> 45 本周新增
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="stat-card">
|
||||
<div class="stat-icon teachers">
|
||||
<i class="fas fa-chalkboard-teacher"></i>
|
||||
</div>
|
||||
<div class="stat-content">
|
||||
<div class="stat-value" id="totalTeachers">128</div>
|
||||
<div class="stat-label">教师总数</div>
|
||||
<div class="stat-change">
|
||||
<i class="fas fa-minus"></i> 无变<E697A0><E58F98>? </div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="stat-card">
|
||||
<div class="stat-icon courses">
|
||||
<i class="fas fa-book"></i>
|
||||
</div>
|
||||
<div class="stat-content">
|
||||
<div class="stat-value" id="totalCourses">89</div>
|
||||
<div class="stat-label">课程总数</div>
|
||||
<div class="stat-change positive">
|
||||
<i class="fas fa-arrow-up"></i> 3 本周新增
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 功能卡片 -->
|
||||
<div class="function-grid">
|
||||
<div class="function-card" onclick="window.location.href='user_management.html'">
|
||||
<div class="function-icon">
|
||||
<i class="fas fa-users"></i>
|
||||
</div>
|
||||
<h3 class="function-title">用户管理</h3>
|
||||
<p class="function-description">
|
||||
管理所有用户账户,包括添加、编辑、删除用户,设置用户角色和权限<E69D83><E99990>? </p>
|
||||
<button class="btn btn-primary">进入管理</button>
|
||||
</div>
|
||||
|
||||
<div class="function-card" onclick="window.location.href='student_management.html'">
|
||||
<div class="function-icon">
|
||||
<i class="fas fa-user-graduate"></i>
|
||||
</div>
|
||||
<h3 class="function-title">学生管理</h3>
|
||||
<p class="function-description">
|
||||
管理学生信息,包括学籍管理、班级分配、信息维护和批量导入导出<E5AFBC><E587BA>? </p>
|
||||
<button class="btn btn-primary">进入管理</button>
|
||||
</div>
|
||||
|
||||
<div class="function-card" onclick="window.location.href='teacher_management.html'">
|
||||
<div class="function-icon">
|
||||
<i class="fas fa-chalkboard-teacher"></i>
|
||||
</div>
|
||||
<h3 class="function-title">教师管理</h3>
|
||||
<p class="function-description">
|
||||
管理教师信息,包括教师分配、课程安排、权限设置和绩效考核<E88083><E6A0B8>? </p>
|
||||
<button class="btn btn-primary">进入管理</button>
|
||||
</div>
|
||||
|
||||
<div class="function-card" onclick="window.location.href='grade_statistics.html'">
|
||||
<div class="function-icon">
|
||||
<i class="fas fa-chart-bar"></i>
|
||||
</div>
|
||||
<h3 class="function-title">成绩统计</h3>
|
||||
<p class="function-description">
|
||||
查看全校成绩统计,生成分析报告,支持图表展示和数据导出<E5AFBC><E587BA>? </p>
|
||||
<button class="btn btn-primary">查看统计</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 系统状<E7BB9F><E78AB6>?-->
|
||||
<div class="system-status">
|
||||
<h2 class="section-title">
|
||||
<i class="fas fa-server"></i>
|
||||
系统状<E7BB9F><E78AB6>? </h2>
|
||||
<div class="status-list">
|
||||
<div class="status-item">
|
||||
<div class="status-indicator online"></div>
|
||||
<div>
|
||||
<div class="status-label">数据库服<EFBFBD><EFBFBD>?/div>
|
||||
<div class="status-value">运行正常 | 响应时间: 12ms</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="status-item">
|
||||
<div class="status-indicator online"></div>
|
||||
<div>
|
||||
<div class="status-label">Web服务<EFBFBD><EFBFBD>?/div>
|
||||
<div class="status-value">运行正常 | 在线用户: 156</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="status-item">
|
||||
<div class="status-indicator online"></div>
|
||||
<div>
|
||||
<div class="status-label">文件存储</div>
|
||||
<div class="status-value">使用<EFBFBD><EFBFBD>? 65% | 剩余: 35GB</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="status-item">
|
||||
<div class="status-indicator warning"></div>
|
||||
<div>
|
||||
<div class="status-label">备份服务</div>
|
||||
<div class="status-value">上次备份: 2天前 | 建议立即备份</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 最近活<E8BF91><E6B4BB>?-->
|
||||
<div class="recent-activities">
|
||||
<h2 class="section-title">
|
||||
<i class="fas fa-history"></i>
|
||||
最近活<E8BF91><E6B4BB>? </h2>
|
||||
<ul class="activity-list">
|
||||
<li class="activity-item">
|
||||
<div class="activity-icon">
|
||||
<i class="fas fa-user-plus"></i>
|
||||
</div>
|
||||
<div class="activity-content">
|
||||
<div class="activity-title">新增学生用户</div>
|
||||
<div class="activity-time">10分钟<EFBFBD><EFBFBD>?| 操作<E6938D><E4BD9C>? 管理<E7AEA1><E79086>?/div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="activity-item">
|
||||
<div class="activity-icon">
|
||||
<i class="fas fa-edit"></i>
|
||||
</div>
|
||||
<div class="activity-content">
|
||||
<div class="activity-title">修改教师信息</div>
|
||||
<div class="activity-time">1小时<EFBFBD><EFBFBD>?| 操作<E6938D><E4BD9C>? 管理<E7AEA1><E79086>?/div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="activity-item">
|
||||
<div class="activity-icon">
|
||||
<i class="fas fa-chart-bar"></i>
|
||||
</div>
|
||||
<div class="activity-content">
|
||||
<div class="activity-title">生成成绩统计报告</div>
|
||||
<div class="activity-time">3小时<EFBFBD><EFBFBD>?| 操作<E6938D><E4BD9C>? 系统</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="activity-item">
|
||||
<div class="activity-icon">
|
||||
<i class="fas fa-download"></i>
|
||||
</div>
|
||||
<div class="activity-content">
|
||||
<div class="activity-title">导出用户数据</div>
|
||||
<div class="activity-time">5小时<EFBFBD><EFBFBD>?| 操作<E6938D><E4BD9C>? 管理<E7AEA1><E79086>?/div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="activity-item">
|
||||
<div class="activity-icon">
|
||||
<i class="fas fa-cog"></i>
|
||||
</div>
|
||||
<div class="activity-content">
|
||||
<div class="activity-title">系统设置更新</div>
|
||||
<div class="activity-time">1天前 | 操作<E6938D><E4BD9C>? 管理<E7AEA1><E79086>?/div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// 更新当前时间
|
||||
function updateCurrentTime() {
|
||||
const now = new Date();
|
||||
const options = {
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
day: 'numeric',
|
||||
weekday: 'long',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
second: '2-digit'
|
||||
};
|
||||
document.getElementById('currentTime').textContent = now.toLocaleDateString('zh-CN', options);
|
||||
}
|
||||
|
||||
// 页面加载时初始化
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
updateCurrentTime();
|
||||
setInterval(updateCurrentTime, 1000);
|
||||
|
||||
// 退出登<E587BA><E799BB>? document.getElementById('logoutBtn').addEventListener('click', function() {
|
||||
if (confirm('确定要退出登录吗<E5BD95><E59097>?)) {
|
||||
// 清除登录状<E5BD95><E78AB6>? localStorage.removeItem('token');
|
||||
localStorage.removeItem('userRole');
|
||||
localStorage.removeItem('userInfo');
|
||||
|
||||
// 跳转到登录页<E5BD95><E9A1B5>? window.location.href = 'login.html';
|
||||
}
|
||||
});
|
||||
|
||||
// 加载用户信息
|
||||
const userInfo = JSON.parse(localStorage.getItem('userInfo') || '{}');
|
||||
if (userInfo.name) {
|
||||
document.getElementById('adminName').textContent = userInfo.name;
|
||||
document.getElementById('userName').textContent = userInfo.name;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
441
frontend/views/admin/student_management.html
Normal file
441
frontend/views/admin/student_management.html
Normal file
@@ -0,0 +1,441 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<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">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<!-- 导航<E5AFBC><E888AA>?-->
|
||||
<nav class="navbar">
|
||||
<div class="container">
|
||||
<div class="navbar-brand">
|
||||
<a href="/">
|
||||
<i class="fas fa-graduation-cap"></i>
|
||||
<span>XX学校成绩管理系统</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">
|
||||
<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>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<!-- 主要内容<E58685><E5AEB9>?-->
|
||||
<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>
|
||||
</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>
|
||||
导出数据
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 学生表格 -->
|
||||
<div class="table-responsive">
|
||||
<table class="student-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>学号</th>
|
||||
<th>姓名</th>
|
||||
<th>性别</th>
|
||||
<th>班级</th>
|
||||
<th>联系电话</th>
|
||||
<th>邮箱</th>
|
||||
<th>入学时间</th>
|
||||
<th>操作</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>
|
||||
</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>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<!-- 页脚 -->
|
||||
<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>
|
||||
</body>
|
||||
</html>
|
||||
494
frontend/views/admin/user_management.html
Normal file
494
frontend/views/admin/user_management.html
Normal file
@@ -0,0 +1,494 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<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">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<!-- 导航<E5AFBC><E888AA>?-->
|
||||
<nav class="navbar">
|
||||
<div class="container">
|
||||
<div class="navbar-brand">
|
||||
<a href="/">
|
||||
<i class="fas fa-graduation-cap"></i>
|
||||
<span>XX学校成绩管理系统</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="navbar-menu">
|
||||
<div class="navbar-start">
|
||||
<a href="/admin/dashboard" class="navbar-item">
|
||||
<i class="fas fa-tachometer-alt"></i>
|
||||
<span>仪表<EFBFBD><EFBFBD>?/span>
|
||||
</a>
|
||||
<a href="/admin/user_management" class="navbar-item active">
|
||||
<i class="fas fa-users"></i>
|
||||
<span>用户管理</span>
|
||||
</a>
|
||||
<a href="/admin/student_management" class="navbar-item">
|
||||
<i class="fas fa-user-graduate"></i>
|
||||
<span>学生管理</span>
|
||||
</a>
|
||||
<a href="/teacher/grade_management" class="navbar-item">
|
||||
<i class="fas fa-chart-bar"></i>
|
||||
<span>成绩统计</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="navbar-end">
|
||||
<div class="navbar-item user-info">
|
||||
<i class="fas fa-user-circle"></i>
|
||||
<span>管理<EFBFBD><EFBFBD>?/span>
|
||||
<div class="dropdown">
|
||||
<a href="#" class="dropdown-toggle">
|
||||
<i class="fas fa-caret-down"></i>
|
||||
</a>
|
||||
<div class="dropdown-menu">
|
||||
<a href="/admin/dashboard" class="dropdown-item">
|
||||
<i class="fas fa-tachometer-alt"></i>
|
||||
仪表<E4BBAA><E8A1A8>? </a>
|
||||
<a href="#" class="dropdown-item">
|
||||
<i class="fas fa-cog"></i>
|
||||
系统设置
|
||||
</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a href="/" class="dropdown-item">
|
||||
<i class="fas fa-sign-out-alt"></i>
|
||||
退出登<E587BA><E799BB>? </a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<!-- 主内容区 -->
|
||||
<main class="main-content">
|
||||
<div class="container">
|
||||
<div class="user-management">
|
||||
<!-- 页面标题和面包屑导航 -->
|
||||
<div class="page-header">
|
||||
<h1>用户管理</h1>
|
||||
<div class="breadcrumb">
|
||||
<a href="/">主页</a> >
|
||||
<a href="/admin/dashboard">管理员仪表板</a> >
|
||||
<span>用户管理</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 筛选区<E98089><E58CBA>?-->
|
||||
<div class="filter-section">
|
||||
<form class="filter-form" id="filter-form">
|
||||
<div class="filter-group">
|
||||
<label for="user-id">用户ID</label>
|
||||
<input type="text" id="user-id" placeholder="请输入用户ID">
|
||||
</div>
|
||||
<div class="filter-group">
|
||||
<label for="user-name">姓名</label>
|
||||
<input type="text" id="user-name" placeholder="请输入姓<E585A5><E5A793>?>
|
||||
</div>
|
||||
<div class="filter-group">
|
||||
<label for="role-select">角色</label>
|
||||
<select id="role-select">
|
||||
<option value="">全部角色</option>
|
||||
<option value="admin">管理<EFBFBD><EFBFBD>?/option>
|
||||
<option value="teacher">教师</option>
|
||||
<option value="student">学生</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="filter-group">
|
||||
<label for="class-select">班级</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-actions">
|
||||
<button type="button" class="btn-add" id="add-btn">
|
||||
<i class="fas fa-plus"></i>
|
||||
添加用户
|
||||
</button>
|
||||
<button type="button" class="btn-search" id="search-btn">
|
||||
<i class="fas fa-search"></i>
|
||||
查询
|
||||
</button>
|
||||
<button type="button" class="btn-reset" id="reset-btn">
|
||||
<i class="fas fa-redo"></i>
|
||||
重置
|
||||
</button>
|
||||
<button type="button" class="btn-export" id="export-btn">
|
||||
<i class="fas fa-file-export"></i>
|
||||
导出
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- 结果区域 -->
|
||||
<div class="table-container">
|
||||
<table class="user-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>用户ID</th>
|
||||
<th>姓名</th>
|
||||
<th>角色</th>
|
||||
<th>班级</th>
|
||||
<th>联系电话</th>
|
||||
<th>邮箱</th>
|
||||
<th>注册时间</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="user-table-body">
|
||||
<!-- 数据将通过JavaScript动态加<E68081><E58AA0>?-->
|
||||
<tr>
|
||||
<td colspan="8" class="loading">
|
||||
<i class="fas fa-spinner fa-spin"></i>
|
||||
<p>正在加载用户数据...</p>
|
||||
</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>
|
||||
<div id="page-numbers">
|
||||
<button class="active">1</button>
|
||||
<button>2</button>
|
||||
<button>3</button>
|
||||
</div>
|
||||
<button id="next-btn">
|
||||
下一<E4B88B><E4B880>? <i class="fas fa-chevron-right"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<!-- 页脚 -->
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p>© 2023 XX学校成绩管理系统. 版权所<E69D83><E68980>?</p>
|
||||
<p>技术支<EFBFBD><EFBFBD>? 信息技术中<E69CAF><E4B8AD>?| 联系电话: 010-12345678</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<!-- JavaScript -->
|
||||
<script>
|
||||
// 模拟用户数据
|
||||
const mockUsers = [
|
||||
{
|
||||
id: 'admin001',
|
||||
name: '张管理员',
|
||||
role: 'admin',
|
||||
className: '',
|
||||
phone: '13800138001',
|
||||
email: 'admin@xxschool.edu.cn',
|
||||
registerTime: '2023-01-15'
|
||||
},
|
||||
{
|
||||
id: 'teacher001',
|
||||
name: '李老师',
|
||||
role: 'teacher',
|
||||
className: '计算机科学与技<E4B88E><E68A80>?<3F><>?,
|
||||
phone: '13800138002',
|
||||
email: 'li.teacher@xxschool.edu.cn',
|
||||
registerTime: '2023-02-10'
|
||||
},
|
||||
{
|
||||
id: 'teacher002',
|
||||
name: '王老师',
|
||||
role: 'teacher',
|
||||
className: '软件工程1<EFBFBD><EFBFBD>?,
|
||||
phone: '13800138003',
|
||||
email: 'wang.teacher@xxschool.edu.cn',
|
||||
registerTime: '2023-02-12'
|
||||
},
|
||||
{
|
||||
id: 'student001',
|
||||
name: '张三',
|
||||
role: 'student',
|
||||
className: '计算机科学与技<E4B88E><E68A80>?<3F><>?,
|
||||
phone: '13800138004',
|
||||
email: 'zhangsan@xxschool.edu.cn',
|
||||
registerTime: '2023-03-01'
|
||||
},
|
||||
{
|
||||
id: 'student002',
|
||||
name: '李四',
|
||||
role: 'student',
|
||||
className: '计算机科学与技<EFBFBD><EFBFBD>?<EFBFBD><EFBFBD>?,
|
||||
phone: '13800138005',
|
||||
email: 'lisi@xxschool.edu.cn',
|
||||
registerTime: '2023-03-01'
|
||||
},
|
||||
{
|
||||
id: 'student003',
|
||||
name: '王五',
|
||||
role: 'student',
|
||||
className: '软件工程1<E7A88B><31>?,
|
||||
phone: '13800138006',
|
||||
email: 'wangwu@xxschool.edu.cn',
|
||||
registerTime: '2023-03-02'
|
||||
},
|
||||
{
|
||||
id: 'student004',
|
||||
name: '赵六',
|
||||
role: 'student',
|
||||
className: '软件工程1<EFBFBD><EFBFBD>?,
|
||||
phone: '13800138007',
|
||||
email: 'zhaoliu@xxschool.edu.cn',
|
||||
registerTime: '2023-03-02'
|
||||
},
|
||||
{
|
||||
id: 'student005',
|
||||
name: '钱七',
|
||||
role: 'student',
|
||||
className: '网络工程1<E7A88B><31>?,
|
||||
phone: '13800138008',
|
||||
email: 'qianqi@xxschool.edu.cn',
|
||||
registerTime: '2023-03-03'
|
||||
},
|
||||
{
|
||||
id: 'student006',
|
||||
name: '孙八',
|
||||
role: 'student',
|
||||
className: '网络工程2<EFBFBD><EFBFBD>?,
|
||||
phone: '13800138009',
|
||||
email: 'sunba@xxschool.edu.cn',
|
||||
registerTime: '2023-03-03'
|
||||
},
|
||||
{
|
||||
id: 'student007',
|
||||
name: '周九',
|
||||
role: 'student',
|
||||
className: '计算机科学与技<E4B88E><E68A80>?<3F><>?,
|
||||
phone: '13800138010',
|
||||
email: 'zhoujiu@xxschool.edu.cn',
|
||||
registerTime: '2023-03-04'
|
||||
}
|
||||
];
|
||||
|
||||
// 当前显示的用户数<E688B7><E695B0>? let currentUsers = [...mockUsers];
|
||||
let currentPage = 1;
|
||||
const usersPerPage = 5;
|
||||
|
||||
// DOM元素
|
||||
const userTableBody = document.getElementById('user-table-body');
|
||||
const pagination = document.getElementById('pagination');
|
||||
const prevBtn = document.getElementById('prev-btn');
|
||||
const nextBtn = document.getElementById('next-btn');
|
||||
const pageNumbers = document.getElementById('page-numbers');
|
||||
const searchBtn = document.getElementById('search-btn');
|
||||
const resetBtn = document.getElementById('reset-btn');
|
||||
const addBtn = document.getElementById('add-btn');
|
||||
const exportBtn = document.getElementById('export-btn');
|
||||
const userIdInput = document.getElementById('user-id');
|
||||
const userNameInput = document.getElementById('user-name');
|
||||
const roleSelect = document.getElementById('role-select');
|
||||
const classSelect = document.getElementById('class-select');
|
||||
|
||||
// 初始<E5889D><E5A78B>? document.addEventListener('DOMContentLoaded', function() {
|
||||
renderUserTable();
|
||||
setupEventListeners();
|
||||
updatePagination();
|
||||
});
|
||||
|
||||
// 设置事件监听<E79B91><E590AC>? function setupEventListeners() {
|
||||
searchBtn.addEventListener('click', handleSearch);
|
||||
resetBtn.addEventListener('click', handleReset);
|
||||
addBtn.addEventListener('click', handleAddUser);
|
||||
exportBtn.addEventListener('click', handleExport);
|
||||
prevBtn.addEventListener('click', goToPrevPage);
|
||||
nextBtn.addEventListener('click', goToNextPage);
|
||||
}
|
||||
|
||||
// 渲染用户表格
|
||||
function renderUserTable() {
|
||||
if (currentUsers.length === 0) {
|
||||
userTableBody.innerHTML = `
|
||||
<tr>
|
||||
<td colspan="8" class="no-results">
|
||||
<i class="fas fa-user-slash"></i>
|
||||
<h3>没有找到用户</h3>
|
||||
<p>请尝试其他筛选条件或添加新用<E696B0><E794A8>?/p>
|
||||
</td>
|
||||
</tr>
|
||||
`;
|
||||
return;
|
||||
}
|
||||
|
||||
// 计算当前页的用户
|
||||
const startIndex = (currentPage - 1) * usersPerPage;
|
||||
const endIndex = startIndex + usersPerPage;
|
||||
const pageUsers = currentUsers.slice(startIndex, endIndex);
|
||||
|
||||
let tableHTML = '';
|
||||
pageUsers.forEach(user => {
|
||||
// 角色徽章
|
||||
let roleBadge = '';
|
||||
if (user.role === 'admin') {
|
||||
roleBadge = '<span class="role-badge role-admin">管理<EFBFBD><EFBFBD>?/span>';
|
||||
} else if (user.role === 'teacher') {
|
||||
roleBadge = '<span class="role-badge role-teacher">教师</span>';
|
||||
} else {
|
||||
roleBadge = '<span class="role-badge role-student">学生</span>';
|
||||
}
|
||||
|
||||
tableHTML += `
|
||||
<tr>
|
||||
<td>${user.id}</td>
|
||||
<td>${user.name}</td>
|
||||
<td>${roleBadge}</td>
|
||||
<td>${user.className || '<27><>?}</td>
|
||||
<td>${user.phone}</td>
|
||||
<td>${user.email}</td>
|
||||
<td>${user.registerTime}</td>
|
||||
<td>
|
||||
<div class="action-buttons-cell">
|
||||
<button class="btn-edit" onclick="editUser('${user.id}')">
|
||||
<i class="fas fa-edit"></i>
|
||||
编辑
|
||||
</button>
|
||||
<button class="btn-delete" onclick="deleteUser('${user.id}')">
|
||||
<i class="fas fa-trash"></i>
|
||||
删除
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
`;
|
||||
});
|
||||
|
||||
userTableBody.innerHTML = tableHTML;
|
||||
}
|
||||
|
||||
// 更新分页
|
||||
function updatePagination() {
|
||||
const totalPages = Math.ceil(currentUsers.length / usersPerPage);
|
||||
|
||||
// 更新按钮状<E992AE><E78AB6>? prevBtn.disabled = currentPage === 1;
|
||||
nextBtn.disabled = currentPage === totalPages || totalPages === 0;
|
||||
|
||||
// 更新页码按钮
|
||||
let pageButtonsHTML = '';
|
||||
for (let i = 1; i <= totalPages; i++) {
|
||||
if (i <= 5) { // 最多显<E5A49A><E698BE>?个页<E4B8AA><E9A1B5>? pageButtonsHTML += `<button class="${i === currentPage ? 'active' : ''}" onclick="goToPage(${i})">${i}</button>`;
|
||||
}
|
||||
}
|
||||
pageNumbers.innerHTML = pageButtonsHTML;
|
||||
}
|
||||
|
||||
// 处理搜索
|
||||
function handleSearch() {
|
||||
const userId = userIdInput.value.trim();
|
||||
const userName = userNameInput.value.trim();
|
||||
const role = roleSelect.value;
|
||||
const className = classSelect.value;
|
||||
|
||||
currentUsers = mockUsers.filter(user => {
|
||||
// 用户ID筛<44><E7AD9B>? if (userId && !user.id.toLowerCase().includes(userId.toLowerCase())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 姓名筛<E5908D><E7AD9B>? if (userName && !user.name.toLowerCase().includes(userName.toLowerCase())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 角色筛<E889B2><E7AD9B>? if (role && user.role !== role) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 班级筛<E7BAA7><E7AD9B>? if (className && user.className !== className) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
currentPage = 1;
|
||||
renderUserTable();
|
||||
updatePagination();
|
||||
}
|
||||
|
||||
// 处理重置
|
||||
function handleReset() {
|
||||
userIdInput.value = '';
|
||||
userNameInput.value = '';
|
||||
roleSelect.value = '';
|
||||
classSelect.value = '';
|
||||
|
||||
currentUsers = [...mockUsers];
|
||||
currentPage = 1;
|
||||
renderUserTable();
|
||||
updatePagination();
|
||||
}
|
||||
|
||||
// 处理添加用户
|
||||
function handleAddUser() {
|
||||
alert('添加用户功能将在后端API完成后实<E5908E><E5AE9E>?);
|
||||
// 这里可以打开一个模态框来添加新用户
|
||||
}
|
||||
|
||||
// 处理导出
|
||||
function handleExport() {
|
||||
alert('导出功能将在后端API完成后实<EFBFBD><EFBFBD>?);
|
||||
// 这里可以导出为Excel或CSV格式
|
||||
}
|
||||
|
||||
// 编辑用户
|
||||
function editUser(userId) {
|
||||
alert(`编辑用户 ${userId} - 功能将在后端API完成后实现`);
|
||||
// 这里可以打开一个模态框来编辑用户信<E688B7><E4BFA1>? }
|
||||
|
||||
// 删除用户
|
||||
function deleteUser(userId) {
|
||||
if (confirm(`确定要删除用<EFBFBD><EFBFBD>?${userId} 吗?此操作不可撤销。`)) {
|
||||
// 从模拟数据中删除
|
||||
const index = mockUsers.findIndex(user => user.id === userId);
|
||||
if (index !== -1) {
|
||||
mockUsers.splice(index, 1);
|
||||
// 更新当前显示的数<E79A84><E695B0>? handleSearch();
|
||||
alert('用户删除成功');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 分页函数
|
||||
function goToPage(page) {
|
||||
currentPage = page;
|
||||
renderUserTable();
|
||||
updatePagination();
|
||||
}
|
||||
|
||||
function goToPrevPage() {
|
||||
if (currentPage > 1) {
|
||||
currentPage--;
|
||||
renderUserTable();
|
||||
updatePagination();
|
||||
}
|
||||
}
|
||||
|
||||
function goToNextPage() {
|
||||
const totalPages = Math.ceil(currentUsers.length / usersPerPage);
|
||||
if (currentPage < totalPages) {
|
||||
currentPage++;
|
||||
renderUserTable();
|
||||
updatePagination();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user