v2.1更新

This commit is contained in:
2026-05-26 13:47:01 +08:00
parent c575d711ee
commit f84c9d3efb
26 changed files with 1482 additions and 567 deletions

View File

@@ -39,8 +39,8 @@ include __DIR__ . '/../includes/header.php';
<span style="font-size: 14px; color: #666;">显示前</span>
<input type="number" id="percentileFilter" style="width: 70px; padding: 4px 8px; border: 1px solid #ddd; border-radius: 4px;" min="1" max="100" value="100" placeholder="1-100">
<span style="font-size: 14px; color: #666;">% 的学生</span>
<button class="btn btn-sm" style="background: #667eea; color: white;" onclick="applyPercentileFilter()">筛选</button>
<button class="btn btn-sm" style="border: 1px solid #ccc; color: #666;" onclick="resetPercentileFilter()">显示全部</button>
<button class="btn btn-sm btn-primary" onclick="applyPercentileFilter()">筛选</button>
<button class="btn btn-sm btn-ghost" onclick="resetPercentileFilter()">显示全部</button>
</div>
<table class="table">
<thead>
@@ -52,7 +52,154 @@ include __DIR__ . '/../includes/header.php';
</div>
</div>
<?php if ($role === '班主任'): ?>
<!-- 升级提示模态框 -->
<div id="upgradeModal" class="modal" style="display:none;">
<div class="modal-content" style="max-width:520px;">
<div class="modal-header">
<h3>🔄 系统升级</h3>
<button class="modal-close" onclick="closeModal('upgradeModal')" id="upgradeCloseBtn">&times;</button>
</div>
<div style="padding: 16px 0;">
<div style="text-align: center; margin-bottom: 12px;">
<p style="font-size: 15px; color: var(--color-text);">检测到数据库有新版本可用</p>
<p style="font-size: 13px; color: var(--color-text-muted); margin-top: 8px;">
当前版本: <span id="currentDbVersion">--</span> → 目标版本: <span id="targetDbVersion">--</span>
</p>
</div>
<div id="upgradeStepsList" style="margin: 12px 0;"></div>
<div id="upgradeResult" style="display:none; margin-top: 12px;"></div>
<p id="upgradeWarning" class="text-danger" style="font-size: 12px; text-align: center; margin-top: 8px;">⚠️ 升级前请确保已备份数据库</p>
</div>
<div class="modal-footer">
<button class="btn" onclick="closeModal('upgradeModal')" id="upgradeLaterBtn">稍后再说</button>
<button class="btn btn-primary" onclick="startUpgrade()" id="startUpgradeBtn">开始升级</button>
</div>
</div>
</div>
<?php endif; ?>
<script>window.PAGE_CONFIG = { role: '<?php echo $role; ?>' };</script>
<script src="/assets/js/dashboard.js"></script>
<?php if ($role === '班主任'): ?>
<script>
(function() {
var upgradeSteps = [];
var currentStepIndex = 0;
fetch('/api/check_upgrade.php')
.then(function(r) { return r.json(); })
.then(function(data) {
if (data.needs_upgrade) {
document.getElementById('currentDbVersion').textContent = data.current;
document.getElementById('targetDbVersion').textContent = data.target;
upgradeSteps = data.steps || [];
// 渲染步骤列表
var listHtml = '';
for (var i = 0; i < upgradeSteps.length; i++) {
listHtml += '<div style="display:flex;align-items:center;padding:8px 12px;margin:4px 0;border-radius:6px;font-size:13px;background:var(--color-hover);border-left:3px solid var(--color-border);" id="ustep-' + i + '">' +
'<span style="margin-right:8px;" id="ustep-icon-' + i + '">○</span>' +
'<span>升级至 v' + upgradeSteps[i].version + '</span>' +
'</div>';
}
document.getElementById('upgradeStepsList').innerHTML = listHtml;
document.getElementById('upgradeModal').style.display = 'flex';
}
})
.catch(function() {});
window.startUpgrade = function() {
var btn = document.getElementById('startUpgradeBtn');
var closeBtn = document.getElementById('upgradeCloseBtn');
var laterBtn = document.getElementById('upgradeLaterBtn');
btn.disabled = true;
btn.textContent = '升级中...';
btn.style.opacity = '0.7';
closeBtn.style.display = 'none';
laterBtn.style.display = 'none';
document.getElementById('upgradeWarning').style.display = 'none';
currentStepIndex = 0;
executeNextUpgradeStep();
};
function executeNextUpgradeStep() {
if (currentStepIndex >= upgradeSteps.length) {
// 所有步骤完成
var btn = document.getElementById('startUpgradeBtn');
btn.textContent = '升级完成 ✓';
btn.style.background = '#52c41a';
var laterBtn = document.getElementById('upgradeLaterBtn');
laterBtn.style.display = '';
laterBtn.textContent = '关闭';
laterBtn.onclick = function() { location.reload(); };
document.getElementById('upgradeResult').style.display = 'block';
document.getElementById('upgradeResult').innerHTML = '<div style="background:#f6ffed;border:1px solid #b7eb8f;border-radius:6px;padding:12px;text-align:center;color:var(--color-success);font-size:14px;">✓ 数据库升级成功!</div>';
return;
}
var step = upgradeSteps[currentStepIndex];
var stepEl = document.getElementById('ustep-' + currentStepIndex);
var iconEl = document.getElementById('ustep-icon-' + currentStepIndex);
// 标记为执行中
if (stepEl) {
stepEl.style.borderLeftColor = 'var(--color-primary)';
stepEl.style.background = 'var(--color-primary-light)';
}
if (iconEl) iconEl.textContent = '⟳';
fetch('/upgrade.php?action=step&version=' + encodeURIComponent(step.version), { method: 'POST' })
.then(function(r) { return r.json(); })
.then(function(data) {
if (data.success) {
if (stepEl) {
stepEl.style.borderLeftColor = 'var(--color-success)';
stepEl.style.background = '#f6ffed';
}
if (iconEl) iconEl.textContent = '✓';
currentStepIndex++;
executeNextUpgradeStep();
} else {
if (stepEl) {
stepEl.style.borderLeftColor = 'var(--color-danger)';
stepEl.style.background = 'var(--color-danger-light)';
}
if (iconEl) iconEl.textContent = '✗';
showUpgradeError(data.error || '未知错误');
}
})
.catch(function(err) {
if (stepEl) {
stepEl.style.borderLeftColor = 'var(--color-danger)';
stepEl.style.background = 'var(--color-danger-light)';
}
if (iconEl) iconEl.textContent = '✗';
showUpgradeError(err.message);
});
}
function showUpgradeError(msg) {
var btn = document.getElementById('startUpgradeBtn');
btn.textContent = '升级失败';
btn.style.background = 'var(--color-danger)';
btn.disabled = false;
btn.style.opacity = '';
var laterBtn = document.getElementById('upgradeLaterBtn');
laterBtn.style.display = '';
laterBtn.textContent = '关闭';
document.getElementById('upgradeResult').style.display = 'block';
document.getElementById('upgradeResult').innerHTML = '<div style="background:var(--color-danger-light);border:1px solid #ffccc7;border-radius:6px;padding:12px;color:var(--color-danger-dark);font-size:13px;"><strong>升级失败:</strong>' + msg + '</div>';
}
})();
</script>
<?php endif; ?>
<?php include __DIR__ . '/../includes/footer.php'; ?>

