refactor(frontend): 重构前端目录结构并优化认证流程
将前端文件从html目录迁移到views目录,按功能模块组织 重构认证中间件和路由处理,简化页面权限控制 更新静态资源引用路径,统一使用/public前缀 添加学生仪表板页面,优化移动端显示 移除旧版html和js文件,更新样式和脚本
This commit is contained in:
@@ -0,0 +1,507 @@
|
||||
<!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>
|
||||
/* 隞芾”�踹�撅� */
|
||||
.dashboard-container {
|
||||
display: flex;
|
||||
min-height: calc(100vh - 80px);
|
||||
}
|
||||
|
||||
/* 靘扯器�?*/
|
||||
.sidebar {
|
||||
width: 250px;
|
||||
background: linear-gradient(180deg, #43e97b 0%, #38f9d7 100%);
|
||||
color: white;
|
||||
padding: 30px 0;
|
||||
position: sticky;
|
||||
top: 80px;
|
||||
height: calc(100vh - 80px);
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.sidebar-header {
|
||||
padding: 0 25px 30px;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.user-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 15px;
|
||||
}
|
||||
|
||||
.user-avatar {
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
border-radius: 50%;
|
||||
background: white;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #43e97b;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.user-details h3 {
|
||||
margin: 0 0 5px;
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
|
||||
.user-details p {
|
||||
margin: 0;
|
||||
font-size: 0.9rem;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.sidebar-menu {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.sidebar-menu li {
|
||||
margin: 5px 0;
|
||||
}
|
||||
|
||||
.sidebar-menu a {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 15px;
|
||||
padding: 15px 25px;
|
||||
color: white;
|
||||
text-decoration: none;
|
||||
transition: all 0.3s ease;
|
||||
border-left: 3px solid transparent;
|
||||
}
|
||||
|
||||
.sidebar-menu a:hover {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border-left-color: white;
|
||||
}
|
||||
|
||||
.sidebar-menu a.active {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
border-left-color: white;
|
||||
}
|
||||
|
||||
.sidebar-menu i {
|
||||
width: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* 銝餃�摰孵躹 */
|
||||
.main-content {
|
||||
flex: 1;
|
||||
padding: 30px;
|
||||
background: #f8f9ff;
|
||||
}
|
||||
|
||||
.content-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.page-title {
|
||||
font-size: 1.8rem;
|
||||
color: #333;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.breadcrumb {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
color: #666;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.breadcrumb a {
|
||||
color: #43e97b;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.breadcrumb i {
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
/* �蠘��∠� */
|
||||
.function-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
||||
gap: 25px;
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
|
||||
.function-card {
|
||||
background: white;
|
||||
border-radius: 15px;
|
||||
padding: 30px;
|
||||
text-align: center;
|
||||
box-shadow: 0 5px 20px rgba(0, 0, 0, 0.05);
|
||||
transition: all 0.3s ease;
|
||||
cursor: pointer;
|
||||
border: 2px solid transparent;
|
||||
}
|
||||
|
||||
.function-card:hover {
|
||||
transform: translateY(-5px);
|
||||
box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
|
||||
border-color: #43e97b;
|
||||
}
|
||||
|
||||
.function-icon {
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
border-radius: 50%;
|
||||
background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin: 0 auto 20px;
|
||||
font-size: 32px;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.function-title {
|
||||
font-size: 1.3rem;
|
||||
color: #333;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.function-description {
|
||||
color: #666;
|
||||
line-height: 1.5;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
/* 敹恍���雿?*/
|
||||
.quick-actions {
|
||||
background: white;
|
||||
border-radius: 15px;
|
||||
padding: 25px;
|
||||
margin-bottom: 30px;
|
||||
box-shadow: 0 5px 20px rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 1.4rem;
|
||||
color: #333;
|
||||
margin-bottom: 20px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.section-title i {
|
||||
color: #43e97b;
|
||||
}
|
||||
|
||||
.action-buttons {
|
||||
display: flex;
|
||||
gap: 15px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.action-btn {
|
||||
padding: 12px 25px;
|
||||
background: #f8f9ff;
|
||||
border: 1px solid #e0e0e0;
|
||||
border-radius: 10px;
|
||||
color: #333;
|
||||
text-decoration: none;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.action-btn:hover {
|
||||
background: #43e97b;
|
||||
color: white;
|
||||
border-color: #43e97b;
|
||||
}
|
||||
|
||||
/* ��餈烐暑�?*/
|
||||
.recent-activities {
|
||||
background: white;
|
||||
border-radius: 15px;
|
||||
padding: 25px;
|
||||
box-shadow: 0 5px 20px rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.activity-list {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.activity-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 15px;
|
||||
padding: 15px 0;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
|
||||
.activity-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.activity-icon {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: 50%;
|
||||
background: #f8f9ff;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #43e97b;
|
||||
}
|
||||
|
||||
.activity-content {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.activity-title {
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.activity-time {
|
||||
font-size: 0.9rem;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
/* �滚�撘讛挽霈?*/
|
||||
@media (max-width: 992px) {
|
||||
.dashboard-container {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
position: static;
|
||||
padding: 20px 0;
|
||||
}
|
||||
|
||||
.sidebar-menu {
|
||||
display: flex;
|
||||
overflow-x: auto;
|
||||
padding: 0 20px;
|
||||
}
|
||||
|
||||
.sidebar-menu li {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.sidebar-menu a {
|
||||
padding: 10px 15px;
|
||||
border-left: none;
|
||||
border-bottom: 3px solid transparent;
|
||||
}
|
||||
|
||||
.sidebar-menu a:hover,
|
||||
.sidebar-menu a.active {
|
||||
border-left-color: transparent;
|
||||
border-bottom-color: white;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.main-content {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.content-header {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 15px;
|
||||
}
|
||||
|
||||
.function-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.action-buttons {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.action-btn {
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</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-chalkboard-teacher"></i>
|
||||
</div>
|
||||
<div class="user-details">
|
||||
<h3 id="teacherName">�舘���</h3>
|
||||
<p>�坔� | �券秄嚗?span id="teacherDept">霈∠��箏郎�?/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="/teacher/grade_entry">
|
||||
<i class="fas fa-edit"></i>
|
||||
<span>�鞟貍敶訫�</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="grade_query.html">
|
||||
<i class="fas fa-search"></i>
|
||||
<span>�鞟貍�亥砭</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="grade_manage.html">
|
||||
<i class="fas fa-cog"></i>
|
||||
<span>�鞟貍蝞∠�</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#">
|
||||
<i class="fas fa-chart-bar"></i>
|
||||
<span>蝏蠘恣���</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#">
|
||||
<i class="fas fa-download"></i>
|
||||
<span>�唳旿撖澆枂</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#">
|
||||
<i class="fas fa-user"></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="function-grid">
|
||||
<div class="function-card" onclick="window.location.href='grade_entry.html'">
|
||||
<div class="function-icon">
|
||||
<i class="fas fa-edit"></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_query.html'">
|
||||
<div class="function-icon">
|
||||
<i class="fas fa-search"></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_manage.html'">
|
||||
<div class="function-icon">
|
||||
<i class="fas fa-cog"></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='#'">
|
||||
<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="quick-actions">
|
||||
<h2 class="section-title">
|
||||
<i class="fas fa-bolt"></i>
|
||||
敹恍���雿? </h2>
|
||||
<div class="action-buttons">
|
||||
<a href="/teacher/grade_entry" class="action-btn">
|
||||
<i class="fas fa-plus"></i>
|
||||
敶訫��唳�蝏? </a>
|
||||
<a href="grade_query.html" class="action-btn">
|
||||
<i class="fas fa-search"></i>
|
||||
�亥砭�鞟貍
|
||||
</a>
|
||||
<a href="#" class="action-btn">
|
||||
<i class="fas fa-download"></i>
|
||||
撖澆枂�鞟貍�? </a>
|
||||
<a href="#" class="action-btn">
|
||||
<i class="fas fa-chart-pie"></i>
|
||||
���蝏蠘恣�亙�
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ��餈烐暑�
|
||||
@@ -0,0 +1,447 @@
|
||||
<!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="navbar-brand">
|
||||
<a href="/"><i class="fas fa-graduation-cap"></i> XX摮行嵗�鞟貍蝞∠�蝟餌�</a>
|
||||
</div>
|
||||
<div class="navbar-menu">
|
||||
<a href="/teacher/dashboard" class="navbar-item"><i class="fas fa-tachometer-alt"></i> �坔�隞芾”�?/a>
|
||||
<a href="/teacher/grade_entry" class="navbar-item active"><i class="fas fa-edit"></i> �鞟貍敶訫�</a>
|
||||
<a href="/teacher/grade_management" class="navbar-item"><i class="fas fa-list"></i> �鞟貍蝞∠�</a>
|
||||
<div class="user-info">
|
||||
<span class="user-name">�舘���</span>
|
||||
<span class="user-role">�坔�</span>
|
||||
<a href="/login" class="btn btn-outline btn-small"><i class="fas fa-sign-out-alt"></i> ���?/a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<!-- �W�撅穃紡�?-->
|
||||
<div class="container">
|
||||
<div class="breadcrumb">
|
||||
<a href="/">銝駁△</a>
|
||||
<i class="fas fa-chevron-right"></i>
|
||||
<a href="/teacher/dashboard">�坔�隞芾”�?/a>
|
||||
<i class="fas fa-chevron-right"></i>
|
||||
<span>�鞟貍敶訫�</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 銝餃�摰孵躹 -->
|
||||
<div class="grade-entry-container">
|
||||
<div class="entry-header">
|
||||
<h1><i class="fas fa-edit"></i> �鞟貍敶訫�</h1>
|
||||
<p>霂琿�㗇𥋘�剔漣�諹紋蝔页��嗅�銝箸�銝芸郎�笔��交�蝏?/p>
|
||||
</div>
|
||||
|
||||
<div class="entry-form">
|
||||
<div class="form-row">
|
||||
<div class="form-group">
|
||||
<label for="class-select"><i class="fas fa-users"></i> �㗇𥋘�剔漣</label>
|
||||
<select id="class-select" class="form-control">
|
||||
<option value="">霂琿�㗇𥋘�剔漣</option>
|
||||
<option value="class1">霈∠��箇�摮虫����?021蝥?�?/option>
|
||||
<option value="class2">霈∠��箇�摮虫����?021蝥?�?/option>
|
||||
<option value="class3">頧臭辣撌亦�2021蝥?�?/option>
|
||||
<option value="class4">頧臭辣撌亦�2021蝥?�?/option>
|
||||
<option value="class5">蝵𤑳�撌亦�2021蝥?�?/option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="course-name"><i class="fas fa-book"></i> 霂曄��滨妍</label>
|
||||
<input type="text" id="course-name" placeholder="霂瑁��亥紋蝔见�蝘堆�憒���唳旿蝏𤘪����雿𦦵頂蝏毺�">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="exam-date"><i class="fas fa-calendar-alt"></i> ����交�</label>
|
||||
<input type="date" id="exam-date">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label><i class="fas fa-info-circle"></i> 憭�釣霂湔�嚗�虾�㚁�</label>
|
||||
<textarea id="remarks" rows="3" placeholder="�航��交𧋦甈∟�����秩�𦒘縑�荔�憒���煺葉�������怨���蝑?></textarea>
|
||||
</div>
|
||||
|
||||
<div class="students-table-container">
|
||||
<h3><i class="fas fa-user-graduate"></i> 摮衣��鞟貍敶訫�</h3>
|
||||
<p class="text-muted">�㗇𥋘�剔漣�𠬍�蝟餌�撠�䌊�典�頧質砲�剔漣��郎�笔�銵?/p>
|
||||
|
||||
<div id="students-loading" class="loading" style="display: none;">
|
||||
<i class="fas fa-spinner"></i>
|
||||
<p>甇�銁�㰘蝸摮衣��𡑒”...</p>
|
||||
</div>
|
||||
|
||||
<div id="no-students" class="no-students" style="display: none;">
|
||||
<i class="fas fa-user-slash"></i>
|
||||
<p>霂亦号蝥扳��惩郎��㺭�殷�霂瑕�瘛餃�摮衣�靽⊥�</p>
|
||||
</div>
|
||||
|
||||
<table id="students-table" class="students-table" style="display: none;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>摮血噡</th>
|
||||
<th>憪枏�</th>
|
||||
<th>撟單𧒄�鞟貍</th>
|
||||
<th>�煺葉�鞟貍</th>
|
||||
<th>��錰�鞟貍</th>
|
||||
<th>�餉��鞟貍</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="students-tbody">
|
||||
<!-- 摮衣��唳旿撠��朞�JavaScript�冽���頧?-->
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
<button id="cancel-btn" class="btn btn-secondary btn-large">
|
||||
<i class="fas fa-times"></i> �𡝗�
|
||||
</button>
|
||||
<button id="submit-btn" class="btn btn-primary btn-large" disabled>
|
||||
<i class="fas fa-check"></i> �𣂷漱�鞟貍
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<h3><i class="fas fa-lightbulb"></i> 雿輻鍂霂湔�</h3>
|
||||
<ul class="text-muted">
|
||||
<li>擐硋��㗇𥋘閬���交�蝏拍��剔漣�諹紋蝔?/li>
|
||||
<li>蝟餌�隡朞䌊�典�頧質砲�剔漣��郎�笔�銵?/li>
|
||||
<li>銝箸�銝芸郎�蠘��亙像�嗆�蝏押���銝剜�蝏拙���錰�鞟貍</li>
|
||||
<li>�餉��鞟貍撠�覔�格��滩䌊�刻恣蝞梹�暺䁅恕���嚗𡁜像�?0%嚗峕�銝?0%嚗峕��?0%嚗?/li>
|
||||
<li>蝖株恕�㰘秤�𡒊��領�𨀣�鈭斗�蝏抽�脲��桐�摮䀹㺭�?/li>
|
||||
<li>�𣂷漱�𤾸虾隞亙銁�𨀣�蝏拍恣���嗪△�X䰻�见�靽格㺿撌脣��亦��鞟貍</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- JavaScript -->
|
||||
<script>
|
||||
// 璅⊥�摮衣��唳旿
|
||||
const mockStudents = [
|
||||
{ id: '2021001', name: '撘牐�', usual: '', midterm: '', final: '', total: '' },
|
||||
{ id: '2021002', name: '�𤾸�', usual: '', midterm: '', final: '', total: '' },
|
||||
{ id: '2021003', name: '�衤�', usual: '', midterm: '', final: '', total: '' },
|
||||
{ id: '2021004', name: '韏萄�', usual: '', midterm: '', final: '', total: '' },
|
||||
{ id: '2021005', name: '�曹�', usual: '', midterm: '', final: '', total: '' },
|
||||
{ id: '2021006', name: '摮坔�', usual: '', midterm: '', final: '', total: '' },
|
||||
{ id: '2021007', name: '�其�', usual: '', midterm: '', final: '', total: '' },
|
||||
{ id: '2021008', name: '�游�', usual: '', midterm: '', final: '', total: '' }
|
||||
];
|
||||
|
||||
// DOM���
|
||||
const classSelect = document.getElementById('class-select');
|
||||
const courseNameInput = document.getElementById('course-name');
|
||||
const examDateInput = document.getElementById('exam-date');
|
||||
const remarksInput = document.getElementById('remarks');
|
||||
const studentsLoading = document.getElementById('students-loading');
|
||||
const noStudents = document.getElementById('no-students');
|
||||
const studentsTable = document.getElementById('students-table');
|
||||
const studentsTbody = document.getElementById('students-tbody');
|
||||
const cancelBtn = document.getElementById('cancel-btn');
|
||||
const submitBtn = document.getElementById('submit-btn');
|
||||
|
||||
// 霈曄蔭暺䁅恕����交�銝箔�憭? const today = new Date().toISOString().split('T')[0];
|
||||
examDateInput.value = today;
|
||||
|
||||
// �剔漣�㗇𥋘�睃�鈭衤辣
|
||||
classSelect.addEventListener('change', function() {
|
||||
const selectedClass = this.value;
|
||||
|
||||
if (!selectedClass) {
|
||||
hideStudentsTable();
|
||||
submitBtn.disabled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// �曄內�㰘蝸�嗆�? showLoading();
|
||||
|
||||
// 璅⊥�API靚�鍂撱嗉�
|
||||
setTimeout(() => {
|
||||
loadStudentsForClass(selectedClass);
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
// �㰘蝸摮衣��唳旿
|
||||
function loadStudentsForClass(className) {
|
||||
// 璅⊥�API�滚�
|
||||
if (mockStudents.length > 0) {
|
||||
renderStudentsTable(mockStudents);
|
||||
} else {
|
||||
showNoStudents();
|
||||
}
|
||||
}
|
||||
|
||||
// 皜脫�摮衣�銵冽聢
|
||||
function renderStudentsTable(students) {
|
||||
hideLoading();
|
||||
|
||||
// 皜�征銵冽聢
|
||||
studentsTbody.innerHTML = '';
|
||||
|
||||
// 瘛餃�摮衣�銵? students.forEach((student, index) => {
|
||||
const row = document.createElement('tr');
|
||||
row.innerHTML = `
|
||||
<td>${student.id}</td>
|
||||
<td>${student.name}</td>
|
||||
<td>
|
||||
<input type="number" class="grade-input usual-grade"
|
||||
data-index="${index}" min="0" max="100"
|
||||
placeholder="0-100" value="${student.usual}">
|
||||
</td>
|
||||
<td>
|
||||
<input type="number" class="grade-input midterm-grade"
|
||||
data-index="${index}" min="0" max="100"
|
||||
placeholder="0-100" value="${student.midterm}">
|
||||
</td>
|
||||
<td>
|
||||
<input type="number" class="grade-input final-grade"
|
||||
data-index="${index}" min="0" max="100"
|
||||
placeholder="0-100" value="${student.final}">
|
||||
</td>
|
||||
<td>
|
||||
<span class="total-grade" data-index="${index}">${student.total || ''}</span>
|
||||
</td>
|
||||
`;
|
||||
|
||||
studentsTbody.appendChild(row);
|
||||
});
|
||||
|
||||
// �曄內銵冽聢
|
||||
studentsTable.style.display = 'table';
|
||||
noStudents.style.display = 'none';
|
||||
|
||||
// �舐鍂�𣂷漱�厰僼
|
||||
submitBtn.disabled = false;
|
||||
|
||||
// 瘛餃��鞟貍颲枏�鈭衤辣�穃𨯬
|
||||
addGradeInputListeners();
|
||||
}
|
||||
|
||||
// �曄內�㰘蝸�嗆�? function showLoading() {
|
||||
studentsLoading.style.display = 'block';
|
||||
studentsTable.style.display = 'none';
|
||||
noStudents.style.display = 'none';
|
||||
}
|
||||
|
||||
// �鞱��㰘蝸�嗆�? function hideLoading() {
|
||||
studentsLoading.style.display = 'none';
|
||||
}
|
||||
|
||||
// �曄內�惩郎��㺭�? function showNoStudents() {
|
||||
hideLoading();
|
||||
studentsTable.style.display = 'none';
|
||||
noStudents.style.display = 'block';
|
||||
}
|
||||
|
||||
// �鞱�摮衣�銵冽聢
|
||||
function hideStudentsTable() {
|
||||
studentsTable.style.display = 'none';
|
||||
noStudents.style.display = 'none';
|
||||
}
|
||||
|
||||
// 瘛餃��鞟貍颲枏�鈭衤辣�穃𨯬
|
||||
function addGradeInputListeners() {
|
||||
const usualGrades = document.querySelectorAll('.usual-grade');
|
||||
const midtermGrades = document.querySelectorAll('.midterm-grade');
|
||||
const finalGrades = document.querySelectorAll('.final-grade');
|
||||
|
||||
usualGrades.forEach(input => {
|
||||
input.addEventListener('input', calculateTotalGrade);
|
||||
});
|
||||
|
||||
midtermGrades.forEach(input => {
|
||||
input.addEventListener('input', calculateTotalGrade);
|
||||
});
|
||||
|
||||
finalGrades.forEach(input => {
|
||||
input.addEventListener('input', calculateTotalGrade);
|
||||
});
|
||||
}
|
||||
|
||||
// 霈∠��餉��鞟貍
|
||||
function calculateTotalGrade(event) {
|
||||
const input = event.target;
|
||||
const index = input.getAttribute('data-index');
|
||||
|
||||
// �瑕�銝劐葵�鞟貍
|
||||
const usualInput = document.querySelector(`.usual-grade[data-index="${index}"]`);
|
||||
const midtermInput = document.querySelector(`.midterm-grade[data-index="${index}"]`);
|
||||
const finalInput = document.querySelector(`.final-grade[data-index="${index}"]`);
|
||||
const totalSpan = document.querySelector(`.total-grade[data-index="${index}"]`);
|
||||
|
||||
const usual = parseFloat(usualInput.value) || 0;
|
||||
const midterm = parseFloat(midtermInput.value) || 0;
|
||||
const final = parseFloat(finalInput.value) || 0;
|
||||
|
||||
// 霈∠��餉��鞟貍嚗���㵪�撟單𧒄20%嚗峕�銝?0%嚗峕��?0%嚗? const total = (usual * 0.2) + (midterm * 0.3) + (final * 0.5);
|
||||
|
||||
// �曄內�餉��鞟貍嚗���滢��亙��湔㺭嚗? totalSpan.textContent = Math.round(total);
|
||||
|
||||
// �寞旿�鞟貍��凒霈曄蔭憸𡏭𠧧
|
||||
if (total >= 90) {
|
||||
totalSpan.style.color = '#38a169';
|
||||
totalSpan.style.fontWeight = 'bold';
|
||||
} else if (total >= 60) {
|
||||
totalSpan.style.color = '#d69e2e';
|
||||
totalSpan.style.fontWeight = 'normal';
|
||||
} else {
|
||||
totalSpan.style.color = '#e53e3e';
|
||||
totalSpan.style.fontWeight = 'bold';
|
||||
}
|
||||
}
|
||||
|
||||
// 銵典�撉諹�
|
||||
function validateForm() {
|
||||
const className = classSelect.value;
|
||||
const courseName = courseNameInput.value.trim();
|
||||
|
||||
if (!className) {
|
||||
alert('霂琿�㗇𥋘�剔漣');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!courseName) {
|
||||
alert('霂瑁��亥紋蝔见�蝘?);
|
||||
courseNameInput.focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
// 璉��交糓�行�摮衣��鞟貍�芸‵�? const usualGrades = document.querySelectorAll('.usual-grade');
|
||||
const midtermGrades = document.querySelectorAll('.midterm-grade');
|
||||
const finalGrades = document.querySelectorAll('.final-grade');
|
||||
|
||||
for (let i = 0; i < usualGrades.length; i++) {
|
||||
const usual = usualGrades[i].value.trim();
|
||||
const midterm = midtermGrades[i].value.trim();
|
||||
const final = finalGrades[i].value.trim();
|
||||
|
||||
if (!usual || !midterm || !final) {
|
||||
alert(`霂瑕‵�嗵洵${i + 1}銵�郎�毺����㗇�蝏奈);
|
||||
return false;
|
||||
}
|
||||
|
||||
const usualNum = parseFloat(usual);
|
||||
const midtermNum = parseFloat(midterm);
|
||||
const finalNum = parseFloat(final);
|
||||
|
||||
if (usualNum < 0 || usualNum > 100 ||
|
||||
midtermNum < 0 || midtermNum > 100 ||
|
||||
finalNum < 0 || finalNum > 100) {
|
||||
alert(`蝚?{i + 1}銵�郎�毺��鞟貍敹�◆�?-100銋钅𡢿`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// �園�銵典��唳旿
|
||||
function collectFormData() {
|
||||
const className = classSelect.options[classSelect.selectedIndex].text;
|
||||
const courseName = courseNameInput.value.trim();
|
||||
const examDate = examDateInput.value;
|
||||
const remarks = remarksInput.value.trim();
|
||||
|
||||
const grades = [];
|
||||
const rows = studentsTbody.querySelectorAll('tr');
|
||||
|
||||
rows.forEach((row, index) => {
|
||||
const studentId = row.cells[0].textContent;
|
||||
const studentName = row.cells[1].textContent;
|
||||
const usual = row.cells[2].querySelector('input').value;
|
||||
const midterm = row.cells[3].querySelector('input').value;
|
||||
const final = row.cells[4].querySelector('input').value;
|
||||
const total = row.cells[5].querySelector('span').textContent;
|
||||
|
||||
grades.push({
|
||||
studentId,
|
||||
studentName,
|
||||
usual: parseFloat(usual),
|
||||
midterm: parseFloat(midterm),
|
||||
final: parseFloat(final),
|
||||
total: parseFloat(total)
|
||||
});
|
||||
});
|
||||
|
||||
return {
|
||||
className,
|
||||
courseName,
|
||||
examDate,
|
||||
remarks,
|
||||
grades
|
||||
};
|
||||
}
|
||||
|
||||
// �𣂷漱銵典�
|
||||
function submitForm() {
|
||||
if (!validateForm()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const formData = collectFormData();
|
||||
|
||||
// �曄內�𣂷漱銝剔𠶖�? submitBtn.innerHTML = '<i class="fas fa-spinner fa-spin"></i> �𣂷漱銝?..';
|
||||
submitBtn.disabled = true;
|
||||
|
||||
// 璅⊥�API靚�鍂
|
||||
setTimeout(() => {
|
||||
// 璅⊥��𣂼��滚�
|
||||
alert(`�鞟貍�𣂷漱�𣂼�嚗�n�剔漣嚗?{formData.className}\n霂曄�嚗?{formData.courseName}\n�勗��?{formData.grades.length}�滚郎���蝏奈);
|
||||
|
||||
// �滨蔭�厰僼�嗆�? submitBtn.innerHTML = '<i class="fas fa-check"></i> �𣂷漱�鞟貍';
|
||||
submitBtn.disabled = false;
|
||||
|
||||
// �滨蔭銵典�
|
||||
resetForm();
|
||||
}, 1500);
|
||||
}
|
||||
|
||||
// �滨蔭銵典�
|
||||
function resetForm() {
|
||||
classSelect.value = '';
|
||||
courseNameInput.value = '';
|
||||
examDateInput.value = today;
|
||||
remarksInput.value = '';
|
||||
|
||||
// 皜�征摮衣�銵冽聢
|
||||
studentsTbody.innerHTML = '';
|
||||
studentsTable.style.display = 'none';
|
||||
noStudents.style.display = 'none';
|
||||
|
||||
// 蝳�鍂�𣂷漱�厰僼
|
||||
submitBtn.disabled = true;
|
||||
}
|
||||
|
||||
// �𡝗��厰僼鈭衤辣
|
||||
cancelBtn.addEventListener('click', function() {
|
||||
if (confirm('蝖桀�閬��瘨��嚗���㗇𧊋靽嘥���凒�孵�隡帋腺憭晞�?)) {
|
||||
resetForm();
|
||||
}
|
||||
});
|
||||
|
||||
// �𣂷漱�厰僼鈭衤辣
|
||||
submitBtn.addEventListener('click', submitForm);
|
||||
|
||||
// 憿菟𢒰�㰘蝸�嗅�憪见�
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// 璉��交糓�行�敹����㺭�? if (!classSelect.value) {
|
||||
submitBtn.disabled = true;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,574 @@
|
||||
<!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.4.0/css/all.min.css">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<!-- 撖潸⏛�?-->
|
||||
<nav class="navbar">
|
||||
<div class="nav-container">
|
||||
<div class="nav-brand">
|
||||
<a href="/">
|
||||
<i class="fas fa-graduation-cap"></i>
|
||||
<span>XX摮行嵗�鞟貍蝞∠�蝟餌�</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="nav-menu">
|
||||
<a href="/teacher/dashboard" class="nav-link">
|
||||
<i class="fas fa-tachometer-alt"></i>
|
||||
<span>�坔�隞芾”�?/span>
|
||||
</a>
|
||||
<a href="/teacher/grade_entry" class="nav-link">
|
||||
<i class="fas fa-edit"></i>
|
||||
<span>�鞟貍敶訫�</span>
|
||||
</a>
|
||||
<a href="/teacher/grade_management" class="nav-link active">
|
||||
<i class="fas fa-search"></i>
|
||||
<span>�鞟貍蝞∠�</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="nav-user">
|
||||
<div class="user-info">
|
||||
<i class="fas fa-user-circle"></i>
|
||||
<span>撘㰘���</span>
|
||||
</div>
|
||||
<a href="/login" class="btn-logout">
|
||||
<i class="fas fa-sign-out-alt"></i>
|
||||
<span>���?/span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<!-- 銝餃�摰孵躹 -->
|
||||
<main class="main-content">
|
||||
<div class="container">
|
||||
<!-- �W�撅穃紡�?-->
|
||||
<div class="breadcrumb">
|
||||
<a href="/">銝駁△</a>
|
||||
<i class="fas fa-chevron-right"></i>
|
||||
<a href="/teacher/dashboard">�坔�隞芾”�?/a>
|
||||
<i class="fas fa-chevron-right"></i>
|
||||
<span>�鞟貍�亥砭/蝞∠�</span>
|
||||
</div>
|
||||
|
||||
<!-- 憿菟𢒰��� -->
|
||||
<div class="page-header">
|
||||
<h1 class="page-title">�鞟貍�亥砭/蝞∠�</h1>
|
||||
<p class="page-description">�亥砭��耨�孵��𣳇膄摮衣��鞟貍霈啣�</p>
|
||||
</div>
|
||||
|
||||
<!-- 蝑偦�匧躹�?-->
|
||||
<div class="filter-section">
|
||||
<h2 class="filter-title">
|
||||
<i class="fas fa-filter"></i>
|
||||
蝑偦�㗇辺隞? </h2>
|
||||
<div class="filter-form">
|
||||
<div class="form-group">
|
||||
<label for="class-select">�剔漣</label>
|
||||
<select id="class-select" class="form-control">
|
||||
<option value="">�券��剔漣</option>
|
||||
<option value="class1">霈∠��箇�摮虫����?�?/option>
|
||||
<option value="class2">霈∠��箇�摮虫����?�?/option>
|
||||
<option value="class3">頧臭辣撌亦�1�?/option>
|
||||
<option value="class4">頧臭辣撌亦�2�?/option>
|
||||
<option value="class5">蝵𤑳�撌亦�1�?/option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="course-select">霂曄�</label>
|
||||
<select id="course-select" class="form-control">
|
||||
<option value="">�券�霂曄�</option>
|
||||
<option value="course1">�唳旿蝏𤘪�</option>
|
||||
<option value="course2">�滢�蝟餌�</option>
|
||||
<option value="course3">霈∠��箇�蝏?/option>
|
||||
<option value="course4">�唳旿摨梶頂蝏?/option>
|
||||
<option value="course5">頧臭辣撌亦�</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="student-id">摮衣�摮血噡</label>
|
||||
<input type="text" id="student-id" class="form-control" placeholder="颲枏�摮衣�摮血噡">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="student-name">摮衣�憪枏�</label>
|
||||
<input type="text" id="student-name" class="form-control" placeholder="颲枏�摮衣�憪枏�">
|
||||
</div>
|
||||
<div class="filter-actions">
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 蝏𤘪��箏� -->
|
||||
<div class="results-section">
|
||||
<div class="results-header">
|
||||
<h2 class="results-title">�亥砭蝏𤘪�</h2>
|
||||
<div class="results-actions">
|
||||
<button id="export-btn" class="btn-export">
|
||||
<i class="fas fa-file-export"></i>
|
||||
撖澆枂�鞟貍
|
||||
</button>
|
||||
<button id="batch-delete-btn" class="btn-batch-delete">
|
||||
<i class="fas fa-trash-alt"></i>
|
||||
�寥��𣳇膄
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="grade-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><input type="checkbox" id="select-all"></th>
|
||||
<th>摮血噡</th>
|
||||
<th>憪枏�</th>
|
||||
<th>�剔漣</th>
|
||||
<th>霂曄�</th>
|
||||
<th>撟單𧒄�鞟貍</th>
|
||||
<th>�煺葉�鞟貍</th>
|
||||
<th>��錰�鞟貍</th>
|
||||
<th>�餉��鞟貍</th>
|
||||
<th>蝑厩漣</th>
|
||||
<th>�滢�</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="grade-table-body">
|
||||
<!-- �唳旿撠��朞�JavaScript�冽���頧?-->
|
||||
<tr>
|
||||
<td colspan="11" class="loading">
|
||||
<i class="fas fa-spinner fa-spin"></i>
|
||||
<p>甇�銁�㰘蝸�鞟貍�唳旿...</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- ��△ -->
|
||||
<div class="pagination">
|
||||
<button id="prev-page" disabled>銝𠹺�憿?/button>
|
||||
<button class="active">1</button>
|
||||
<button>2</button>
|
||||
<button>3</button>
|
||||
<button id="next-page">銝衤�憿?/button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<!-- 憿菔� -->
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p>© 2023 XX摮行嵗�鞟貍蝞∠�蝟餌�. ������?</p>
|
||||
<p>���舀𣈲�? 霈∠��箇�摮虫����臬郎�?/p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<script>
|
||||
// 璅⊥��鞟貍�唳旿
|
||||
const mockGrades = [
|
||||
{
|
||||
id: 1,
|
||||
studentId: "20230001",
|
||||
studentName: "撘牐�",
|
||||
className: "霈∠��箇�摮虫����?�?,
|
||||
courseName: "�唳旿蝏𤘪�",
|
||||
regularScore: 85,
|
||||
midtermScore: 88,
|
||||
finalScore: 90,
|
||||
totalScore: 88.5,
|
||||
grade: "隡条�"
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
studentId: "20230002",
|
||||
studentName: "�𤾸�",
|
||||
className: "霈∠��箇�摮虫����?�?,
|
||||
courseName: "�唳旿蝏𤘪�",
|
||||
regularScore: 78,
|
||||
midtermScore: 82,
|
||||
finalScore: 85,
|
||||
totalScore: 82.3,
|
||||
grade: "�臬末"
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
studentId: "20230003",
|
||||
studentName: "�衤�",
|
||||
className: "霈∠��箇�摮虫����?�?,
|
||||
courseName: "�滢�蝟餌�",
|
||||
regularScore: 92,
|
||||
midtermScore: 88,
|
||||
finalScore: 95,
|
||||
totalScore: 91.8,
|
||||
grade: "隡条�"
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
studentId: "20230004",
|
||||
studentName: "韏萄�",
|
||||
className: "霈∠��箇�摮虫����?�?,
|
||||
courseName: "�滢�蝟餌�",
|
||||
regularScore: 65,
|
||||
midtermScore: 70,
|
||||
finalScore: 68,
|
||||
totalScore: 67.9,
|
||||
grade: "�𦠜聢"
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
studentId: "20230005",
|
||||
studentName: "�曹�",
|
||||
className: "頧臭辣撌亦�1�?,
|
||||
courseName: "�唳旿摨梶頂蝏?,
|
||||
regularScore: 88,
|
||||
midtermScore: 85,
|
||||
finalScore: 90,
|
||||
totalScore: 87.9,
|
||||
grade: "�臬末"
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
studentId: "20230006",
|
||||
studentName: "摮坔�",
|
||||
className: "頧臭辣撌亦�1�?,
|
||||
courseName: "�唳旿摨梶頂蝏?,
|
||||
regularScore: 75,
|
||||
midtermScore: 78,
|
||||
finalScore: 80,
|
||||
totalScore: 78.1,
|
||||
grade: "銝剔�"
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
studentId: "20230007",
|
||||
studentName: "�其�",
|
||||
className: "頧臭辣撌亦�2�?,
|
||||
courseName: "頧臭辣撌亦�",
|
||||
regularScore: 90,
|
||||
midtermScore: 92,
|
||||
finalScore: 88,
|
||||
totalScore: 89.6,
|
||||
grade: "隡条�"
|
||||
},
|
||||
{
|
||||
id: 8,
|
||||
studentId: "20230008",
|
||||
studentName: "�游�",
|
||||
className: "頧臭辣撌亦�2�?,
|
||||
courseName: "頧臭辣撌亦�",
|
||||
regularScore: 82,
|
||||
midtermScore: 85,
|
||||
finalScore: 87,
|
||||
totalScore: 85.1,
|
||||
grade: "�臬末"
|
||||
}
|
||||
];
|
||||
|
||||
// DOM���
|
||||
const searchBtn = document.getElementById('search-btn');
|
||||
const resetBtn = document.getElementById('reset-btn');
|
||||
const exportBtn = document.getElementById('export-btn');
|
||||
const batchDeleteBtn = document.getElementById('batch-delete-btn');
|
||||
const selectAllCheckbox = document.getElementById('select-all');
|
||||
const gradeTableBody = document.getElementById('grade-table-body');
|
||||
const classSelect = document.getElementById('class-select');
|
||||
const courseSelect = document.getElementById('course-select');
|
||||
const studentIdInput = document.getElementById('student-id');
|
||||
const studentNameInput = document.getElementById('student-name');
|
||||
|
||||
// 敶枏��劐葉���蝏呼D
|
||||
let selectedGradeIds = new Set();
|
||||
|
||||
// �嘥��㚚△�? function initPage() {
|
||||
renderGradeTable(mockGrades);
|
||||
setupEventListeners();
|
||||
updateSelectedCount();
|
||||
}
|
||||
|
||||
// 皜脫��鞟貍銵冽聢
|
||||
function renderGradeTable(grades) {
|
||||
if (grades.length === 0) {
|
||||
gradeTableBody.innerHTML = `
|
||||
<tr>
|
||||
<td colspan="11" class="no-results">
|
||||
<i class="fas fa-search"></i>
|
||||
<h3>�芣𪄳�啁㮾�單�蝏抵扇敶?/h3>
|
||||
<p>霂瑕�霂閗��渡��㗇辺隞嗆�瘛餃��啁��鞟貍霈啣�</p>
|
||||
</td>
|
||||
</tr>
|
||||
`;
|
||||
return;
|
||||
}
|
||||
|
||||
let tableHTML = '';
|
||||
|
||||
grades.forEach(grade => {
|
||||
// �寞旿�鞟貍蝖桀�CSS蝐? let gradeClass = 'grade-cell';
|
||||
if (grade.totalScore >= 90) {
|
||||
gradeClass += ' grade-excellent';
|
||||
} else if (grade.totalScore >= 80) {
|
||||
gradeClass += ' grade-good';
|
||||
} else if (grade.totalScore < 60) {
|
||||
gradeClass += ' grade-poor';
|
||||
}
|
||||
|
||||
// �寞旿�餉��鞟貍蝖桀�蝑厩漣
|
||||
let gradeLevel = grade.grade;
|
||||
|
||||
tableHTML += `
|
||||
<tr data-grade-id="${grade.id}">
|
||||
<td>
|
||||
<input type="checkbox" class="grade-checkbox" data-id="${grade.id}">
|
||||
</td>
|
||||
<td>${grade.studentId}</td>
|
||||
<td>${grade.studentName}</td>
|
||||
<td>${grade.className}</td>
|
||||
<td>${grade.courseName}</td>
|
||||
<td>${grade.regularScore}</td>
|
||||
<td>${grade.midtermScore}</td>
|
||||
<td>${grade.finalScore}</td>
|
||||
<td class="${gradeClass}">${grade.totalScore.toFixed(1)}</td>
|
||||
<td>${gradeLevel}</td>
|
||||
<td>
|
||||
<div class="action-buttons">
|
||||
<button class="btn-edit" onclick="editGrade(${grade.id})">
|
||||
<i class="fas fa-edit"></i> 靽格㺿
|
||||
</button>
|
||||
<button class="btn-delete" onclick="deleteGrade(${grade.id})">
|
||||
<i class="fas fa-trash"></i> �𣳇膄
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
`;
|
||||
});
|
||||
|
||||
gradeTableBody.innerHTML = tableHTML;
|
||||
|
||||
// �齿鰵蝏穃�憭漤�㗇�鈭衤辣
|
||||
document.querySelectorAll('.grade-checkbox').forEach(checkbox => {
|
||||
checkbox.addEventListener('change', function() {
|
||||
const gradeId = parseInt(this.getAttribute('data-id'));
|
||||
if (this.checked) {
|
||||
selectedGradeIds.add(gradeId);
|
||||
} else {
|
||||
selectedGradeIds.delete(gradeId);
|
||||
selectAllCheckbox.checked = false;
|
||||
}
|
||||
updateSelectedCount();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// 霈曄蔭鈭衤辣�穃𨯬�? function setupEventListeners() {
|
||||
// �亥砭�厰僼
|
||||
searchBtn.addEventListener('click', function() {
|
||||
performSearch();
|
||||
});
|
||||
|
||||
// �滨蔭�厰僼
|
||||
resetBtn.addEventListener('click', function() {
|
||||
classSelect.value = '';
|
||||
courseSelect.value = '';
|
||||
studentIdInput.value = '';
|
||||
studentNameInput.value = '';
|
||||
renderGradeTable(mockGrades);
|
||||
selectedGradeIds.clear();
|
||||
selectAllCheckbox.checked = false;
|
||||
updateSelectedCount();
|
||||
});
|
||||
|
||||
// 撖澆枂�厰僼
|
||||
exportBtn.addEventListener('click', function() {
|
||||
exportGrades();
|
||||
});
|
||||
|
||||
// �寥��𣳇膄�厰僼
|
||||
batchDeleteBtn.addEventListener('click', function() {
|
||||
if (selectedGradeIds.size === 0) {
|
||||
alert('霂瑕��㗇𥋘閬���斤��鞟貍霈啣�嚗?);
|
||||
return;
|
||||
}
|
||||
|
||||
if (confirm(`蝖桀�閬���日�劐葉�?${selectedGradeIds.size} �⊥�蝏抵扇敶訫�嚗�迨�滢�銝滚虾�日���)) {
|
||||
batchDeleteGrades();
|
||||
}
|
||||
});
|
||||
|
||||
// �券�匧��㗇�
|
||||
selectAllCheckbox.addEventListener('change', function() {
|
||||
const checkboxes = document.querySelectorAll('.grade-checkbox');
|
||||
checkboxes.forEach(checkbox => {
|
||||
checkbox.checked = this.checked;
|
||||
const gradeId = parseInt(checkbox.getAttribute('data-id'));
|
||||
if (this.checked) {
|
||||
selectedGradeIds.add(gradeId);
|
||||
} else {
|
||||
selectedGradeIds.delete(gradeId);
|
||||
}
|
||||
});
|
||||
updateSelectedCount();
|
||||
});
|
||||
|
||||
// 颲枏�獢��頧阡睸�𦦵揣
|
||||
[studentIdInput, studentNameInput].forEach(input => {
|
||||
input.addEventListener('keypress', function(e) {
|
||||
if (e.key === 'Enter') {
|
||||
performSearch();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// �扯��𦦵揣
|
||||
function performSearch() {
|
||||
const selectedClass = classSelect.value;
|
||||
const selectedCourse = courseSelect.value;
|
||||
const studentId = studentIdInput.value.trim();
|
||||
const studentName = studentNameInput.value.trim();
|
||||
|
||||
// �曄內�㰘蝸�嗆�? gradeTableBody.innerHTML = `
|
||||
<tr>
|
||||
<td colspan="11" class="loading">
|
||||
<i class="fas fa-spinner fa-spin"></i>
|
||||
<p>甇�銁�𦦵揣�鞟貍�唳旿...</p>
|
||||
</td>
|
||||
</tr>
|
||||
`;
|
||||
|
||||
// 璅⊥�API撱嗉�
|
||||
setTimeout(() => {
|
||||
let filteredGrades = mockGrades.filter(grade => {
|
||||
// �剔漣蝑偦�? if (selectedClass && grade.className !== selectedClass) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 霂曄�蝑偦�? if (selectedCourse && grade.courseName !== selectedCourse) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 摮血噡蝑偦�? if (studentId && !grade.studentId.includes(studentId)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 憪枏�蝑偦�? if (studentName && !grade.studentName.includes(studentName)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
renderGradeTable(filteredGrades);
|
||||
selectedGradeIds.clear();
|
||||
selectAllCheckbox.checked = false;
|
||||
updateSelectedCount();
|
||||
}, 500);
|
||||
}
|
||||
|
||||
// 撖澆枂�鞟貍
|
||||
function exportGrades() {
|
||||
// 餈䠷�摨磰砲靚�鍂�𡒊垢API撖澆枂�鞟貍
|
||||
// ��𧒄雿輻鍂璅⊥�撖澆枂
|
||||
alert('�鞟貍撖澆枂�蠘�甇�銁撘��睲葉嚗���舀�Excel�龦SV�澆�撖澆枂�?);
|
||||
|
||||
// 璅⊥�撖澆枂餈��
|
||||
exportBtn.innerHTML = '<i class="fas fa-spinner fa-spin"></i> 撖澆枂銝?..';
|
||||
exportBtn.disabled = true;
|
||||
|
||||
setTimeout(() => {
|
||||
exportBtn.innerHTML = '<i class="fas fa-file-export"></i> 撖澆枂�鞟貍';
|
||||
exportBtn.disabled = false;
|
||||
|
||||
// �典�����其葉嚗諹��䔶�閫血���辣銝贝蝸
|
||||
// ��𧒄�曄內�𣂼�瘨��
|
||||
showNotification('�鞟貍撖澆枂�𣂼�嚗��隞嗅歇撘�憪衤�頧賬�?, 'success');
|
||||
}, 1500);
|
||||
}
|
||||
|
||||
// �寥��𣳇膄�鞟貍
|
||||
function batchDeleteGrades() {
|
||||
// 餈䠷�摨磰砲靚�鍂�𡒊垢API�𣳇膄�鞟貍
|
||||
// ��𧒄雿輻鍂璅⊥��𣳇膄
|
||||
batchDeleteBtn.innerHTML = '<i class="fas fa-spinner fa-spin"></i> �𣳇膄銝?..';
|
||||
batchDeleteBtn.disabled = true;
|
||||
|
||||
setTimeout(() => {
|
||||
// 隞擧芋��㺭�桐葉�𣳇膄�劐葉���蝏? selectedGradeIds.forEach(id => {
|
||||
const index = mockGrades.findIndex(grade => grade.id === id);
|
||||
if (index !== -1) {
|
||||
mockGrades.splice(index, 1);
|
||||
}
|
||||
});
|
||||
|
||||
// �齿鰵皜脫�銵冽聢
|
||||
renderGradeTable(mockGrades);
|
||||
selectedGradeIds.clear();
|
||||
selectAllCheckbox.checked = false;
|
||||
|
||||
batchDeleteBtn.innerHTML = '<i class="fas fa-trash-alt"></i> �寥��𣳇膄';
|
||||
batchDeleteBtn.disabled = false;
|
||||
|
||||
showNotification(`�𣂼��𣳇膄 ${selectedGradeIds.size} �⊥�蝏抵扇敶𤏪�`, 'success');
|
||||
updateSelectedCount();
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
// 蝻𤥁��鞟貍
|
||||
function editGrade(gradeId) {
|
||||
// 餈䠷�摨磰砲頝唾蓮�啁�颲煾△�X��枏�蝻𤥁�璅⊥���
|
||||
// ��𧒄�曄內�鞟內
|
||||
alert(`蝻𤥁��鞟貍 ID: ${gradeId}\n�典�����其葉嚗諹��䔶��枏�蝻𤥁�銵典���);
|
||||
}
|
||||
|
||||
// �𣳇膄�蓥葵�鞟貍
|
||||
function deleteGrade(gradeId) {
|
||||
if (confirm('蝖桀�閬���方��⊥�蝏抵扇敶訫�嚗�迨�滢�銝滚虾�日��?)) {
|
||||
// 餈䠷�摨磰砲靚�鍂�𡒊垢API�𣳇膄�鞟貍
|
||||
// ��𧒄雿輻鍂璅⊥��𣳇膄
|
||||
const index = mockGrades.findIndex(grade => grade.id === gradeId);
|
||||
if (index !== -1) {
|
||||
mockGrades.splice(index, 1);
|
||||
renderGradeTable(mockGrades);
|
||||
selectedGradeIds.delete(gradeId);
|
||||
updateSelectedCount();
|
||||
showNotification('�鞟貍霈啣�撌脣��歹�', 'success');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// �湔鰵�劐葉霈⊥㺭
|
||||
function updateSelectedCount() {
|
||||
const count = selectedGradeIds.size;
|
||||
if (count > 0) {
|
||||
batchDeleteBtn.innerHTML = `<i class="fas fa-trash-alt"></i> �寥��𣳇膄 (${count})`;
|
||||
} else {
|
||||
batchDeleteBtn.innerHTML = '<i class="fas fa-trash-alt"></i> �寥��𣳇膄';
|
||||
}
|
||||
}
|
||||
|
||||
// �曄內�𡁶䰻
|
||||
function showNotification(message, type = 'info') {
|
||||
// �典�����其葉嚗諹��䔶��曄內銝�銝芰�閫���𡁶䰻蝏�辣
|
||||
// ��𧒄雿輻鍂alert
|
||||
alert(message);
|
||||
}
|
||||
|
||||
// 憿菟𢒰�㰘蝸摰峕��𤾸�憪见�
|
||||
document.addEventListener('DOMContentLoaded', initPage);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user