bcf2c71fad
将前端文件从html目录迁移到views目录,按功能模块组织 重构认证中间件和路由处理,简化页面权限控制 更新静态资源引用路径,统一使用/public前缀 添加学生仪表板页面,优化移动端显示 移除旧版html和js文件,更新样式和脚本
442 lines
18 KiB
HTML
442 lines
18 KiB
HTML
<!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>
|