v0.8.6测试
This commit is contained in:
@@ -135,6 +135,7 @@ async function loadAdmins() {
|
||||
<td>${escapeHtml(admin.role_type)}</td>
|
||||
<td>
|
||||
<button class="btn btn-sm btn-primary" onclick="showEditAdminModal(${admin.user_id}, '${escapeHtml(admin.username)}', '${escapeHtml(admin.real_name)}', '${escapeHtml(admin.role_type)}')">编辑</button>
|
||||
<button class="btn btn-sm btn-warning" onclick="resetAdminPassword(${admin.user_id}, '${escapeHtml(admin.real_name)}')">重置密码</button>
|
||||
<button class="btn btn-sm btn-danger" onclick="deleteAdmin(${admin.user_id}, '${escapeHtml(admin.real_name)}')">删除</button>
|
||||
</td>
|
||||
</tr>`;
|
||||
@@ -227,6 +228,19 @@ async function deleteAdmin(userId, realName) {
|
||||
}
|
||||
}
|
||||
|
||||
async function resetAdminPassword(userId, realName) {
|
||||
if (!confirm(`确定要重置管理员 "${realName}" 的密码吗?`)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const res = await apiPost(`/api/admin/reset-password/${userId}`, {});
|
||||
if (res && res.success) {
|
||||
alert(`密码重置成功!\n管理员:${realName}\n新密码:${res.data.password}\n请妥善保管并及时通知该管理员。`);
|
||||
} else {
|
||||
showToast(res?.message || '密码重置失败', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
function closeModal(modalId) {
|
||||
const modal = document.getElementById(modalId);
|
||||
if (modal) modal.style.display = 'none';
|
||||
|
||||
@@ -114,23 +114,39 @@ async function exportMoralityRecords() {
|
||||
return;
|
||||
}
|
||||
|
||||
// 获取每个学生的历史记录
|
||||
// 获取所有历史记录(不分页,获取全部)
|
||||
const historyRes = await apiGet('/api/admin/conduct/history', { page: 1, page_size: 10000 });
|
||||
if (!historyRes || !historyRes.success) {
|
||||
showToast('获取历史记录失败', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
const allRecords = historyRes.data.records || [];
|
||||
|
||||
// 按学生ID分组历史记录
|
||||
const recordsByStudent = {};
|
||||
allRecords.forEach(record => {
|
||||
const sid = record.student_id;
|
||||
if (!recordsByStudent[sid]) {
|
||||
recordsByStudent[sid] = [];
|
||||
}
|
||||
recordsByStudent[sid].push(record);
|
||||
});
|
||||
|
||||
// 构建学生记录
|
||||
const studentRecords = [];
|
||||
for (const student of students) {
|
||||
const historyRes = await apiGet(`/api/student/conduct/${student.student_id}`, { limit: 1000 });
|
||||
if (historyRes && historyRes.success) {
|
||||
const records = historyRes.data.records || [];
|
||||
const positiveRecords = records.filter(r => r.points_change > 0).map(r => `${r.reason}(${r.points_change > 0 ? '+' : ''}${r.points_change})`);
|
||||
const negativeRecords = records.filter(r => r.points_change < 0).map(r => `${r.reason}(${r.points_change})`);
|
||||
|
||||
studentRecords.push({
|
||||
student_no: student.student_no,
|
||||
name: student.name,
|
||||
total_points: historyRes.data.total_points || 0,
|
||||
positive_history: positiveRecords.join(', '),
|
||||
negative_history: negativeRecords.join(', ')
|
||||
});
|
||||
}
|
||||
const studentRecords_list = recordsByStudent[student.student_id] || [];
|
||||
const positiveRecords = studentRecords_list.filter(r => r.points_change > 0).map(r => `${r.reason}(+${r.points_change})`);
|
||||
const negativeRecords = studentRecords_list.filter(r => r.points_change < 0).map(r => `${r.reason}(${r.points_change})`);
|
||||
|
||||
studentRecords.push({
|
||||
student_no: student.student_no,
|
||||
name: student.name,
|
||||
total_points: student.total_points || 0,
|
||||
positive_history: positiveRecords.join(','),
|
||||
negative_history: negativeRecords.join(',')
|
||||
});
|
||||
}
|
||||
|
||||
// 构建CSV内容
|
||||
@@ -154,6 +170,7 @@ async function exportMoralityRecords() {
|
||||
showToast(`导出成功,共${studentRecords.length}名学生`);
|
||||
} catch (err) {
|
||||
showToast('导出失败:' + err.message, 'error');
|
||||
console.error('导出失败:', err);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user