更新 attendance-teacher.html
parent
ca55d9d2fd
commit
3e79a22956
|
|
@ -74,50 +74,8 @@
|
|||
<script src="/static/layui.js"></script>
|
||||
<script src="/static/js/menu.js"></script>
|
||||
<script src="/static/js/logout.js"></script>
|
||||
<script src="/static/js/get_teacher_attendance_table.js"></script>
|
||||
<script>
|
||||
layui.use(['laypage', 'element', 'jquery', 'dropdown'], function () {
|
||||
var laypage = layui.laypage;
|
||||
var $ = layui.jquery;
|
||||
|
||||
function renderTable(page) {
|
||||
// 发送GET请求到服务器端点
|
||||
$.get('/api/get-teacher-attendance-table?page=' + page, function (response) {
|
||||
var $tbody = $('#attendanceTable tbody');
|
||||
$tbody.empty(); // 清空表格内容
|
||||
|
||||
// 遍历返回的数据数组
|
||||
response.data.forEach(function (item) {
|
||||
// 创建新的行并填充数据
|
||||
var $row = $('<tr></tr>');
|
||||
$row.append(`<td>${item.course_name}</td>`);
|
||||
$row.append(`<td>${item.course_code}</td>`);
|
||||
$row.append(`<td>${item.credits}</td>`);
|
||||
$row.append(`<td>${item.class_name + item.major}</td>`);
|
||||
$row.append(`<td><div class="layui-btn-container">
|
||||
<button type="button" class="layui-btn">签到</button>
|
||||
</div>
|
||||
</td>`)
|
||||
$tbody.append($row);
|
||||
|
||||
});
|
||||
// 渲染分页控件
|
||||
laypage.render({
|
||||
elem: 'pagination', // 分页容器的id
|
||||
count: response.count, // 总条数
|
||||
limit: 10, // 每页显示条数
|
||||
curr: page, // 当前页
|
||||
jump: function (obj, first) {
|
||||
if (!first) { // 首次不执行
|
||||
renderTable(obj.curr); // 根据页码加载数据
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// 初始加载第一页
|
||||
renderTable(1);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
Reference in New Issue