按老师数量设置查询结果默认折叠

This commit is contained in:
Codex
2026-06-26 17:30:44 +08:00
parent 2fc32db0d4
commit 93cd2e9c75
+10
View File
@@ -123,6 +123,13 @@ function groupRecordsByTeacher(records) {
}); });
} }
function initializeTeacherGroupCollapse(records) {
const groups = groupRecordsByTeacher(records);
collapsedTeacherGroups = groups.length > 1
? new Set(groups.map((group) => group.teacher))
: new Set();
}
function getDisplayRecord(row) { function getDisplayRecord(row) {
return correctedRecords.get(row._recordKey) || row; return correctedRecords.get(row._recordKey) || row;
} }
@@ -811,6 +818,9 @@ async function queryRecords(query, options = {}) {
_recordIndex: currentRecordPage.offset + index, _recordIndex: currentRecordPage.offset + index,
_recordKey: makeRecordKey(row, currentRecordPage.offset + index), _recordKey: makeRecordKey(row, currentRecordPage.offset + index),
})); }));
if (options.reset !== false) {
initializeTeacherGroupCollapse(currentRecords);
}
recordRows.innerHTML = renderGroupedRecords(currentRecords); recordRows.innerHTML = renderGroupedRecords(currentRecords);
} catch (error) { } catch (error) {
recordRows.innerHTML = `<tr><td colspan="${RECORD_TABLE_COLUMN_COUNT}" class="empty">查询失败:${escapeHtml(error.message)}</td></tr>`; recordRows.innerHTML = `<tr><td colspan="${RECORD_TABLE_COLUMN_COUNT}" class="empty">查询失败:${escapeHtml(error.message)}</td></tr>`;