diff --git a/backend/services/attendance_service.py b/backend/services/attendance_service.py index 6322f45..4099047 100644 --- a/backend/services/attendance_service.py +++ b/backend/services/attendance_service.py @@ -15,12 +15,20 @@ from datetime import datetime from models.attendance import AttendanceModel from models.student import StudentModel from models.conduct import ConductModel +from models.user import UserModel from middleware.permission import PermissionChecker from config import settings from utils.logger import get_logger logger = get_logger(__name__) +# 考勤状态中文映射 +ATTENDANCE_STATUS_MAP = { + "absent": "缺勤", + "late": "迟到", + "leave": "请假" +} + class AttendanceService: """考勤服务""" @@ -71,11 +79,17 @@ class AttendanceService: # 创建扣分记录 student = await StudentModel.get_by_id(student_id) if student: + # 获取操作人姓名 + user = await UserModel.get_by_user_id(recorder_id) + recorder_name = user.get("real_name", "班主任") if user else "班主任" + # 使用中文状态 + status_text = ATTENDANCE_STATUS_MAP.get(status, status) await ConductModel.create_record( student_id=student_id, points_change=points_change, - reason=f"考勤异常: {status}", + reason=f"考勤异常: {status_text}", recorder_id=recorder_id, + recorder_name=recorder_name, related_type="attendance", related_id=attendance_id ) diff --git a/frontend/admin/admins.php b/frontend/admin/admins.php index cc36ff0..80b154c 100644 --- a/frontend/admin/admins.php +++ b/frontend/admin/admins.php @@ -37,7 +37,7 @@ include __DIR__ . '/../includes/header.php';
- +
用户名姓名角色关联科目
用户名姓名角色
@@ -95,11 +95,10 @@ async function loadAdmins() { ${escapeHtml(admin.username)} ${escapeHtml(admin.real_name)} ${escapeHtml(admin.role_type)} - ${admin.subject_name || '-'} `; }); if (res.data.admins.length === 0) { - html = '暂无管理员'; + html = '暂无管理员'; } document.getElementById('adminList').innerHTML = html; } diff --git a/frontend/admin/attendance.php b/frontend/admin/attendance.php index 2e8a7d5..b98ab66 100644 --- a/frontend/admin/attendance.php +++ b/frontend/admin/attendance.php @@ -39,9 +39,9 @@ include __DIR__ . '/../includes/header.php';
- - - + + +
@@ -79,16 +79,6 @@ let currentStatus = 'absent'; let studentsData = []; let existingRecords = []; -// 初始化考勤扣分配置 -const attAbsent = window.DEDUCTION_ATTENDANCE_ABSENT || 5; -const attLate = window.DEDUCTION_ATTENDANCE_LATE || 2; -const attLeave = window.DEDUCTION_ATTENDANCE_LEAVE || 1; - -// 更新页面中的配置值显示 -document.querySelectorAll('.att-absent').forEach(el => el.textContent = attAbsent); -document.querySelectorAll('.att-late').forEach(el => el.textContent = attLate); -document.querySelectorAll('.att-leave').forEach(el => el.textContent = attLeave); - // 选择考勤状态 function selectStatus(btn) { document.querySelectorAll('.status-btn').forEach(b => b.classList.remove('active'));