v0.5测试

This commit is contained in:
2026-04-14 11:35:56 +08:00
parent 2f271b1dc4
commit bf5b2516e2
17 changed files with 646 additions and 439 deletions

View File

@@ -127,4 +127,86 @@
width: 18px;
height: 18px;
cursor: pointer;
}
}
/* 考勤学生方格网格 */
.student-grid {
display: flex;
flex-wrap: wrap;
gap: 10px;
margin: 15px 0;
}
.student-cell {
width: calc(100% / 7 - 10px);
min-height: 60px;
border: 2px solid #e5e7eb;
border-radius: 8px;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
font-size: 14px;
font-weight: 500;
transition: all 0.2s ease;
padding: 8px 4px;
text-align: center;
word-break: break-all;
user-select: none;
}
.student-cell:hover {
background: #f3f4f6;
border-color: #9ca3af;
}
.student-cell.selected {
background: #fee2e2;
border-color: #ef4444;
color: #dc2626;
}
.student-cell.has-record {
border: 2px dashed #9ca3af;
opacity: 0.7;
}
.attendance-toolbar {
display: flex;
align-items: center;
gap: 10px;
margin: 15px 0;
flex-wrap: wrap;
}
.attendance-toolbar .status-group {
display: flex;
gap: 8px;
}
.attendance-toolbar .status-btn {
padding: 6px 16px;
border: 2px solid #e5e7eb;
border-radius: 6px;
background: white;
cursor: pointer;
font-size: 13px;
transition: all 0.2s;
}
.attendance-toolbar .status-btn.active {
border-color: #667eea;
background: #eef2ff;
color: #4338ca;
}
@media (max-width: 768px) {
.student-cell {
width: calc(100% / 4 - 10px);
}
}
@media (max-width: 480px) {
.student-cell {
width: calc(100% / 3 - 10px);
}
}

View File

@@ -171,103 +171,6 @@ async function submitAddStudent() {
}
}
// 显示添加作业模态框
function showAddAssignmentModal() {
document.getElementById('addAssignmentModal').style.display = 'flex';
loadSubjectsForSelect();
}
// 加载科目下拉框
async function loadSubjectsForSelect() {
const res = await apiGet('/api/subject/list');
if (res && res.success) {
let html = '<option value="">请选择科目</option>';
res.data.subjects.forEach(s => {
if (s.is_active) {
html += `<option value="${s.subject_id}">${s.subject_name}</option>`;
}
});
document.getElementById('assignmentSubjectId').innerHTML = html;
}
}
// 提交添加作业
async function submitAddAssignment() {
const subjectId = document.getElementById('assignmentSubjectId').value;
const title = document.getElementById('assignmentTitle').value.trim();
const description = document.getElementById('assignmentDescription').value;
const deadline = document.getElementById('assignmentDeadline').value;
if (!subjectId || !title || !deadline) {
showToast('请填写完整信息', 'warning');
return;
}
const res = await apiPost('/api/admin/homework/assignment', {
subject_id: parseInt(subjectId),
title: title,
description: description,
deadline: deadline
});
if (res && res.success) {
showToast('作业发布成功');
closeModal('addAssignmentModal');
loadAssignments();
} else {
showToast(res?.message || '发布失败', 'error');
}
}
// 显示添加考勤模态框
async function showAddAttendanceModal() {
await loadStudentsForSelect();
document.getElementById('addAttendanceModal').style.display = 'flex';
document.getElementById('attendanceDate').value = new Date().toISOString().split('T')[0];
}
// 加载学生下拉框
async function loadStudentsForSelect() {
const res = await apiGet('/api/admin/students');
if (res && res.success) {
let html = '<option value="">请选择学生</option>';
res.data.students.forEach(s => {
html += `<option value="${s.student_id}">${s.student_no} - ${s.name}</option>`;
});
document.getElementById('attendanceStudentId').innerHTML = html;
}
}
// 提交添加考勤
async function submitAddAttendance() {
const studentId = document.getElementById('attendanceStudentId').value;
const date = document.getElementById('attendanceDate').value;
const status = document.getElementById('attendanceStatus').value;
const reason = document.getElementById('attendanceReason').value;
const applyDeduction = document.getElementById('attendanceDeduct').checked;
if (!studentId || !date || !status) {
showToast('请填写完整信息', 'warning');
return;
}
const res = await apiPost('/api/admin/attendance', {
student_id: parseInt(studentId),
date: date,
status: status,
reason: reason,
apply_deduction: applyDeduction
});
if (res && res.success) {
showToast('考勤记录添加成功');
closeModal('addAttendanceModal');
loadAttendanceRecords();
} else {
showToast(res?.message || '添加失败', 'error');
}
}
// 显示添加管理员模态框
function showAddAdminModal() {
document.getElementById('addAdminModal').style.display = 'flex';