更新:models/routes/services/templates/docs
This commit is contained in:
@@ -19,6 +19,9 @@
|
||||
<div class="card mb-3">
|
||||
<div class="card-body">
|
||||
<div class="row g-3">
|
||||
<div class="col-md-1 d-flex align-items-end">
|
||||
<button class="btn btn-primary active w-100" id="minePlansBtn" onclick="toggleMinePlans()">我的</button>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label class="form-label small">班级</label>
|
||||
<select class="form-select" id="filterClass" onchange="loadPlans()">
|
||||
@@ -44,7 +47,7 @@
|
||||
<option value="true">仅典型</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="col-md-2">
|
||||
<label class="form-label small">学员姓名</label>
|
||||
<input type="text" class="form-control" id="filterStudentName" placeholder="模糊搜索..." oninput="debounceLoad()">
|
||||
</div>
|
||||
@@ -148,6 +151,11 @@ async function loadPlans() {
|
||||
params.append('problem_ids', parseInt(problemId));
|
||||
}
|
||||
|
||||
const mineBtn = document.getElementById('minePlansBtn');
|
||||
if (mineBtn && mineBtn.classList.contains('active')) {
|
||||
params.append('mine', 'true');
|
||||
}
|
||||
|
||||
const resp = await fetch(`/api/plans?${params}`);
|
||||
const plans = await resp.json();
|
||||
|
||||
@@ -173,8 +181,9 @@ async function loadPlans() {
|
||||
`;
|
||||
|
||||
plans.forEach(p => {
|
||||
const problems = (p.problem_names || []).slice(0, 3).join('、');
|
||||
const moreProblems = (p.problem_names || []).length > 3 ? `等${p.problem_names.length}个` : '';
|
||||
const details = p.problem_details || [];
|
||||
const problemText = details.slice(0, 3).map(d => `${d.name}[${d.level}/${d.severity}]`).join('、');
|
||||
const moreProblems = details.length > 3 ? `等${details.length}个` : '';
|
||||
const template = p.template_name || '无模板';
|
||||
const studentName = p.student_name || '未知';
|
||||
const className = p.class_name || '-';
|
||||
@@ -182,9 +191,9 @@ async function loadPlans() {
|
||||
|
||||
html += `
|
||||
<tr>
|
||||
<td><strong>${studentName}</strong></td>
|
||||
<td><a href="/student/${p.student_id}" class="text-decoration-none"><strong>${studentName}</strong></a></td>
|
||||
<td>${className}</td>
|
||||
<td><span class="plan-problem-text">${problems}${moreProblems}</span></td>
|
||||
<td><span class="plan-problem-text">${problemText}${moreProblems}</span></td>
|
||||
<td class="text-muted small">${template}</td>
|
||||
<td class="text-center">${isTypical ? '<span class="text-warning">★</span>' : ''}</td>
|
||||
<td class="text-muted small">${p.created_at || ''}</td>
|
||||
@@ -210,6 +219,26 @@ function clearFilters() {
|
||||
document.getElementById('filterTemplate').value = '';
|
||||
document.getElementById('filterTypical').value = '';
|
||||
document.getElementById('filterStudentName').value = '';
|
||||
const mineBtn = document.getElementById('minePlansBtn');
|
||||
if (mineBtn) {
|
||||
mineBtn.classList.remove('active', 'btn-primary');
|
||||
mineBtn.classList.add('btn-outline-secondary');
|
||||
}
|
||||
loadPlans();
|
||||
}
|
||||
|
||||
// 我的筛选
|
||||
function toggleMinePlans() {
|
||||
const btn = document.getElementById('minePlansBtn');
|
||||
if (!btn) return;
|
||||
btn.classList.toggle('active');
|
||||
if (btn.classList.contains('active')) {
|
||||
btn.classList.remove('btn-outline-secondary');
|
||||
btn.classList.add('btn-primary');
|
||||
} else {
|
||||
btn.classList.remove('btn-primary');
|
||||
btn.classList.add('btn-outline-secondary');
|
||||
}
|
||||
loadPlans();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user