v0.8.2测试
This commit is contained in:
@@ -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
|
||||
)
|
||||
|
||||
@@ -37,7 +37,7 @@ include __DIR__ . '/../includes/header.php';
|
||||
<div class="table-wrapper">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr><th>用户名</th><th>姓名</th><th>角色</th><th>关联科目</th></tr>
|
||||
<tr><th>用户名</th><th>姓名</th><th>角色</th></tr>
|
||||
</thead>
|
||||
<tbody id="adminList"></tbody>
|
||||
</table>
|
||||
@@ -95,11 +95,10 @@ async function loadAdmins() {
|
||||
<td>${escapeHtml(admin.username)}</td>
|
||||
<td>${escapeHtml(admin.real_name)}</td>
|
||||
<td>${escapeHtml(admin.role_type)}</td>
|
||||
<td>${admin.subject_name || '-'}</td>
|
||||
</tr>`;
|
||||
});
|
||||
if (res.data.admins.length === 0) {
|
||||
html = '<tr><td colspan="4" style="text-align:center;">暂无管理员</td></tr>';
|
||||
html = '<tr><td colspan="3" style="text-align:center;">暂无管理员</td></tr>';
|
||||
}
|
||||
document.getElementById('adminList').innerHTML = html;
|
||||
}
|
||||
|
||||
@@ -39,9 +39,9 @@ include __DIR__ . '/../includes/header.php';
|
||||
<input type="date" id="attendanceDate" value="<?php echo date('Y-m-d'); ?>">
|
||||
</div>
|
||||
<div class="status-group">
|
||||
<button class="status-btn active" data-status="absent" onclick="selectStatus(this)" data-default-deduction="3">缺勤(-<span class="att-absent"></span>分)</button>
|
||||
<button class="status-btn" data-status="late" onclick="selectStatus(this)" data-default-deduction="1">迟到(-<span class="att-late"></span>分)</button>
|
||||
<button class="status-btn" data-status="leave" onclick="selectStatus(this)" data-default-deduction="0">请假(-<span class="att-leave"></span>分)</button>
|
||||
<button class="status-btn active" data-status="absent" onclick="selectStatus(this)" data-default-deduction="3">缺勤</button>
|
||||
<button class="status-btn" data-status="late" onclick="selectStatus(this)" data-default-deduction="1">迟到</button>
|
||||
<button class="status-btn" data-status="leave" onclick="selectStatus(this)" data-default-deduction="0">请假</button>
|
||||
<input type="number" id="customDeduction" placeholder="自定义扣分" min="0" max="10" style="width:100px;margin-left:10px;" title="留空或0使用默认值">
|
||||
</div>
|
||||
<input type="text" id="attendanceReason" placeholder="原因(可选)" style="flex:1;min-width:150px;">
|
||||
@@ -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'));
|
||||
|
||||
Reference in New Issue
Block a user