refactor(frontend): 重构前端目录结构并优化认证流程
将前端文件从html目录迁移到views目录,按功能模块组织 重构认证中间件和路由处理,简化页面权限控制 更新静态资源引用路径,统一使用/public前缀 添加学生仪表板页面,优化移动端显示 移除旧版html和js文件,更新样式和脚本
This commit is contained in:
@@ -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>
|
||||
<!-- 憿園�撖潸⏛�?-->
|
||||
<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">蝞∠��?/span>
|
||||
<button id="logoutBtn" class="btn btn-primary">
|
||||
<i class="fas fa-sign-out-alt"></i> ���? </button>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<!-- 隞芾”�踹捆�?-->
|
||||
<div class="dashboard-container">
|
||||
<!-- 撌虫儒靘扯器�?-->
|
||||
<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">蝞∠��?/h3>
|
||||
<p>蝟餌�蝞∠��?| ���嚗?span id="adminRole">頞�漣蝞∠��?/span></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ul class="sidebar-menu">
|
||||
<li>
|
||||
<a href="#" class="active">
|
||||
<i class="fas fa-tachometer-alt"></i>
|
||||
<span>隞芾”�?/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> �惩��? </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">
|
||||
蝞∠����厩鍂�瑁揭�瘀���𡠺瘛餃����颲㻫����斤鍂�瘀�霈曄蔭�冽�閫坿𠧧�峕��僐�? </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">
|
||||
蝞∠�摮衣�靽⊥�嚗���砍郎蝐滨恣����号蝥批��溻��縑�舐輕�文��寥�撖澆�撖澆枂�? </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">
|
||||
蝞∠��坔�靽⊥�嚗���祆�撣���溻��紋蝔见��鉝����鞱挽蝵桀�蝏拇���瓲�? </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">
|
||||
�亦��冽嵗�鞟貍蝏蠘恣嚗𣬚��𣂼��鞉𥁒�𠺪��舀��曇”撅閧內�峕㺭�桀紡�箝�? </p>
|
||||
<button class="btn btn-primary">�亦�蝏蠘恣</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 蝟餌��嗆�?-->
|
||||
<div class="system-status">
|
||||
<h2 class="section-title">
|
||||
<i class="fas fa-server"></i>
|
||||
蝟餌��嗆�? </h2>
|
||||
<div class="status-list">
|
||||
<div class="status-item">
|
||||
<div class="status-indicator online"></div>
|
||||
<div>
|
||||
<div class="status-label">�唳旿摨𤘪��?/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�滚𦛚�?/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">雿輻鍂�? 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>
|
||||
|
||||
<!-- ��餈烐暑�?-->
|
||||
<div class="recent-activities">
|
||||
<h2 class="section-title">
|
||||
<i class="fas fa-history"></i>
|
||||
��餈烐暑�? </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����?| �滢�鈭? 蝞∠��?/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撠𤩺𧒄�?| �滢�鈭? 蝞∠��?/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撠𤩺𧒄�?| �滢�鈭? 蝟餌�</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撠𤩺𧒄�?| �滢�鈭? 蝞∠��?/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憭拙� | �滢�鈭? 蝞∠��?/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);
|
||||
|
||||
// ���箇蒈敶? document.getElementById('logoutBtn').addEventListener('click', function() {
|
||||
if (confirm('蝖桀�閬����箇蒈敶訫�嚗?)) {
|
||||
// 皜�膄�餃��嗆�? localStorage.removeItem('token');
|
||||
localStorage.removeItem('userRole');
|
||||
localStorage.removeItem('userInfo');
|
||||
|
||||
// 頝唾蓮�啁蒈敶閖△�? 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>
|
||||
@@ -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>
|
||||
<!-- 撖潸⏛�?-->
|
||||
<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>�批��X踎</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>蝞∠��?/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> ���箇蒈敶?/a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<!-- 銝餉���捆�?-->
|
||||
<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>
|
||||
|
||||
<!-- 蝑偦�匧躹�?-->
|
||||
<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="霂瑁��亙郎�?>
|
||||
</div>
|
||||
<div class="filter-group">
|
||||
<label for="student-name"><i class="fas fa-user"></i> 憪枏�</label>
|
||||
<input type="text" id="student-name" placeholder="霂瑁��亙��?>
|
||||
</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="霈∠��箇�摮虫����?�?>霈∠��箇�摮虫����?�?/option>
|
||||
<option value="霈∠��箇�摮虫����?�?>霈∠��箇�摮虫����?�?/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-group">
|
||||
<label for="gender-select"><i class="fas fa-venus-mars"></i> �批�</label>
|
||||
<select id="gender-select">
|
||||
<option value="">�券��批�</option>
|
||||
<option value="�?>�?/option>
|
||||
<option value="憟?>憟?/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�冽���頧?-->
|
||||
<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>
|
||||
<button class="active">1</button>
|
||||
<button>2</button>
|
||||
<button>3</button>
|
||||
<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>���舀𣈲�? 霈∠��箇�摮虫����臬郎�?/p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<script>
|
||||
// 璅⊥�摮衣��唳旿
|
||||
const mockStudents = [
|
||||
{
|
||||
id: '20230001',
|
||||
name: '撘牐�',
|
||||
gender: '�?,
|
||||
class: '霈∠��箇�摮虫����?�?,
|
||||
phone: '13800138001',
|
||||
email: 'zhangsan@example.com',
|
||||
enrollmentDate: '2023-09-01'
|
||||
},
|
||||
{
|
||||
id: '20230002',
|
||||
name: '�𤾸�',
|
||||
gender: '憟?,
|
||||
class: '霈∠��箇�摮虫����?�?,
|
||||
phone: '13800138002',
|
||||
email: 'lisi@example.com',
|
||||
enrollmentDate: '2023-09-01'
|
||||
},
|
||||
{
|
||||
id: '20230003',
|
||||
name: '�衤�',
|
||||
gender: '�?,
|
||||
class: '霈∠��箇�摮虫����?�?,
|
||||
phone: '13800138003',
|
||||
email: 'wangwu@example.com',
|
||||
enrollmentDate: '2023-09-01'
|
||||
},
|
||||
{
|
||||
id: '20230004',
|
||||
name: '韏萄�',
|
||||
gender: '憟?,
|
||||
class: '頧臭辣撌亦�1�?,
|
||||
phone: '13800138004',
|
||||
email: 'zhaoliu@example.com',
|
||||
enrollmentDate: '2023-09-01'
|
||||
},
|
||||
{
|
||||
id: '20230005',
|
||||
name: '�曹�',
|
||||
gender: '�?,
|
||||
class: '頧臭辣撌亦�2�?,
|
||||
phone: '13800138005',
|
||||
email: 'qianqi@example.com',
|
||||
enrollmentDate: '2023-09-01'
|
||||
},
|
||||
{
|
||||
id: '20230006',
|
||||
name: '摮坔�',
|
||||
gender: '�?,
|
||||
class: '蝵𤑳�撌亦�1�?,
|
||||
phone: '13800138006',
|
||||
email: 'sunba@example.com',
|
||||
enrollmentDate: '2023-09-01'
|
||||
},
|
||||
{
|
||||
id: '20230007',
|
||||
name: '�其�',
|
||||
gender: '憟?,
|
||||
class: '蝵𤑳�撌亦�2�?,
|
||||
phone: '13800138007',
|
||||
email: 'zhoujiu@example.com',
|
||||
enrollmentDate: '2023-09-01'
|
||||
},
|
||||
{
|
||||
id: '20230008',
|
||||
name: '�游�',
|
||||
gender: '�?,
|
||||
class: '霈∠��箇�摮虫����?�?,
|
||||
phone: '13800138008',
|
||||
email: 'wushi@example.com',
|
||||
enrollmentDate: '2023-09-01'
|
||||
}
|
||||
];
|
||||
|
||||
// 敶枏�憿菜㺭�? 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>霂瑕�霂閗��渡��㗇辺隞嗆�瘛餃��啣郎�?/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';
|
||||
}
|
||||
});
|
||||
|
||||
// �湔鰵銝𠹺�憿?銝衤�憿菜��桃𠶖�? prevBtn.disabled = currentPage === 1;
|
||||
nextBtn.disabled = currentPage === totalPages || totalPages === 0;
|
||||
}
|
||||
|
||||
// 蝑偦�匧郎�? 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();
|
||||
}
|
||||
|
||||
// �滨蔭蝑偦�㗇辺隞? 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摰峕��𤾸��?);
|
||||
// 餈䠷��臭誑�枏�銝�銝芣芋����交溶�惩郎�煺縑�? }
|
||||
|
||||
// 蝻𤥁�摮衣�
|
||||
function editStudent(studentId) {
|
||||
alert(`蝻𤥁�摮衣� ${studentId} �蠘�撠�銁�𡒊垢API摰峕��𤾸��躬);
|
||||
// 餈䠷��臭誑�枏�銝�銝芣芋����亦�颲穃郎�煺縑�? }
|
||||
|
||||
// �𣳇膄摮衣�
|
||||
function deleteStudent(studentId) {
|
||||
if (confirm(`蝖桀�閬���文郎�瑚蛹 ${studentId} ��郎�笔�嚗鬮)) {
|
||||
alert(`�𣳇膄摮衣� ${studentId} �蠘�撠�銁�𡒊垢API摰峕��𤾸��躬);
|
||||
// 餈䠷��臭誑靚�鍂API�𣳇膄摮衣�
|
||||
}
|
||||
}
|
||||
|
||||
// 撖澆枂�唳旿
|
||||
function exportData() {
|
||||
alert('撖澆枂�唳旿�蠘�撠�銁�𡒊垢API摰峕��𤾸��?);
|
||||
// 餈䠷��臭誑靚�鍂API撖澆枂Excel�𥟟SV��辣
|
||||
}
|
||||
|
||||
// 憿菟𢒰��揢
|
||||
function goToPage(page) {
|
||||
currentPage = page;
|
||||
renderStudentTable();
|
||||
updatePagination();
|
||||
}
|
||||
|
||||
// �嘥��碶�隞嗥��? 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);
|
||||
}
|
||||
});
|
||||
|
||||
// 颲枏�獢��頧行�蝝? 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>
|
||||
@@ -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>
|
||||
<!-- 撖潸⏛�?-->
|
||||
<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>隞芾”�?/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>蝞∠��?/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>
|
||||
隞芾”�? </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>
|
||||
���箇蒈敶? </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>
|
||||
|
||||
<!-- 蝑偦�匧躹�?-->
|
||||
<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="霂瑁��亦鍂�弒D">
|
||||
</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="霈∠��箇�摮虫����?�?>霈∠��箇�摮虫����?�?/option>
|
||||
<option value="霈∠��箇�摮虫����?�?>霈∠��箇�摮虫����?�?/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: '霈∠��箇�摮虫����?�?,
|
||||
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: '霈∠��箇�摮虫����?�?,
|
||||
phone: '13800138004',
|
||||
email: 'zhangsan@xxschool.edu.cn',
|
||||
registerTime: '2023-03-01'
|
||||
},
|
||||
{
|
||||
id: 'student002',
|
||||
name: '�𤾸�',
|
||||
role: 'student',
|
||||
className: '霈∠��箇�摮虫����?�?,
|
||||
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: '霈∠��箇�摮虫����?�?,
|
||||
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) { // ��憭𡁏遬蝷?銝芷△�? 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摰峕��𤾸��?);
|
||||
// 餈䠷��臭誑撖澆枂銝慟xcel�𥟟SV�澆�
|
||||
}
|
||||
|
||||
// 蝻𤥁��冽�
|
||||
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