更新:models/routes/services/templates/docs
This commit is contained in:
@@ -68,6 +68,9 @@
|
||||
<option value="">全部班级</option>
|
||||
</select>
|
||||
<input type="text" class="form-control form-control-sm" style="width:150px;" placeholder="搜索姓名..." id="nameFilter" oninput="loadStudents()">
|
||||
<button class="btn btn-primary btn-sm active" id="mineStudentFilterBtn" onclick="toggleMineStudentFilter()">
|
||||
<i class="bi bi-person"></i> 我的
|
||||
</button>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<button class="btn btn-outline-secondary" onclick="downloadTemplate()">
|
||||
@@ -480,10 +483,14 @@ function importStudents(input) {
|
||||
async function loadStudents() {
|
||||
const classId = document.getElementById('classFilter').value;
|
||||
const name = document.getElementById('nameFilter').value;
|
||||
const mineFilter = document.getElementById('mineStudentFilterBtn').classList.contains('active');
|
||||
|
||||
let url = '/api/students?';
|
||||
if (classId) url += 'class_id=' + classId + '&';
|
||||
if (name) url += 'name=' + encodeURIComponent(name);
|
||||
if (name) url += 'name=' + encodeURIComponent(name) + '&';
|
||||
if (mineFilter) url += 'mine=true&';
|
||||
|
||||
url = url.endsWith('&') ? url.slice(0, -1) : url;
|
||||
|
||||
const response = await fetch(url);
|
||||
if (response.status === 401) {
|
||||
@@ -494,6 +501,20 @@ async function loadStudents() {
|
||||
renderStudentList(students);
|
||||
}
|
||||
|
||||
// 我的学员筛选
|
||||
function toggleMineStudentFilter() {
|
||||
const btn = document.getElementById('mineStudentFilterBtn');
|
||||
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');
|
||||
}
|
||||
loadStudents();
|
||||
}
|
||||
|
||||
// 加载班级筛选选项
|
||||
async function loadClassFilter() {
|
||||
try {
|
||||
@@ -545,6 +566,7 @@ function renderStudentList(students) {
|
||||
<span class="badge bg-info">${s.practice_time}</span>
|
||||
<span class="badge bg-secondary">${problemText}</span>
|
||||
<span class="badge bg-primary">${s.plan_count} 个方案</span>
|
||||
${s.goal_count > 0 ? `<span class="badge bg-success">${s.goal_count}个目标(${s.completed_goal_count}已达成)</span>` : ''}
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
@@ -835,9 +857,9 @@ function renderPlanList(plans) {
|
||||
plans.forEach(p => {
|
||||
// 构建显示文本:问题【模板 | 时间】
|
||||
let problemText = '';
|
||||
if (p.problem_names && p.problem_names.length > 0) {
|
||||
const problems = p.problem_names.slice(0, 3).join('、');
|
||||
const more = p.problem_names.length > 3 ? `等${p.problem_names.length}个` : '';
|
||||
if (p.problem_details && p.problem_details.length > 0) {
|
||||
const problems = p.problem_details.slice(0, 3).map(d => `${d.name}[${d.level}/${d.severity}]`).join('、');
|
||||
const more = p.problem_details.length > 3 ? `等${p.problem_details.length}个` : '';
|
||||
problemText = `${problems}${more}`;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user