v2.6更新
This commit is contained in:
@@ -27,14 +27,11 @@ include __DIR__ . '/../includes/header.php';
|
||||
<div class="container">
|
||||
<div class="card">
|
||||
<div class="filter-bar" id="historyFilterBar">
|
||||
<div class="filter-group">
|
||||
<label>学生</label>
|
||||
<select id="historyStudentId" onchange="onStudentFilterChange()">
|
||||
<option value="">全部</option>
|
||||
</select>
|
||||
</div>
|
||||
<button class="btn btn-primary" onclick="loadHistory(1)">查询</button>
|
||||
<button class="btn btn-ghost" id="filterToggleBtn" onclick="toggleFilterPanel()">展开筛选 ▼</button>
|
||||
<label class="history-grouped-label">
|
||||
<input type="checkbox" id="historyGrouped" checked onchange="loadHistory(1)"> 批次合并
|
||||
</label>
|
||||
<?php if ($role === '班主任'): ?>
|
||||
<button class="btn btn-secondary" onclick="exportHistoryRecords()">导出</button>
|
||||
<?php endif; ?>
|
||||
@@ -42,6 +39,22 @@ include __DIR__ . '/../includes/header.php';
|
||||
<!-- 高级筛选面板(默认折叠) -->
|
||||
<div id="advancedFilters" style="display:none; padding: 0 16px 16px; border-top: 1px solid var(--color-border-light);">
|
||||
<div style="display:flex; flex-wrap:wrap; gap:16px; padding-top:16px;">
|
||||
<div class="filter-group">
|
||||
<label>学生</label>
|
||||
<select id="historyStudentId" onchange="onStudentFilterChange()">
|
||||
<option value="">全部</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="filter-group">
|
||||
<label>科目</label>
|
||||
<select id="historySubjectFilter" onchange="onSubjectFilterChange()">
|
||||
<option value="">全部科目</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="filter-group">
|
||||
<label>搜索原因</label>
|
||||
<input type="text" id="historyReasonSearch" placeholder="输入关键词..." style="min-width:150px;">
|
||||
</div>
|
||||
<div class="filter-group">
|
||||
<label>开始日期</label>
|
||||
<input type="date" id="historyStartDate">
|
||||
@@ -74,11 +87,6 @@ include __DIR__ . '/../includes/header.php';
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div style="margin-top: 12px;">
|
||||
<label class="history-grouped-label">
|
||||
<input type="checkbox" id="historyGrouped" checked onchange="loadHistory(1)"> 批次合并
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="table-wrapper">
|
||||
|
||||
@@ -33,6 +33,20 @@ async function loadStudentsForSelect() {
|
||||
}
|
||||
}
|
||||
|
||||
// 加载科目下拉列表
|
||||
async function loadSubjectsForFilter() {
|
||||
var subjectSelect = document.getElementById('historySubjectFilter');
|
||||
if (!subjectSelect) return;
|
||||
var res = await apiGet('/api/subject/list', { is_active: true });
|
||||
if (res && res.success && res.data && res.data.subjects) {
|
||||
let html = '<option value="">全部科目</option>';
|
||||
res.data.subjects.forEach(s => {
|
||||
html += '<option value="' + escapeHtml(s.subject_name) + '">' + escapeHtml(s.subject_name) + '</option>';
|
||||
});
|
||||
subjectSelect.innerHTML = html;
|
||||
}
|
||||
}
|
||||
|
||||
// 筛选学生时自动取消合并记录
|
||||
function onStudentFilterChange() {
|
||||
var studentId = document.getElementById('historyStudentId').value;
|
||||
@@ -42,10 +56,19 @@ function onStudentFilterChange() {
|
||||
}
|
||||
}
|
||||
|
||||
// 科目筛选变化时,取消扣分类型筛选(互斥)
|
||||
function onSubjectFilterChange() {
|
||||
var subjectVal = document.getElementById('historySubjectFilter').value;
|
||||
if (subjectVal) {
|
||||
document.getElementById('historyReasonFilter').value = '';
|
||||
}
|
||||
}
|
||||
|
||||
// 折叠/展开筛选面板
|
||||
function toggleFilterPanel() {
|
||||
var panel = document.getElementById('advancedFilters');
|
||||
var btn = document.getElementById('filterToggleBtn');
|
||||
if (!panel || !btn) return;
|
||||
if (panel.style.display === 'none') {
|
||||
panel.style.display = 'block';
|
||||
btn.textContent = '收起筛选 ▲';
|
||||
@@ -62,6 +85,8 @@ async function loadHistory(page) {
|
||||
var endDate = document.getElementById('historyEndDate').value;
|
||||
var studentId = document.getElementById('historyStudentId').value;
|
||||
var reasonFilter = document.getElementById('historyReasonFilter').value;
|
||||
var subjectFilter = document.getElementById('historySubjectFilter').value;
|
||||
var reasonSearch = document.getElementById('historyReasonSearch').value.trim();
|
||||
var isGrouped = document.getElementById('historyGrouped').checked;
|
||||
var statusFilter = document.getElementById('historyStatusFilter') ? document.getElementById('historyStatusFilter').value : '';
|
||||
|
||||
@@ -74,7 +99,15 @@ async function loadHistory(page) {
|
||||
end_date: endDate
|
||||
};
|
||||
if (studentId) params.student_id = studentId;
|
||||
if (reasonFilter) params.reason_prefix = reasonFilter;
|
||||
|
||||
// 科目筛选优先于扣分类型筛选
|
||||
if (subjectFilter) {
|
||||
params.reason_prefix = '[' + subjectFilter + ']';
|
||||
} else if (reasonFilter) {
|
||||
params.reason_prefix = reasonFilter;
|
||||
}
|
||||
|
||||
if (reasonSearch) params.reason_search = reasonSearch;
|
||||
if (isGrouped) params.grouped = true;
|
||||
if (statusFilter !== '') params.is_revoked = parseInt(statusFilter);
|
||||
|
||||
@@ -186,11 +219,18 @@ async function exportHistoryRecords() {
|
||||
|
||||
try {
|
||||
var reasonFilter = document.getElementById('historyReasonFilter').value;
|
||||
var subjectFilter = document.getElementById('historySubjectFilter').value;
|
||||
var reasonSearch = document.getElementById('historyReasonSearch').value.trim();
|
||||
var params = { page: 1, page_size: 1000 };
|
||||
if (startDate) params.start_date = startDate;
|
||||
if (endDate) params.end_date = endDate;
|
||||
if (studentId) params.student_id = studentId;
|
||||
if (reasonFilter) params.reason_prefix = reasonFilter;
|
||||
if (subjectFilter) {
|
||||
params.reason_prefix = '[' + subjectFilter + ']';
|
||||
} else if (reasonFilter) {
|
||||
params.reason_prefix = reasonFilter;
|
||||
}
|
||||
if (reasonSearch) params.reason_search = reasonSearch;
|
||||
|
||||
var res = await apiGet('/api/admin/conduct/history', params);
|
||||
if (res && res.success && res.data.records) {
|
||||
@@ -270,7 +310,8 @@ async function batchRevokeGrouped(reason, pointsChange, recorderName, createdAt)
|
||||
}
|
||||
}
|
||||
|
||||
loadStudentsForSelect().then(function() {
|
||||
// 初始化:并行加载学生和科目列表,然后加载历史记录
|
||||
Promise.all([loadStudentsForSelect(), loadSubjectsForFilter()]).then(function() {
|
||||
var urlParams = new URLSearchParams(window.location.search);
|
||||
var preStudentId = urlParams.get('student_id');
|
||||
if (preStudentId) {
|
||||
@@ -285,6 +326,7 @@ window.loadStudentsForSelect = loadStudentsForSelect;
|
||||
window.exportHistoryRecords = exportHistoryRecords;
|
||||
window.batchRevokeGrouped = batchRevokeGrouped;
|
||||
window.onStudentFilterChange = onStudentFilterChange;
|
||||
window.onSubjectFilterChange = onSubjectFilterChange;
|
||||
window.toggleFilterPanel = toggleFilterPanel;
|
||||
|
||||
})();
|
||||
|
||||
@@ -126,7 +126,7 @@ function toggleSubjectPanel() {
|
||||
}
|
||||
|
||||
async function loadSubjectList() {
|
||||
const res = await apiGet('/api/subject/list');
|
||||
const res = await apiGet('/api/subject/list', { is_active: true });
|
||||
if (res && res.success && res.data) {
|
||||
let html = '';
|
||||
const subjects = res.data.subjects || [];
|
||||
|
||||
Reference in New Issue
Block a user