817 lines
42 KiB
HTML
817 lines
42 KiB
HTML
{% extends "base_tailwind.html" %}
|
|
|
|
{% block title %}教师课表 - {{ brand_name }}{% endblock %}
|
|
|
|
{% block extra_css %}
|
|
<style>
|
|
@keyframes fadeSlideIn {
|
|
from { opacity: 0; transform: translateY(8px); }
|
|
to { opacity: 1; transform: translateY(0); }
|
|
}
|
|
.row-animate { animation: fadeSlideIn 0.3s ease both; }
|
|
|
|
/* 课程格子入场动画 */
|
|
@keyframes cellFadeIn {
|
|
from { opacity: 0; transform: translateY(6px) scale(0.96); }
|
|
to { opacity: 1; transform: translateY(0) scale(1); }
|
|
}
|
|
.course-cell {
|
|
animation: cellFadeIn 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
|
|
}
|
|
|
|
/* 弹窗 */
|
|
#teacherModal {
|
|
opacity: 0;
|
|
pointer-events: none;
|
|
transition: opacity 0.22s ease;
|
|
}
|
|
#teacherModal.modal-open {
|
|
opacity: 1;
|
|
pointer-events: auto;
|
|
}
|
|
#teacherModal .modal-backdrop {
|
|
opacity: 0;
|
|
transition: opacity 0.22s ease;
|
|
}
|
|
#teacherModal.modal-open .modal-backdrop {
|
|
opacity: 1;
|
|
}
|
|
#teacherModal .modal-panel {
|
|
opacity: 0;
|
|
transform: scale(0.94) translateY(12px);
|
|
transition: opacity 0.22s ease, transform 0.26s cubic-bezier(0.22, 1, 0.36, 1);
|
|
}
|
|
#teacherModal.modal-open .modal-panel {
|
|
opacity: 1;
|
|
transform: scale(1) translateY(0);
|
|
}
|
|
|
|
/* 行悬停提示 */
|
|
.clickable-row { cursor: pointer; }
|
|
</style>
|
|
{% endblock %}
|
|
|
|
{% block content %}
|
|
<div>
|
|
<div class="flex flex-col md:flex-row justify-between items-start md:items-center gap-4 mb-6 list-item-enter" style="animation-delay: 0ms;">
|
|
<div>
|
|
<h2 class="text-2xl font-bold flex items-center gap-2">
|
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"
|
|
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/>
|
|
<circle cx="9" cy="7" r="4"/>
|
|
<path d="M23 21v-2a4 4 0 0 0-3-3.87"/>
|
|
<path d="M16 3.13a4 4 0 0 1 0 7.75"/>
|
|
</svg>
|
|
教师课表
|
|
</h2>
|
|
<p class="text-sm text-gray-500 dark:text-gray-400 mt-1">查询教师授课安排,点击教师行可预览课程表</p>
|
|
</div>
|
|
<div class="flex gap-2">
|
|
<button onclick="refresh()"
|
|
class="px-4 py-2 rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-black/30 text-sm font-medium hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors flex items-center gap-2">
|
|
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none"
|
|
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<polyline points="23 4 23 10 17 10"/>
|
|
<path d="M20.49 15a9 9 0 1 1-2.12-9.36L23 10"/>
|
|
</svg>
|
|
刷新
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 筛选条件 -->
|
|
<div class="glass rounded-2xl p-4 mb-4 list-item-enter max-w-5xl mx-auto" style="animation-delay: 50ms;">
|
|
<div class="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-3">
|
|
<div>
|
|
<label class="block text-xs text-gray-500 dark:text-gray-400 mb-1">学年</label>
|
|
<select id="fXnm" onchange="refresh()" class="w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-black/30 text-sm">
|
|
<option value="">全部</option>
|
|
<option value="2026" selected>2026-2027</option>
|
|
<option value="2025">2025-2026</option>
|
|
<option value="2024">2024-2025</option>
|
|
<option value="2023">2023-2024</option>
|
|
</select>
|
|
</div>
|
|
<div>
|
|
<label class="block text-xs text-gray-500 dark:text-gray-400 mb-1">学期</label>
|
|
<select id="fXqm" onchange="refresh()" class="w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-black/30 text-sm">
|
|
<option value="">全部</option>
|
|
<option value="3" selected>第1学期</option>
|
|
<option value="12">第2学期</option>
|
|
</select>
|
|
</div>
|
|
<div>
|
|
<label class="block text-xs text-gray-500 dark:text-gray-400 mb-1">校区</label>
|
|
<select id="fXqh" onchange="refresh()" class="w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-black/30 text-sm">
|
|
<option value="">全部</option>
|
|
<option value="1">长清校区</option>
|
|
</select>
|
|
</div>
|
|
<div>
|
|
<label class="block text-xs text-gray-500 dark:text-gray-400 mb-1">职称</label>
|
|
<select id="fZcm" onchange="refresh()" class="w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-black/30 text-sm">
|
|
<option value="">全部</option>
|
|
<option value="01">教授</option>
|
|
<option value="02">副教授</option>
|
|
<option value="03">讲师</option>
|
|
<option value="04">助教</option>
|
|
<option value="05">未评级</option>
|
|
</select>
|
|
</div>
|
|
<div>
|
|
<label class="block text-xs text-gray-500 dark:text-gray-400 mb-1">部门/学院</label>
|
|
<select id="fJg" onchange="refresh()" class="w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-black/30 text-sm">
|
|
<option value="">全部</option>
|
|
<option value="301">劳动关系学院</option>
|
|
<option value="302">工商学院</option>
|
|
<option value="303">会计学院</option>
|
|
<option value="304">艺术学院</option>
|
|
<option value="305">信息工程学院</option>
|
|
<option value="306">经贸学院</option>
|
|
<option value="307">智能工程学院</option>
|
|
<option value="308">人文学院</option>
|
|
<option value="311">马克思主义学院</option>
|
|
<option value="312">体育教学部</option>
|
|
<option value="313">国际交流学院</option>
|
|
</select>
|
|
</div>
|
|
<div>
|
|
<label class="block text-xs text-gray-500 dark:text-gray-400 mb-1">开课学院</label>
|
|
<select id="fKkbm" onchange="refresh()" class="w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-black/30 text-sm">
|
|
<option value="">全部</option>
|
|
<option value="301">劳动关系学院</option>
|
|
<option value="302">工商学院</option>
|
|
<option value="303">会计学院</option>
|
|
<option value="304">艺术学院</option>
|
|
<option value="305">信息工程学院</option>
|
|
<option value="306">经贸学院</option>
|
|
<option value="307">智能工程学院</option>
|
|
<option value="308">人文学院</option>
|
|
<option value="311">马克思主义学院</option>
|
|
<option value="312">体育教学部</option>
|
|
<option value="313">国际交流学院</option>
|
|
</select>
|
|
</div>
|
|
<div>
|
|
<label class="block text-xs text-gray-500 dark:text-gray-400 mb-1">教师工号/姓名</label>
|
|
<input id="fJgh" type="text" placeholder="可模糊搜索" onkeydown="if(event.key==='Enter')refresh()"
|
|
class="w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-black/30 text-sm">
|
|
</div>
|
|
</div>
|
|
<div class="flex gap-3 mt-3 items-center flex-wrap">
|
|
<label class="flex items-center gap-1.5 text-sm text-gray-600 dark:text-gray-400 cursor-pointer">
|
|
<input type="checkbox" id="fZxszjjs" onchange="refresh()" class="w-4 h-4 rounded accent-black dark:accent-white">
|
|
只显示主讲教师
|
|
</label>
|
|
<label class="flex items-center gap-1.5 text-sm text-gray-600 dark:text-gray-400 cursor-pointer">
|
|
<input type="checkbox" id="fSfwp" onchange="refresh()" class="w-4 h-4 rounded accent-black dark:accent-white">
|
|
仅显示外聘教师
|
|
</label>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 图表区域 -->
|
|
<div id="chartsRow" class="hidden grid grid-cols-1 md:grid-cols-2 gap-4 mb-4 list-item-enter" style="animation-delay: 120ms;">
|
|
<div class="glass rounded-2xl p-4">
|
|
<h4 class="text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3">职称分布</h4>
|
|
<div id="titleChart" style="height: 260px;"></div>
|
|
</div>
|
|
<div class="glass rounded-2xl p-4">
|
|
<h4 class="text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3">学院分布</h4>
|
|
<div id="deptChart" style="height: 260px;"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 加载中 -->
|
|
<div id="loadingIndicator" class="text-center py-12 list-item-enter" style="animation-delay: 100ms;">
|
|
<div class="w-10 h-10 border-2 border-black dark:border-white border-t-transparent rounded-full animate-spin mx-auto mb-4"></div>
|
|
<p class="text-gray-500 dark:text-gray-400">正在查询教师列表...</p>
|
|
</div>
|
|
|
|
<!-- 错误提示 -->
|
|
<div id="errorMessage" class="glass rounded-2xl p-6 mb-4 text-center hidden">
|
|
<p id="errorText" class="text-red-500"></p>
|
|
</div>
|
|
|
|
<!-- 结果 -->
|
|
<div id="dataContainer" class="hidden list-item-enter" style="animation-delay: 150ms;">
|
|
<div class="flex justify-between items-center mb-3 px-1">
|
|
<p class="text-sm text-gray-500 dark:text-gray-400">共 <span id="totalCount" class="font-bold text-black dark:text-white">0</span> 条记录</p>
|
|
<p class="text-xs text-gray-400 dark:text-gray-500">点击行可预览课程表</p>
|
|
</div>
|
|
<div class="glass rounded-2xl overflow-hidden">
|
|
<div class="overflow-x-auto">
|
|
<table class="w-full text-sm">
|
|
<thead>
|
|
<tr class="border-b border-gray-200 dark:border-gray-700 bg-gray-50/50 dark:bg-gray-800/50">
|
|
<th class="text-left py-3 px-4 font-semibold text-gray-700 dark:text-gray-300">#</th>
|
|
<th class="text-left py-3 px-4 font-semibold text-gray-700 dark:text-gray-300">工号</th>
|
|
<th class="text-left py-3 px-4 font-semibold text-gray-700 dark:text-gray-300">姓名</th>
|
|
<th class="text-left py-3 px-4 font-semibold text-gray-700 dark:text-gray-300">职称</th>
|
|
<th class="text-left py-3 px-4 font-semibold text-gray-700 dark:text-gray-300">所属学院</th>
|
|
<th class="text-left py-3 px-4 font-semibold text-gray-700 dark:text-gray-300">校区</th>
|
|
<th class="text-center py-3 px-4 font-semibold text-gray-700 dark:text-gray-300">电话</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="tableBody"></tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div id="emptyState" class="glass rounded-2xl p-12 text-center hidden">
|
|
<p class="text-gray-500 dark:text-gray-400 text-lg">暂无符合条件的教师</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 教师课表明细弹窗 -->
|
|
<div id="teacherModal" class="fixed inset-0 z-50 flex items-center justify-center p-4" aria-labelledby="modal-title" role="dialog" aria-modal="true">
|
|
<!-- 背景遮罩 -->
|
|
<div class="modal-backdrop fixed inset-0 bg-black/50 backdrop-blur-sm" onclick="closeTeacherModal()"></div>
|
|
|
|
<!-- 弹窗面板 -->
|
|
<div class="modal-panel relative glass rounded-2xl shadow-xl w-full max-w-2xl max-h-[85vh] flex flex-col overflow-hidden">
|
|
<!-- 顶部标题区 -->
|
|
<div class="flex items-center gap-3 p-5 pb-4 flex-shrink-0 border-b border-gray-200 dark:border-gray-700">
|
|
<div id="modalTeacherIcon" class="w-10 h-10 rounded-xl bg-blue-900/50 text-blue-100 flex items-center justify-center flex-shrink-0">
|
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path>
|
|
<circle cx="12" cy="7" r="4"></circle>
|
|
</svg>
|
|
</div>
|
|
<div class="min-w-0 flex-1">
|
|
<h3 id="modalTeacherName" class="text-lg font-bold text-gray-900 dark:text-white leading-tight truncate">--</h3>
|
|
<p id="modalTeacherInfo" class="text-sm text-gray-500 dark:text-gray-400 truncate">--</p>
|
|
</div>
|
|
<div class="flex items-center gap-2 flex-shrink-0">
|
|
<span id="modalCourseCount" class="px-2 py-1 rounded-full text-xs font-medium bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-300">0门课</span>
|
|
<button onclick="closeTeacherModal()" class="p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-full transition-colors">
|
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<line x1="18" y1="6" x2="6" y2="18"></line>
|
|
<line x1="6" y1="6" x2="18" y2="18"></line>
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 加载指示器 -->
|
|
<div id="modalLoading" class="flex-1 flex items-center justify-center py-12">
|
|
<div class="w-8 h-8 border-2 border-black dark:border-white border-t-transparent rounded-full animate-spin"></div>
|
|
</div>
|
|
|
|
<!-- 错误提示 -->
|
|
<div id="modalError" class="flex-1 flex items-center justify-center py-12 hidden">
|
|
<p id="modalErrorText" class="text-red-500 text-sm"></p>
|
|
</div>
|
|
|
|
<!-- 课表内容区 -->
|
|
<div id="modalContent" class="flex-1 overflow-y-auto p-4 hidden">
|
|
<!-- 视图切换 + 周次选择 -->
|
|
<div class="flex items-center justify-between gap-2 mb-3">
|
|
<div class="flex items-center gap-2">
|
|
<span class="text-xs text-gray-500 dark:text-gray-400">周次:</span>
|
|
<select id="modalWeekSelect" onchange="renderTeacherScheduleInModal()" class="px-2 py-1 rounded border border-gray-200 dark:border-gray-700 bg-white dark:bg-black/30 text-xs">
|
|
</select>
|
|
</div>
|
|
<div class="flex items-center gap-1 p-0.5 rounded-lg bg-gray-100 dark:bg-gray-800">
|
|
<button id="viewGridBtn" onclick="switchView('grid')" class="px-3 py-1 rounded-md text-xs font-medium bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm transition-all">网格</button>
|
|
<button id="viewListBtn" onclick="switchView('list')" class="px-3 py-1 rounded-md text-xs font-medium text-gray-500 dark:text-gray-400 transition-all">列表</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 课表网格视图 -->
|
|
<div id="gridView" class="overflow-x-auto">
|
|
<div class="grid gap-1 min-w-[320px]" id="teacherScheduleGrid" style="grid-template-columns: 48px repeat(7, 1fr); grid-template-rows: 32px repeat(11, minmax(48px, auto));">
|
|
<!-- 由 JS 动态生成 -->
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 列表视图 -->
|
|
<div id="listView" class="hidden overflow-x-auto">
|
|
<table class="w-full text-xs">
|
|
<thead>
|
|
<tr class="border-b border-gray-200 dark:border-gray-700 text-gray-500 dark:text-gray-400">
|
|
<th class="py-2 px-2 text-left font-medium">星期</th>
|
|
<th class="py-2 px-2 text-left font-medium">节次</th>
|
|
<th class="py-2 px-2 text-left font-medium">课程</th>
|
|
<th class="py-2 px-2 text-left font-medium">上课班级</th>
|
|
<th class="py-2 px-2 text-left font-medium">人数</th>
|
|
<th class="py-2 px-2 text-left font-medium">地点</th>
|
|
<th class="py-2 px-2 text-left font-medium">周次</th>
|
|
<th class="py-2 px-2 text-left font-medium">考核</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="listTableBody"></tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<!-- 空状态 -->
|
|
<div id="modalEmpty" class="text-center py-8 hidden">
|
|
<p class="text-gray-400 dark:text-gray-500 text-sm">该周次暂无课程</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{% block extra_js %}
|
|
<script src="{{ url_for('static', filename='echarts.min.js') }}"></script>
|
|
<script>
|
|
// ─── Session 自动刷新 ────────────────────────────────────────────
|
|
async function initSession() {
|
|
try {
|
|
const res = await fetch('/api/jwxt/ping');
|
|
const data = await res.json();
|
|
if (data.refreshed) console.log('[Session] 已刷新');
|
|
return true;
|
|
} catch (e) { console.warn('[Session] ping 失败:', e); return false; }
|
|
}
|
|
function isDarkMode() { return document.documentElement.classList.contains('dark'); }
|
|
// ─── 工具函数(复用 timetable.html 逻辑)──────────────────────────────
|
|
|
|
// 解析周次描述
|
|
function parseWeekRange(zcd) {
|
|
if (!zcd) return { start: 1, end: 20, isOdd: false, isEven: false };
|
|
const isOdd = zcd.includes('(单)');
|
|
const isEven = zcd.includes('(双)');
|
|
const clean = zcd.replace(/\([^)]*\)/g, '');
|
|
const segments = clean.split(',');
|
|
let minWeek = 20, maxWeek = 0;
|
|
for (const seg of segments) {
|
|
const match = seg.match(/(\d+)(?:-(\d+))?/);
|
|
if (match) {
|
|
const start = parseInt(match[1]);
|
|
const end = match[2] ? parseInt(match[2]) : start;
|
|
minWeek = Math.min(minWeek, start);
|
|
maxWeek = Math.max(maxWeek, end);
|
|
}
|
|
}
|
|
if (minWeek > maxWeek) return { start: 1, end: 20, isOdd, isEven };
|
|
return { start: minWeek, end: maxWeek, isOdd, isEven };
|
|
}
|
|
|
|
// 判断课程是否在指定周次
|
|
function isCourseInWeek(course, week) {
|
|
const zcd = course.zcd;
|
|
if (!zcd) return true;
|
|
const isOdd = zcd.includes('(单)');
|
|
const isEven = zcd.includes('(双)');
|
|
const clean = zcd.replace(/\([^)]*\)/g, '');
|
|
const segments = clean.split(',');
|
|
let inRange = false;
|
|
for (const seg of segments) {
|
|
const match = seg.match(/(\d+)(?:-(\d+))?/);
|
|
if (match) {
|
|
const start = parseInt(match[1]);
|
|
const end = match[2] ? parseInt(match[2]) : start;
|
|
if (start <= week && week <= end) { inRange = true; break; }
|
|
}
|
|
}
|
|
if (!inRange) return false;
|
|
if (isOdd && week % 2 === 0) return false;
|
|
if (isEven && week % 2 === 1) return false;
|
|
return true;
|
|
}
|
|
|
|
// 解析节数范围
|
|
function parsePeriodRange(jcor) {
|
|
if (!jcor || typeof jcor !== 'string') return { start: 1, end: 1 };
|
|
const parts = jcor.split(/[-,\s]+/).filter(p => p.trim());
|
|
if (parts.length >= 2) {
|
|
const s = parseInt(parts[0]);
|
|
const e = parseInt(parts[parts.length - 1]);
|
|
if (!isNaN(s) && !isNaN(e) && s > 0 && e > 0) return { start: s, end: e };
|
|
}
|
|
const p = parseInt(jcor);
|
|
if (!isNaN(p) && p > 0) return { start: p, end: p };
|
|
return { start: 1, end: 1 };
|
|
}
|
|
|
|
// 课程图标
|
|
function getCourseIcon(name) {
|
|
const n = name || '';
|
|
function has(...keys) { return keys.some(k => n.includes(k)); }
|
|
const icons = {
|
|
math: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="9" y1="9" x2="15" y2="9"/><line x1="12" y1="6" x2="12" y2="12"/><line x1="9" y1="15" x2="15" y2="15"/></svg>`,
|
|
code: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>`,
|
|
default: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z"/><path d="M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z"/></svg>`
|
|
};
|
|
if (has('数学', '微积分', '线性代数', '概率', '统计学')) return icons.math;
|
|
if (has('C语言', 'C++', 'Java', 'Python', '编程', '程序设计', '算法', '数据结构', '计算机', 'Web', '软件')) return icons.code;
|
|
return icons.default;
|
|
}
|
|
|
|
// 课程颜色
|
|
const COURSE_COLORS = [
|
|
{ bg: 'bg-blue-900/50', border: 'border-blue-700/70', text: 'text-blue-100' },
|
|
{ bg: 'bg-emerald-900/50', border: 'border-emerald-700/70', text: 'text-emerald-100' },
|
|
{ bg: 'bg-violet-900/50', border: 'border-violet-700/70', text: 'text-violet-100' },
|
|
{ bg: 'bg-amber-900/50', border: 'border-amber-700/70', text: 'text-amber-100' },
|
|
{ bg: 'bg-rose-900/50', border: 'border-rose-700/70', text: 'text-rose-100' },
|
|
{ bg: 'bg-cyan-900/50', border: 'border-cyan-700/70', text: 'text-cyan-100' },
|
|
{ bg: 'bg-lime-900/50', border: 'border-lime-700/70', text: 'text-lime-100' },
|
|
{ bg: 'bg-fuchsia-900/50', border: 'border-fuchsia-700/70', text: 'text-fuchsia-100' },
|
|
];
|
|
const courseColorMap = new Map();
|
|
function getCourseColor(name) {
|
|
if (!courseColorMap.has(name)) {
|
|
let h = 0; for (let i = 0; i < name.length; i++) h = name.charCodeAt(i) + ((h << 5) - h);
|
|
courseColorMap.set(name, Math.abs(h) % COURSE_COLORS.length);
|
|
}
|
|
return COURSE_COLORS[courseColorMap.get(name)];
|
|
}
|
|
|
|
// 节次时间
|
|
const PERIOD_TIMES = {
|
|
1: { start: '08:30', end: '09:15' }, 2: { start: '09:20', end: '10:05' },
|
|
3: { start: '10:25', end: '11:10' }, 4: { start: '11:15', end: '12:00' },
|
|
5: { start: '14:00', end: '14:45' }, 6: { start: '14:55', end: '15:40' },
|
|
7: { start: '16:00', end: '16:45' }, 8: { start: '16:55', end: '17:40' },
|
|
9: { start: '19:00', end: '19:45' }, 10: { start: '19:55', end: '20:40' },
|
|
11: { start: '20:45', end: '21:30' },
|
|
};
|
|
|
|
// 全局变量
|
|
let teacherModalData = null; // 当前教师的 kbList
|
|
let teacherModalWeek = 1; // 当前选择的周次
|
|
let teacherModalWeekCount = 20; // 最大周次
|
|
|
|
// ─── 弹窗控制 ─────────────────────────────────────────────────────────
|
|
|
|
function openTeacherModal(jgh_id, jgh, xm, jgmc, zcmc) {
|
|
const modal = document.getElementById('teacherModal');
|
|
document.getElementById('modalTeacherName').textContent = xm || jgh;
|
|
document.getElementById('modalTeacherInfo').textContent = [jgmc, zcmc].filter(Boolean).join(' · ') || jgh;
|
|
document.getElementById('modalLoading').classList.remove('hidden');
|
|
document.getElementById('modalError').classList.add('hidden');
|
|
document.getElementById('modalContent').classList.add('hidden');
|
|
document.getElementById('modalEmpty').classList.add('hidden');
|
|
|
|
// 当前页面的学年学期
|
|
const xnm = document.getElementById('fXnm').value || '2026';
|
|
const xqm = document.getElementById('fXqm').value || '3';
|
|
|
|
fetch(`/api/jwxt/teacher-schedule-detail?jgh_id=${encodeURIComponent(jgh_id)}&xnm=${xnm}&xqm=${xqm}`)
|
|
.then(r => r.json())
|
|
.then(data => {
|
|
document.getElementById('modalLoading').classList.add('hidden');
|
|
if (!data.success) {
|
|
document.getElementById('modalErrorText').textContent = data.message || '加载失败';
|
|
document.getElementById('modalError').classList.remove('hidden');
|
|
return;
|
|
}
|
|
teacherModalData = data.kbList || [];
|
|
|
|
// 计算最大周次
|
|
teacherModalWeekCount = 20;
|
|
teacherModalData.forEach(item => {
|
|
const w = parseWeekRange(item.zcd);
|
|
if (w.end > 0 && w.end < 25) teacherModalWeekCount = Math.max(teacherModalWeekCount, w.end);
|
|
});
|
|
|
|
// 填充周次选择
|
|
const weekSelect = document.getElementById('modalWeekSelect');
|
|
weekSelect.innerHTML = '';
|
|
for (let i = 1; i <= teacherModalWeekCount; i++) {
|
|
weekSelect.innerHTML += `<option value="${i}">第${i}周</option>`;
|
|
}
|
|
weekSelect.value = 1;
|
|
teacherModalWeek = 1;
|
|
|
|
document.getElementById('modalCourseCount').textContent = `${teacherModalData.length}门课`;
|
|
document.getElementById('modalContent').classList.remove('hidden');
|
|
renderTeacherScheduleInModal();
|
|
})
|
|
.catch(err => {
|
|
document.getElementById('modalLoading').classList.add('hidden');
|
|
document.getElementById('modalErrorText').textContent = '网络错误: ' + err.message;
|
|
document.getElementById('modalError').classList.remove('hidden');
|
|
});
|
|
|
|
modal.classList.add('modal-open');
|
|
document.documentElement.style.overflow = 'hidden';
|
|
document.body.style.overflow = 'hidden';
|
|
}
|
|
|
|
function closeTeacherModal() {
|
|
const modal = document.getElementById('teacherModal');
|
|
modal.classList.remove('modal-open');
|
|
document.documentElement.style.overflow = '';
|
|
document.body.style.overflow = '';
|
|
teacherModalData = null;
|
|
}
|
|
|
|
function renderTeacherScheduleInModal() {
|
|
if (!teacherModalData) return;
|
|
const week = parseInt(document.getElementById('modalWeekSelect').value);
|
|
teacherModalWeek = week;
|
|
|
|
const grid = document.getElementById('teacherScheduleGrid');
|
|
const emptyDiv = document.getElementById('modalEmpty');
|
|
|
|
// 表头
|
|
let html = `
|
|
<!-- 空角 -->
|
|
<div class="bg-white/50 dark:bg-gray-900/50 rounded-lg flex items-center justify-center text-[10px] font-bold text-gray-500 dark:text-gray-400" style="grid-column:1;grid-row:1;"></div>
|
|
<div class="bg-white/50 dark:bg-gray-900/50 rounded-lg text-center text-[10px] font-bold text-gray-600 dark:text-gray-300 flex items-center justify-center" style="grid-column:2;grid-row:1;">周一</div>
|
|
<div class="bg-white/50 dark:bg-gray-900/50 rounded-lg text-center text-[10px] font-bold text-gray-600 dark:text-gray-300 flex items-center justify-center" style="grid-column:3;grid-row:1;">周二</div>
|
|
<div class="bg-white/50 dark:bg-gray-900/50 rounded-lg text-center text-[10px] font-bold text-gray-600 dark:text-gray-300 flex items-center justify-center" style="grid-column:4;grid-row:1;">周三</div>
|
|
<div class="bg-white/50 dark:bg-gray-900/50 rounded-lg text-center text-[10px] font-bold text-gray-600 dark:text-gray-300 flex items-center justify-center" style="grid-column:5;grid-row:1;">周四</div>
|
|
<div class="bg-white/50 dark:bg-gray-900/50 rounded-lg text-center text-[10px] font-bold text-gray-600 dark:text-gray-300 flex items-center justify-center" style="grid-column:6;grid-row:1;">周五</div>
|
|
<div class="bg-white/50 dark:bg-gray-900/50 rounded-lg text-center text-[10px] font-bold text-gray-600 dark:text-gray-300 flex items-center justify-center" style="grid-column:7;grid-row:1;">周六</div>
|
|
<div class="bg-white/50 dark:bg-gray-900/50 rounded-lg text-center text-[10px] font-bold text-gray-600 dark:text-gray-300 flex items-center justify-center" style="grid-column:8;grid-row:1;">周日</div>
|
|
`;
|
|
|
|
// 节次行
|
|
for (let p = 1; p <= 11; p++) {
|
|
const ti = PERIOD_TIMES[p] || { start: '', end: '' };
|
|
html += `
|
|
<div class="bg-white/30 dark:bg-gray-900/30 rounded-lg flex flex-col items-center justify-center text-[9px] text-gray-500 dark:text-gray-400" style="grid-column:1;grid-row:${p+1};">
|
|
<div class="font-bold text-gray-700 dark:text-gray-300">${p}</div>
|
|
<div>${ti.start}</div>
|
|
</div>
|
|
`;
|
|
}
|
|
|
|
// 课程格子占位(7列)
|
|
for (let d = 0; d < 7; d++) {
|
|
for (let p = 1; p <= 11; p++) {
|
|
html += `<div class="bg-gray-50/20 dark:bg-gray-800/10 rounded border border-gray-200/30 dark:border-gray-700/20" style="grid-column:${d+2};grid-row:${p+1};"></div>`;
|
|
}
|
|
}
|
|
|
|
grid.innerHTML = html;
|
|
|
|
// 渲染课程
|
|
const courseGrid = Array(11).fill(null).map(() => Array(7).fill(null));
|
|
let courseCount = 0;
|
|
|
|
teacherModalData.forEach(item => {
|
|
if (!isCourseInWeek(item, week)) return;
|
|
const dayIndex = item.xqj - 1;
|
|
if (isNaN(dayIndex) || dayIndex < 0 || dayIndex > 6) return;
|
|
const pr = parsePeriodRange(item.skjc);
|
|
for (let p = pr.start; p <= pr.end; p++) {
|
|
if (p >= 1 && p <= 11) {
|
|
const pi = p - 1;
|
|
if (!courseGrid[pi][dayIndex]) {
|
|
courseGrid[pi][dayIndex] = { item, isStart: p === pr.start, rowSpan: pr.end - pr.start + 1 };
|
|
}
|
|
}
|
|
}
|
|
courseCount++;
|
|
});
|
|
|
|
// 写入课程
|
|
courseGrid.forEach((row, pi) => {
|
|
row.forEach((cell, di) => {
|
|
if (cell && cell.isStart) {
|
|
const color = getCourseColor(cell.item.kcmc);
|
|
const delay = Math.min(di * 40 + pi * 15, 300);
|
|
const cls = `course-cell rounded-lg overflow-hidden ${color.bg} ${color.text} border-l-4 ${color.border} flex flex-col justify-center p-1`;
|
|
const rowStyle = `grid-column:${di+2};grid-row:${pi+2}/span ${cell.rowSpan};animation-delay:${delay}ms;`;
|
|
const parts = [cell.item.kcmc, cell.item.cdmc || '无地点', cell.item.zcd || ''];
|
|
if (cell.item.jxbzcbjjc) parts.push('班级: ' + cell.item.jxbzcbjjc);
|
|
if (cell.item.jxbrs) parts.push('人数: ' + cell.item.jxbrs);
|
|
if (cell.item.khfsmc) parts.push(cell.item.khfsmc);
|
|
const title = parts.join('\n');
|
|
grid.innerHTML += `<div class="${cls}" style="${rowStyle}" title="${title.replace(/\n/g,' ')}">
|
|
<div class="font-bold text-[10px] leading-tight mb-0.5">${cell.item.kcmc}</div>
|
|
<div class="text-[9px] opacity-80">${cell.item.cdmc || ''}</div>
|
|
<div class="text-[9px] opacity-60">${cell.item.skjc}</div>
|
|
</div>`;
|
|
}
|
|
});
|
|
});
|
|
|
|
emptyDiv.classList.toggle('hidden', courseCount > 0);
|
|
renderListView(week);
|
|
}
|
|
|
|
// ─── 视图切换 ─────────────────────────────────────────────────────
|
|
|
|
let currentView = 'grid';
|
|
|
|
function switchView(view) {
|
|
currentView = view;
|
|
const grid = document.getElementById('gridView');
|
|
const list = document.getElementById('listView');
|
|
const gridBtn = document.getElementById('viewGridBtn');
|
|
const listBtn = document.getElementById('viewListBtn');
|
|
if (view === 'grid') {
|
|
grid.classList.remove('hidden');
|
|
list.classList.add('hidden');
|
|
gridBtn.className = 'px-3 py-1 rounded-md text-xs font-medium bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm transition-all';
|
|
listBtn.className = 'px-3 py-1 rounded-md text-xs font-medium text-gray-500 dark:text-gray-400 transition-all';
|
|
} else {
|
|
grid.classList.add('hidden');
|
|
list.classList.remove('hidden');
|
|
listBtn.className = 'px-3 py-1 rounded-md text-xs font-medium bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm transition-all';
|
|
gridBtn.className = 'px-3 py-1 rounded-md text-xs font-medium text-gray-500 dark:text-gray-400 transition-all';
|
|
}
|
|
}
|
|
|
|
function renderListView(week) {
|
|
const tbody = document.getElementById('listTableBody');
|
|
if (!tbody) return;
|
|
const weekItems = teacherModalData.filter(item => isCourseInWeek(item, week));
|
|
const dayNames = ['', '周一', '周二', '周三', '周四', '周五', '周六', '周日'];
|
|
if (weekItems.length === 0) {
|
|
tbody.innerHTML = '<tr><td colspan="8" class="py-4 text-center text-gray-400 dark:text-gray-500">该周次暂无课程</td></tr>';
|
|
return;
|
|
}
|
|
tbody.innerHTML = weekItems.map((item, idx) => {
|
|
const color = getCourseColor(item.kcmc);
|
|
return `<tr class="border-b border-gray-100 dark:border-gray-800 hover:bg-gray-50/50 dark:hover:bg-gray-800/30">
|
|
<td class="py-2 px-2 text-gray-600 dark:text-gray-300">${dayNames[item.xqj] || '--'}</td>
|
|
<td class="py-2 px-2 text-gray-500 dark:text-gray-400">${item.skjc || '--'}</td>
|
|
<td class="py-2 px-2 font-medium text-gray-900 dark:text-white">${escHtml(item.kcmc || '--')}${item.xslxbj ? ' <span class="text-amber-500">' + escHtml(item.xslxbj) + '</span>' : ''}</td>
|
|
<td class="py-2 px-2 text-gray-500 dark:text-gray-400">${escHtml(item.jxbzcbjjc || '--')}</td>
|
|
<td class="py-2 px-2 text-gray-500 dark:text-gray-400 text-center">${item.jxbrs || '--'}</td>
|
|
<td class="py-2 px-2 text-gray-500 dark:text-gray-400">${escHtml(item.cdmc || '--')}</td>
|
|
<td class="py-2 px-2 text-gray-500 dark:text-gray-400 whitespace-nowrap">${item.zcd || '--'}</td>
|
|
<td class="py-2 px-2 text-gray-500 dark:text-gray-400">${item.khfsmc || '--'}</td>
|
|
</tr>`;
|
|
}).join('');
|
|
}
|
|
|
|
// ─── ECharts 图表 ─────────────────────────────────────────────────
|
|
let titleChart = null;
|
|
let deptChart = null;
|
|
|
|
function renderTitleChart(items) {
|
|
const dom = document.getElementById('titleChart');
|
|
if (!dom) return;
|
|
|
|
const titleMap = {};
|
|
items.forEach(item => { const t = item.zcmc || '未评级'; titleMap[t] = (titleMap[t] || 0) + 1; });
|
|
const data = Object.entries(titleMap).map(([name, value]) => ({ name, value }));
|
|
|
|
const dark = isDarkMode();
|
|
if (!titleChart) titleChart = echarts.init(dom);
|
|
titleChart.setOption({
|
|
tooltip: { trigger: 'item', formatter: '{b}: {c} 人 ({d}%)' },
|
|
legend: { bottom: 0, textStyle: { color: dark ? '#9ca3af' : '#6b7280', fontSize: 11 } },
|
|
series: [{
|
|
type: 'pie', radius: ['45%', '72%'], center: ['50%', '48%'],
|
|
itemStyle: { borderRadius: 6, borderColor: dark ? '#1f2937' : '#fff', borderWidth: 2 },
|
|
label: { color: dark ? '#d1d5db' : '#374151', fontSize: 11 },
|
|
data: data
|
|
}]
|
|
}, { notMerge: true });
|
|
titleChart.resize();
|
|
}
|
|
|
|
function renderDeptChart(items) {
|
|
const dom = document.getElementById('deptChart');
|
|
if (!dom) return;
|
|
|
|
const deptMap = {};
|
|
items.forEach(item => { const d = item.jgmc || '未知'; deptMap[d] = (deptMap[d] || 0) + 1; });
|
|
const sorted = Object.entries(deptMap).sort((a, b) => b[1] - a[1]);
|
|
|
|
const dark = isDarkMode();
|
|
if (!deptChart) deptChart = echarts.init(dom);
|
|
deptChart.setOption({
|
|
tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' } },
|
|
grid: { left: '3%', right: '10%', top: 10, bottom: 30, containLabel: true },
|
|
xAxis: {
|
|
type: 'value', name: '教师数',
|
|
nameTextStyle: { color: dark ? '#9ca3af' : '#6b7280' },
|
|
axisLabel: { color: dark ? '#9ca3af' : '#6b7280' }
|
|
},
|
|
yAxis: {
|
|
type: 'category', data: sorted.map(s => s[0]),
|
|
axisLabel: { color: dark ? '#9ca3af' : '#6b7280', fontSize: 10 },
|
|
inverse: true
|
|
},
|
|
series: [{
|
|
type: 'bar', data: sorted.map(s => s[1]),
|
|
itemStyle: { color: dark ? '#818cf8' : '#4f46e5', borderRadius: [0, 6, 6, 0] },
|
|
emphasis: { itemStyle: { color: dark ? '#a5b4fc' : '#6366f1' } }
|
|
}]
|
|
}, { notMerge: true });
|
|
deptChart.resize();
|
|
}
|
|
|
|
function setupDarkObserver() {
|
|
const observer = new MutationObserver(() => {
|
|
if (titleChart) { titleChart.dispose(); titleChart = null; }
|
|
if (deptChart) { deptChart.dispose(); deptChart = null; }
|
|
const items = window._lastTeacherItems;
|
|
if (items && items.length) {
|
|
renderCharts(items);
|
|
}
|
|
});
|
|
observer.observe(document.documentElement, { attributes: true, attributeFilter: ['class'] });
|
|
}
|
|
|
|
function renderCharts(items) {
|
|
const row = document.getElementById('chartsRow');
|
|
if (row) row.classList.remove('hidden');
|
|
renderTitleChart(items);
|
|
renderDeptChart(items);
|
|
}
|
|
|
|
window.addEventListener('resize', () => {
|
|
if (titleChart) titleChart.resize();
|
|
if (deptChart) deptChart.resize();
|
|
});
|
|
|
|
// ─── 列表渲染 ─────────────────────────────────────────────────────────
|
|
|
|
async function refresh() {
|
|
document.getElementById('loadingIndicator').classList.remove('hidden');
|
|
document.getElementById('errorMessage').classList.add('hidden');
|
|
document.getElementById('dataContainer').classList.add('hidden');
|
|
document.getElementById('chartsRow').classList.add('hidden');
|
|
|
|
const xnm = document.getElementById('fXnm').value;
|
|
const xqm = document.getElementById('fXqm').value;
|
|
const xqh_id = document.getElementById('fXqh').value;
|
|
const zcm = document.getElementById('fZcm').value;
|
|
const jg_id = document.getElementById('fJg').value;
|
|
const kkbm_id = document.getElementById('fKkbm').value;
|
|
const jgh = document.getElementById('fJgh').value;
|
|
const zxszjjs = document.getElementById('fZxszjjs').checked ? '1' : '0';
|
|
const sfwp = document.getElementById('fSfwp').checked ? '1' : '0';
|
|
|
|
const params = new URLSearchParams({ page_size: 1000 });
|
|
if (xnm) params.set('xnm', xnm);
|
|
if (xqm) params.set('xqm', xqm);
|
|
if (xqh_id) params.set('xqh_id', xqh_id);
|
|
if (zcm) params.set('zcm', zcm);
|
|
if (jg_id) params.set('jg_id', jg_id);
|
|
if (kkbm_id) params.set('kkbm_id', kkbm_id);
|
|
if (jgh) params.set('jgh', jgh);
|
|
if (zxszjjs === '1') params.set('zxszjjs', '1');
|
|
if (sfwp === '1') params.set('sfwp', '1');
|
|
|
|
try {
|
|
const res = await fetch('/api/jwxt/teacher-schedule?' + params.toString());
|
|
const data = await res.json();
|
|
document.getElementById('loadingIndicator').classList.add('hidden');
|
|
|
|
if (!data.success) {
|
|
document.getElementById('errorText').textContent = data.message || '查询失败';
|
|
document.getElementById('errorMessage').classList.remove('hidden');
|
|
return;
|
|
}
|
|
|
|
const items = data.items || [];
|
|
window._lastTeacherItems = items;
|
|
document.getElementById('totalCount').textContent = data.total || items.length;
|
|
if (!items.length) {
|
|
document.getElementById('dataContainer').classList.remove('hidden');
|
|
document.getElementById('emptyState').classList.remove('hidden');
|
|
return;
|
|
}
|
|
renderTable(items);
|
|
document.getElementById('dataContainer').classList.remove('hidden');
|
|
renderCharts(items);
|
|
} catch (e) {
|
|
document.getElementById('loadingIndicator').classList.add('hidden');
|
|
document.getElementById('errorText').textContent = '网络错误: ' + e.message;
|
|
document.getElementById('errorMessage').classList.remove('hidden');
|
|
}
|
|
}
|
|
|
|
function renderTable(items) {
|
|
const tbody = document.getElementById('tableBody');
|
|
tbody.innerHTML = items.map((item, idx) => {
|
|
const campus = item.xqh_id === '1' ? '长清校区' : (item.xqh_id || '--');
|
|
return `<tr class="clickable-row border-b border-gray-100 dark:border-gray-800 hover:bg-gray-50/50 dark:hover:bg-gray-800/30 transition-colors row-animate" style="animation-delay:${idx * 30}ms;"
|
|
onclick="openTeacherModal(${JSON.stringify(item.jgh_id||'').replace(/"/g,'"')}, ${JSON.stringify(item.jgh||'').replace(/"/g,'"')}, ${JSON.stringify(item.xm||'').replace(/"/g,'"')}, ${JSON.stringify(item.jgmc||'').replace(/"/g,'"')}, ${JSON.stringify(item.zcmc||'').replace(/"/g,'"')})">
|
|
<td class="py-3 px-4 text-gray-400 dark:text-gray-500">${idx + 1}</td>
|
|
<td class="py-3 px-4 font-mono text-xs text-gray-500 dark:text-gray-400">${item.jgh || '--'}</td>
|
|
<td class="py-3 px-4 font-medium">${escHtml(item.xm || '--')}</td>
|
|
<td class="py-3 px-4 text-gray-500 dark:text-gray-400">${item.zcmc || '--'}</td>
|
|
<td class="py-3 px-4 text-gray-500 dark:text-gray-400">${escHtml(item.jgmc || '--')}</td>
|
|
<td class="py-3 px-4 text-gray-500 dark:text-gray-400">${campus}</td>
|
|
<td class="py-3 px-4 text-center text-gray-500 dark:text-gray-400 text-xs">${item.sjhm || '--'}</td>
|
|
</tr>`;
|
|
}).join('');
|
|
}
|
|
|
|
function escHtml(str) {
|
|
return String(str).replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');
|
|
}
|
|
|
|
// ─── 初始化 ────────────────────────────────────────────────────────────
|
|
|
|
document.addEventListener('DOMContentLoaded', function () {
|
|
// 将弹窗移到 body 直接子级
|
|
const modal = document.getElementById('teacherModal');
|
|
if (modal) document.body.appendChild(modal);
|
|
|
|
setupDarkObserver();
|
|
initSession().then(() => refresh());
|
|
|
|
// ESC 关闭弹窗
|
|
document.addEventListener('keydown', function (e) {
|
|
if (e.key === 'Escape') closeTeacherModal();
|
|
});
|
|
});
|
|
</script>
|
|
{% endblock %}
|