v0.8测试

This commit is contained in:
2026-04-16 07:55:46 +08:00
parent 7c743293be
commit c8262cf92e
16 changed files with 84 additions and 39 deletions

View File

@@ -70,10 +70,11 @@ include __DIR__ . '/../includes/header.php';
<label>角色</label>
<select id="adminRole" required>
<option value="">请选择角色</option>
<option value="班长">班长</option>
<option value="学习委员">学习委员</option>
<option value="考勤委员">考勤委员</option>
<option value="劳动委员">劳动委员</option>
<option value='班长'>班长</option>
<option value='学习委员'>学习委员</option>
<option value='考勤委员'>考勤委员</option>
<option value='劳动委员'>劳动委员</option>
<option value='志愿委员'>志愿委员</option>
</select>
</div>
<div class="modal-footer">

View File

@@ -39,9 +39,10 @@ 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)">缺勤(-<span class="att-absent"></span>分)</button>
<button class="status-btn" data-status="late" onclick="selectStatus(this)">迟到(-<span class="att-late"></span>分)</button>
<button class="status-btn" data-status="leave" onclick="selectStatus(this)">请假(-<span class="att-leave"></span>分)</button>
<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>
<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;">
<button class="btn btn-primary" onclick="selectAllStudents()">全选</button>
@@ -93,6 +94,13 @@ function selectStatus(btn) {
document.querySelectorAll('.status-btn').forEach(b => b.classList.remove('active'));
btn.classList.add('active');
currentStatus = btn.dataset.status;
// 自动设置默认扣分值
const defaultDeduction = btn.dataset.defaultDeduction;
if (defaultDeduction && defaultDeduction !== '0') {
document.getElementById('customDeduction').value = defaultDeduction;
} else {
document.getElementById('customDeduction').value = '';
}
}
// 加载学生列表
@@ -165,6 +173,8 @@ async function submitAttendance() {
const date = document.getElementById('attendanceDate').value;
const reason = document.getElementById('attendanceReason').value;
const customDeduction = document.getElementById('customDeduction').value;
const customDeductionValue = customDeduction ? parseInt(customDeduction) : null;
// 检查是否有已存在记录的学生
const hasRecordStudents = [];
@@ -183,15 +193,18 @@ async function submitAttendance() {
const promises = [];
selectedCells.forEach(cell => {
const studentId = parseInt(cell.dataset.id);
promises.push(
apiPost('/api/admin/attendance', {
student_id: studentId,
date: date,
status: currentStatus,
reason: reason,
apply_deduction: true
})
);
const payload = {
student_id: studentId,
date: date,
status: currentStatus,
reason: reason,
apply_deduction: true
};
// 只有设置了自定义扣分时才发送
if (customDeductionValue !== null && customDeductionValue > 0) {
payload.custom_deduction = customDeductionValue;
}
promises.push(apiPost('/api/admin/attendance', payload));
});
const results = await Promise.allSettled(promises);

View File

@@ -20,7 +20,7 @@ if (!isset($_SESSION['user_id']) || $_SESSION['user_type'] !== 'admin') {
$page_title = '操行分管理';
$role = $_SESSION['role'] ?? '';
if (!in_array($role, ['班主任', '班长', '劳动委员'])) {
if (!in_array($role, ['班主任', '班长', '劳动委员', '志愿委员'])) {
header('Location: /admin/dashboard.php');
exit();
}
@@ -115,6 +115,7 @@ loadStudents();
<small><?php
if ($role === '班长') echo '班长单次±5分以内';
elseif ($role === '劳动委员') echo '劳动委员仅限±1分';
elseif ($role === '志愿委员') echo '志愿委员仅限加分';
else echo '班主任无限制';
?></small>
</div>

View File

@@ -58,7 +58,7 @@ async function loadDashboard() {
}
let quickActions = '';
if ('<?php echo $role; ?>' === '班主任' || '<?php echo $role; ?>' === '班长' || '<?php echo $role; ?>' === '劳动委员') {
if ('<?php echo $role; ?>' === '班主任' || '<?php echo $role; ?>' === '班长' || '<?php echo $role; ?>' === '劳动委员' || '<?php echo $role; ?>' === '志愿委员') {
quickActions += '<button class="btn btn-primary" onclick="location.href=\'/admin/conduct.php\'">操行分管理</button>';
}
if ('<?php echo $role; ?>' === '班主任') {

View File

@@ -53,7 +53,7 @@ include __DIR__ . '/../includes/header.php';
<th>分数变动</th>
<th>原因</th>
<th>操作人</th>
<?php if ($role === '班主任' || $role === '班长'): ?>
<?php if ($role === '班主任' || $role === '班长' || $role === '志愿委员'): ?>
<th>操作</th>
<?php endif; ?>
</tr>
@@ -105,14 +105,14 @@ async function loadHistory(page = 1) {
<td class="${pointsClass}">${record.points_change > 0 ? '+' : ''}${record.points_change}</td>
<td>${escapeHtml(record.reason)}</td>
<td>${escapeHtml(record.recorder_name)}</td>`;
<?php if ($role === '班主任' || $role === '班长'): ?>
<?php if ($role === '班主任' || $role === '班长' || $role === '志愿委员'): ?>
html += `<td><button class="btn btn-sm btn-danger" onclick="revokeRecord(${record.record_id})">撤销</button></td>`;
<?php endif; ?>
html += `</tr>`;
});
if (res.data.records.length === 0) {
const colSpan = <?php echo ($role === '班主任' || $role === '班长') ? '6' : '5'; ?>;
const colSpan = <?php echo ($role === '班主任' || $role === '班长' || $role === '志愿委员') ? '6' : '5'; ?>;
html = `<tr><td colspan="${colSpan}" style="text-align:center;">暂无记录</td></tr>`;
}