first commit
This commit is contained in:
509
frontend/html/user_management.html
Normal file
509
frontend/html/user_management.html
Normal file
@@ -0,0 +1,509 @@
|
||||
<!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="../css/style.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<!-- 导航栏 -->
|
||||
<nav class="navbar">
|
||||
<div class="container">
|
||||
<div class="navbar-brand">
|
||||
<a href="index.html">
|
||||
<i class="fas fa-graduation-cap"></i>
|
||||
<span>XX学校成绩管理系统</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="navbar-menu">
|
||||
<div class="navbar-start">
|
||||
<a href="admin_dashboard.html" class="navbar-item">
|
||||
<i class="fas fa-tachometer-alt"></i>
|
||||
<span>仪表板</span>
|
||||
</a>
|
||||
<a href="user_management.html" class="navbar-item active">
|
||||
<i class="fas fa-users"></i>
|
||||
<span>用户管理</span>
|
||||
</a>
|
||||
<a href="student_management.html" class="navbar-item">
|
||||
<i class="fas fa-user-graduate"></i>
|
||||
<span>学生管理</span>
|
||||
</a>
|
||||
<a href="grade_management.html" 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>管理员</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.html" class="dropdown-item">
|
||||
<i class="fas fa-tachometer-alt"></i>
|
||||
仪表板
|
||||
</a>
|
||||
<a href="#" class="dropdown-item">
|
||||
<i class="fas fa-cog"></i>
|
||||
系统设置
|
||||
</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a href="index.html" class="dropdown-item">
|
||||
<i class="fas fa-sign-out-alt"></i>
|
||||
退出登录
|
||||
</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="index.html">主页</a> >
|
||||
<a href="admin_dashboard.html">管理员仪表板</a> >
|
||||
<span>用户管理</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 筛选区域 -->
|
||||
<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="请输入姓名">
|
||||
</div>
|
||||
<div class="filter-group">
|
||||
<label for="role-select">角色</label>
|
||||
<select id="role-select">
|
||||
<option value="">全部角色</option>
|
||||
<option value="admin">管理员</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="计算机科学与技术1班">计算机科学与技术1班</option>
|
||||
<option value="计算机科学与技术2班">计算机科学与技术2班</option>
|
||||
<option value="软件工程1班">软件工程1班</option>
|
||||
<option value="软件工程2班">软件工程2班</option>
|
||||
<option value="网络工程1班">网络工程1班</option>
|
||||
<option value="网络工程2班">网络工程2班</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动态加载 -->
|
||||
<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>
|
||||
上一页
|
||||
</button>
|
||||
<div id="page-numbers">
|
||||
<button class="active">1</button>
|
||||
<button>2</button>
|
||||
<button>3</button>
|
||||
</div>
|
||||
<button id="next-btn">
|
||||
下一页
|
||||
<i class="fas fa-chevron-right"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<!-- 页脚 -->
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p>© 2023 XX学校成绩管理系统. 版权所有.</p>
|
||||
<p>技术支持: 信息技术中心 | 联系电话: 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: '计算机科学与技术1班',
|
||||
phone: '13800138002',
|
||||
email: 'li.teacher@xxschool.edu.cn',
|
||||
registerTime: '2023-02-10'
|
||||
},
|
||||
{
|
||||
id: 'teacher002',
|
||||
name: '王老师',
|
||||
role: 'teacher',
|
||||
className: '软件工程1班',
|
||||
phone: '13800138003',
|
||||
email: 'wang.teacher@xxschool.edu.cn',
|
||||
registerTime: '2023-02-12'
|
||||
},
|
||||
{
|
||||
id: 'student001',
|
||||
name: '张三',
|
||||
role: 'student',
|
||||
className: '计算机科学与技术1班',
|
||||
phone: '13800138004',
|
||||
email: 'zhangsan@xxschool.edu.cn',
|
||||
registerTime: '2023-03-01'
|
||||
},
|
||||
{
|
||||
id: 'student002',
|
||||
name: '李四',
|
||||
role: 'student',
|
||||
className: '计算机科学与技术1班',
|
||||
phone: '13800138005',
|
||||
email: 'lisi@xxschool.edu.cn',
|
||||
registerTime: '2023-03-01'
|
||||
},
|
||||
{
|
||||
id: 'student003',
|
||||
name: '王五',
|
||||
role: 'student',
|
||||
className: '软件工程1班',
|
||||
phone: '13800138006',
|
||||
email: 'wangwu@xxschool.edu.cn',
|
||||
registerTime: '2023-03-02'
|
||||
},
|
||||
{
|
||||
id: 'student004',
|
||||
name: '赵六',
|
||||
role: 'student',
|
||||
className: '软件工程1班',
|
||||
phone: '13800138007',
|
||||
email: 'zhaoliu@xxschool.edu.cn',
|
||||
registerTime: '2023-03-02'
|
||||
},
|
||||
{
|
||||
id: 'student005',
|
||||
name: '钱七',
|
||||
role: 'student',
|
||||
className: '网络工程1班',
|
||||
phone: '13800138008',
|
||||
email: 'qianqi@xxschool.edu.cn',
|
||||
registerTime: '2023-03-03'
|
||||
},
|
||||
{
|
||||
id: 'student006',
|
||||
name: '孙八',
|
||||
role: 'student',
|
||||
className: '网络工程2班',
|
||||
phone: '13800138009',
|
||||
email: 'sunba@xxschool.edu.cn',
|
||||
registerTime: '2023-03-03'
|
||||
},
|
||||
{
|
||||
id: 'student007',
|
||||
name: '周九',
|
||||
role: 'student',
|
||||
className: '计算机科学与技术2班',
|
||||
phone: '13800138010',
|
||||
email: 'zhoujiu@xxschool.edu.cn',
|
||||
registerTime: '2023-03-04'
|
||||
}
|
||||
];
|
||||
|
||||
// 当前显示的用户数据
|
||||
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');
|
||||
|
||||
// 初始化
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
renderUserTable();
|
||||
setupEventListeners();
|
||||
updatePagination();
|
||||
});
|
||||
|
||||
// 设置事件监听器
|
||||
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>请尝试其他筛选条件或添加新用户</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">管理员</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 || '—'}</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);
|
||||
|
||||
// 更新按钮状态
|
||||
prevBtn.disabled = currentPage === 1;
|
||||
nextBtn.disabled = currentPage === totalPages || totalPages === 0;
|
||||
|
||||
// 更新页码按钮
|
||||
let pageButtonsHTML = '';
|
||||
for (let i = 1; i <= totalPages; i++) {
|
||||
if (i <= 5) { // 最多显示5个页码
|
||||
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筛选
|
||||
if (userId && !user.id.toLowerCase().includes(userId.toLowerCase())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 姓名筛选
|
||||
if (userName && !user.name.toLowerCase().includes(userName.toLowerCase())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 角色筛选
|
||||
if (role && user.role !== role) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 班级筛选
|
||||
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完成后实现');
|
||||
// 这里可以打开一个模态框来添加新用户
|
||||
}
|
||||
|
||||
// 处理导出
|
||||
function handleExport() {
|
||||
alert('导出功能将在后端API完成后实现');
|
||||
// 这里可以导出为Excel或CSV格式
|
||||
}
|
||||
|
||||
// 编辑用户
|
||||
function editUser(userId) {
|
||||
alert(`编辑用户 ${userId} - 功能将在后端API完成后实现`);
|
||||
// 这里可以打开一个模态框来编辑用户信息
|
||||
}
|
||||
|
||||
// 删除用户
|
||||
function deleteUser(userId) {
|
||||
if (confirm(`确定要删除用户 ${userId} 吗?此操作不可撤销。`)) {
|
||||
// 从模拟数据中删除
|
||||
const index = mockUsers.findIndex(user => user.id === userId);
|
||||
if (index !== -1) {
|
||||
mockUsers.splice(index, 1);
|
||||
// 更新当前显示的数据
|
||||
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