View File

@@ -83,7 +83,7 @@ include __DIR__ . '/../includes/header.php';
</div>
</div>
<script>window.PAGE_CONFIG = { role: '<?php echo $role; ?>', userId: <?php echo intval($_SESSION['user_id']); ?> };</script>
<script>window.PAGE_CONFIG = { role: '<?php echo htmlspecialchars($role, ENT_QUOTES, 'UTF-8'); ?>', userId: <?php echo intval($_SESSION['user_id']); ?> };</script>
<script src="/assets/js/modules/modal-utils.js"></script>
<script src="/assets/js/modules/utils.js"></script>
<script src="/assets/js/modules/points-mgmt.js"></script>

View File

@@ -32,12 +32,12 @@ include __DIR__ . '/../includes/header.php';
<div class="container">
<!-- 科目管理折叠面板 -->
<div class="card" style="margin-bottom: 20px;">
<div class="collapsible-header" onclick="toggleSubjectPanel()" style="cursor: pointer; display: flex; justify-content: space-between; align-items: center; padding: 15px 20px;">
<div class="card collapsible-card" style="margin-bottom: 20px;">
<div class="collapsible-header" id="subjectPanelHeader">
<h3 style="margin: 0; font-size: 16px;">📚 科目管理</h3>
<span id="subjectPanelToggle" class="toggle-icon">▶ 展开</span>
</div>
<div id="subjectPanelContent" style="display: none; padding: 0 20px 20px;">
<div id="subjectPanelContent" class="collapsible-content">
<div class="action-bar">
<button class="btn btn-primary" onclick="showAddSubjectModal()">添加科目</button>
</div>
@@ -92,9 +92,6 @@ include __DIR__ . '/../includes/header.php';
<div class="deduction-types">
<button type="button" class="btn btn-sm" onclick="selectDeductionType(-window.DEDUCTION_HOMEWORK_NOT_SUBMIT, '未交作业')">未交作业(-<span class="hw-not-submit"></span>分)</button>
<button type="button" class="btn btn-sm" onclick="selectDeductionType(-window.DEDUCTION_HOMEWORK_LATE, '迟交作业')">迟交作业(-<span class="hw-late"></span>分)</button>
<button type="button" class="btn btn-sm" onclick="selectDeductionType(null, '卫生')">卫生</button>
<button type="button" class="btn btn-sm" onclick="selectDeductionType(null, '课堂')">课堂</button>
<button type="button" class="btn btn-sm" onclick="selectDeductionType(null, '纪律')">纪律</button>
<button type="button" class="btn btn-sm" onclick="selectDeductionType(0, '')">自定义</button>
</div>
</div>
@@ -189,7 +186,7 @@ include __DIR__ . '/../includes/header.php';
gap: 12px;
}
.subject-item {
background: #f8f9fa;
background: var(--color-hover);
padding: 12px 20px;
border-radius: 8px;
display: flex;
@@ -201,7 +198,7 @@ include __DIR__ . '/../includes/header.php';
font-size: 16px;
}
.subject-code {
color: #999;
color: var(--color-text-muted);
font-size: 12px;
}
.subject-status {
@@ -217,22 +214,36 @@ include __DIR__ . '/../includes/header.php';
background: #fed7d7;
color: #742a2a;
}
.collapsible-header {
.collapsible-card .collapsible-header {
cursor: pointer;
display: flex;
justify-content: space-between;
align-items: center;
padding: 15px 20px;
user-select: none;
transition: background 0.2s;
border-radius: 12px;
}
.collapsible-header:hover {
background: #f8f9fa;
.collapsible-card .collapsible-header:hover {
background: var(--color-hover, #f7fafc);
}
.collapsible-card .collapsible-content {
max-height: 0;
overflow: hidden;
transition: max-height 0.3s ease-out, padding 0.3s ease-out;
padding: 0 20px;
}
.collapsible-card .collapsible-content.expanded {
max-height: 1000px;
padding: 0 20px 20px;
}
.toggle-icon {
font-size: 12px;
color: #666;
color: var(--color-text-secondary, #666);
transition: transform 0.3s;
}
.btn-danger {
background: #e53e3e;
color: white;
}
.btn-danger:hover {
background: #c53030;
.toggle-icon.expanded {
transform: rotate(90deg);
}
</style>

View File

@@ -66,8 +66,8 @@ include __DIR__ . '/../includes/header.php';
<input type="text" id="semesterName" required placeholder="如2025春季学期" maxlength="100">
</div>
<div style="margin-bottom: 8px;">
<button type="button" class="btn btn-sm" style="border: 1px solid #667eea; color: #667eea; margin-right: 6px;" onclick="fillSemesterDates('upper')">上学期9月-次年2月</button>
<button type="button" class="btn btn-sm" style="border: 1px solid #667eea; color: #667eea;" onclick="fillSemesterDates('lower')">下学期3月-7月</button>
<button type="button" class="btn btn-sm btn-outline" style="margin-right: 6px;" onclick="fillSemesterDates('upper')">上学期9月-次年2月</button>
<button type="button" class="btn btn-sm btn-outline" onclick="fillSemesterDates('lower')">下学期3月-7月</button>
</div>
<div class="form-group">
<label>开始日期</label>

View File

@@ -30,7 +30,7 @@ include __DIR__ . '/../includes/header.php';
<div class="action-buttons">
<?php if ($role === '班主任'): ?>
<button class="btn btn-primary" onclick="showImportModal()">导入学生</button>
<button class="btn btn-success" onclick="showAddStudentModal()">新增学生</button>
<button class="btn btn-primary" onclick="showAddStudentModal()">新增学生</button>
<?php endif; ?>
</div>
<div class="search-bar">