1509 lines
68 KiB
HTML
1509 lines
68 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; }
|
|
|
|
/* Tab 内容区 */
|
|
.tab-content-wrap {
|
|
min-height: 200px;
|
|
}
|
|
/* 修读要求 iframe */
|
|
#requirementsFrame {
|
|
width: 100%;
|
|
min-height: 500px;
|
|
border: none;
|
|
background: #fff;
|
|
}
|
|
.dark #requirementsFrame {
|
|
background: #1a1a2e;
|
|
}
|
|
|
|
/* 修读要求 HTML (回退直接渲染) */
|
|
#requirementsContent table {
|
|
width: 100%;
|
|
border-collapse: collapse;
|
|
font-size: 14px;
|
|
}
|
|
#requirementsContent table th,
|
|
#requirementsContent table td {
|
|
border: 1px solid #e5e7eb;
|
|
padding: 8px 12px;
|
|
text-align: left;
|
|
}
|
|
.dark #requirementsContent table th,
|
|
.dark #requirementsContent table td {
|
|
border-color: #374151;
|
|
}
|
|
#requirementsContent table th {
|
|
background: #f9fafb;
|
|
font-weight: 600;
|
|
}
|
|
.dark #requirementsContent table th {
|
|
background: #1f2937;
|
|
}
|
|
|
|
/* 课程表格 - 增强 */
|
|
#coursesContent {
|
|
overflow-x: auto;
|
|
-webkit-overflow-scrolling: touch;
|
|
}
|
|
#coursesContent .course-table {
|
|
width: 100%;
|
|
min-width: 800px;
|
|
border-collapse: collapse;
|
|
font-size: 13px;
|
|
}
|
|
#coursesContent .course-table th,
|
|
#coursesContent .course-table td {
|
|
border-bottom: 1px solid #e5e7eb;
|
|
padding: 8px 10px;
|
|
text-align: left;
|
|
vertical-align: middle;
|
|
}
|
|
.dark #coursesContent .course-table th,
|
|
.dark #coursesContent .course-table td {
|
|
border-bottom-color: #374151;
|
|
}
|
|
#coursesContent .course-table thead th {
|
|
background: #f9fafb;
|
|
font-weight: 600;
|
|
position: sticky;
|
|
top: 0;
|
|
z-index: 5;
|
|
}
|
|
.dark #coursesContent .course-table thead th {
|
|
background: #1f2937;
|
|
}
|
|
/* sticky 序号列 */
|
|
#coursesContent .course-table th.sticky,
|
|
#coursesContent .course-table td.sticky {
|
|
position: sticky;
|
|
left: 0;
|
|
}
|
|
#coursesContent .course-table th.sticky {
|
|
z-index: 10;
|
|
background: #f9fafb;
|
|
}
|
|
.dark #coursesContent .course-table th.sticky {
|
|
background: #1f2937;
|
|
}
|
|
#coursesContent .course-table td.sticky {
|
|
z-index: 9;
|
|
background: #fff;
|
|
}
|
|
.dark #coursesContent .course-table td.sticky {
|
|
background: #111827;
|
|
}
|
|
#coursesContent .course-table tr:hover td {
|
|
background: #f9fafb;
|
|
}
|
|
#coursesContent .course-table tr:hover td.sticky {
|
|
background: #f3f4f6;
|
|
}
|
|
.dark #coursesContent .course-table tr:hover td {
|
|
background: #1f2937;
|
|
}
|
|
.dark #coursesContent .course-table tr:hover td.sticky {
|
|
background: #1a2332;
|
|
}
|
|
#coursesContent .course-table td {
|
|
color: #374151;
|
|
}
|
|
.dark #coursesContent .course-table td {
|
|
color: #d1d5db;
|
|
}
|
|
|
|
/* 预览 iframe / embed */
|
|
#previewContent iframe,
|
|
#previewContent embed {
|
|
width: 100%;
|
|
border: none;
|
|
min-height: 500px;
|
|
background: #fff;
|
|
}
|
|
|
|
/* 空提示 */
|
|
.no-selection-hint {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
min-height: 200px;
|
|
color: #9ca3af;
|
|
font-size: 14px;
|
|
}
|
|
|
|
/* 权限警告(橙/黄) */
|
|
.permission-warning {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
min-height: 200px;
|
|
color: #d97706;
|
|
text-align: center;
|
|
gap: 8px;
|
|
}
|
|
.permission-warning .warning-icon {
|
|
width: 40px;
|
|
height: 40px;
|
|
opacity: 0.6;
|
|
}
|
|
.permission-warning .warning-title {
|
|
font-size: 15px;
|
|
font-weight: 600;
|
|
}
|
|
.permission-warning .warning-desc {
|
|
font-size: 13px;
|
|
color: #92400e;
|
|
max-width: 320px;
|
|
line-height: 1.5;
|
|
}
|
|
|
|
/* 空数据提示 */
|
|
.empty-data-hint {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
min-height: 200px;
|
|
color: #9ca3af;
|
|
font-size: 14px;
|
|
gap: 8px;
|
|
}
|
|
|
|
/* ── 修读要求原生树形视图 ─────────────────────────── */
|
|
.requirements-tree .tree-children {
|
|
overflow: hidden;
|
|
transition: all 0.25s ease;
|
|
border-left: 2px solid #e5e7eb;
|
|
margin-left: 1.25rem;
|
|
}
|
|
.requirements-tree .tree-children.collapsed {
|
|
display: none;
|
|
}
|
|
.dark .requirements-tree .tree-children {
|
|
border-left-color: #374151;
|
|
}
|
|
.requirements-tree .tree-item {
|
|
transition: all 0.2s ease;
|
|
}
|
|
.requirements-tree .tree-toggle {
|
|
cursor: pointer;
|
|
user-select: none;
|
|
}
|
|
.requirements-tree .tree-chevron {
|
|
width: 16px;
|
|
height: 16px;
|
|
flex-shrink: 0;
|
|
color: #9ca3af;
|
|
transition: transform 0.2s ease;
|
|
}
|
|
.requirements-tree .tree-chevron.collapsed {
|
|
transform: rotate(-90deg);
|
|
}
|
|
.requirements-tree .tree-leaf-icon {
|
|
width: 16px;
|
|
height: 16px;
|
|
flex-shrink: 0;
|
|
color: #d1d5db;
|
|
}
|
|
.requirements-tree .tree-row {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
padding: 8px 12px;
|
|
transition: background-color 0.15s ease;
|
|
}
|
|
.requirements-tree .tree-row:hover {
|
|
background-color: rgba(0,0,0,0.03);
|
|
}
|
|
.dark .requirements-tree .tree-row:hover {
|
|
background-color: rgba(255,255,255,0.04);
|
|
}
|
|
.requirements-tree .tree-name {
|
|
flex: 1;
|
|
min-width: 0;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
}
|
|
.requirements-tree .tree-credits {
|
|
font-size: 12px;
|
|
color: #6b7280;
|
|
flex-shrink: 0;
|
|
min-width: 4rem;
|
|
text-align: right;
|
|
}
|
|
.dark .requirements-tree .tree-credits {
|
|
color: #9ca3af;
|
|
}
|
|
.requirements-tree .tree-relation {
|
|
font-size: 11px;
|
|
padding: 1px 6px;
|
|
border-radius: 10px;
|
|
flex-shrink: 0;
|
|
background: #f3f4f6;
|
|
color: #6b7280;
|
|
font-weight: 500;
|
|
}
|
|
.dark .requirements-tree .tree-relation {
|
|
background: #1f2937;
|
|
color: #9ca3af;
|
|
}
|
|
.requirements-tree .tree-relation.or {
|
|
background: #fef3c7;
|
|
color: #92400e;
|
|
}
|
|
.dark .requirements-tree .tree-relation.or {
|
|
background: #422006;
|
|
color: #fbbf24;
|
|
}
|
|
/* 缩进层次 */
|
|
.req-indent-0 { padding-left: 0.25rem; }
|
|
.req-indent-1 { padding-left: 1.5rem; }
|
|
.req-indent-2 { padding-left: 2.75rem; }
|
|
.req-indent-3 { padding-left: 4rem; }
|
|
.req-indent-4 { padding-left: 5.25rem; }
|
|
</style>
|
|
{% endblock %}
|
|
|
|
{% block content %}
|
|
<div>
|
|
<div class="flex flex-col md:flex-row justify-between items-start md:items-center gap-4 mb-4 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">
|
|
<rect x="3" y="3" width="7" height="7"/>
|
|
<rect x="14" y="3" width="7" height="7"/>
|
|
<rect x="14" y="14" width="7" height="7"/>
|
|
<rect x="3" y="14" width="7" height="7"/>
|
|
</svg>
|
|
教学执行计划
|
|
</h2>
|
|
<p class="text-sm text-gray-500 dark:text-gray-400 mt-1">查看各专业教学执行计划安排</p>
|
|
</div>
|
|
<div class="flex flex-wrap gap-3 items-center">
|
|
<button onclick="locateMyPlan()" id="locateMyPlanBtn"
|
|
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 whitespace-nowrap">
|
|
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
<circle cx="12" cy="10" r="3"/><path d="M12 21.7C17.3 17 20 13 20 10a8 8 0 10-16 0c0 3 2.7 7 8 11.7z"/>
|
|
</svg>
|
|
我的专业
|
|
</button>
|
|
<select id="njdmSelect" class="px-4 py-2 rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-black/30 text-sm">
|
|
<option value="">全部年级</option>
|
|
</select>
|
|
<input id="zyhInput" type="text" placeholder="专业号(可选)" class="px-4 py-2 rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-black/30 text-sm w-32">
|
|
<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">
|
|
刷新
|
|
</button>
|
|
</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="xzChart" 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="gradeChart" 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="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-center py-3 px-4 font-semibold text-gray-700 dark:text-gray-300 w-10">
|
|
<input type="checkbox" id="selectAll" class="w-4 h-4 rounded accent-black dark:accent-white cursor-pointer" onchange="toggleSelectAll()">
|
|
</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>
|
|
<th class="text-center 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>
|
|
<th class="text-center 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>
|
|
</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>
|
|
|
|
<!-- 详情 Tab 区域 -->
|
|
<div id="detailSection" class="hidden mt-6 list-item-enter" style="animation-delay: 200ms;">
|
|
<div class="glass rounded-2xl overflow-hidden">
|
|
<!-- Tab 导航 -->
|
|
<div class="border-b border-gray-200 dark:border-gray-700">
|
|
<nav class="flex -mb-px">
|
|
<button id="tab-home" onclick="switchTab('home')"
|
|
class="detail-tab active px-5 py-3 text-sm font-medium border-b-2 border-black dark:border-white text-black dark:text-white">
|
|
大类专业信息
|
|
</button>
|
|
<button id="tab-requirements" onclick="switchTab('requirements')"
|
|
class="detail-tab px-5 py-3 text-sm font-medium border-b-2 border-transparent text-gray-400 dark:text-gray-500 hover:text-black dark:hover:text-white hover:border-gray-300 transition-colors">
|
|
修读要求
|
|
</button>
|
|
<button id="tab-courses" onclick="switchTab('courses')"
|
|
class="detail-tab px-5 py-3 text-sm font-medium border-b-2 border-transparent text-gray-400 dark:text-gray-500 hover:text-black dark:hover:text-white hover:border-gray-300 transition-colors">
|
|
课程信息
|
|
</button>
|
|
<button id="tab-preview" onclick="switchTab('preview')"
|
|
class="detail-tab px-5 py-3 text-sm font-medium border-b-2 border-transparent text-gray-400 dark:text-gray-500 hover:text-black dark:hover:text-white hover:border-gray-300 transition-colors">
|
|
执行计划预览
|
|
</button>
|
|
</nav>
|
|
</div>
|
|
|
|
<!-- 当前选中行信息 -->
|
|
<div id="selectedRowInfo" class="px-4 py-2 bg-gray-50 dark:bg-gray-800/50 text-xs text-gray-500 dark:text-gray-400 border-b border-gray-200 dark:border-gray-700 hidden">
|
|
<span id="selectedRowText"></span>
|
|
</div>
|
|
|
|
<!-- Tab 内容 -->
|
|
<div id="tabContent" class="tab-content-wrap">
|
|
<!-- 大类专业信息:选中提示 -->
|
|
<div id="panels-home" class="p-0">
|
|
<div id="homeHint" class="no-selection-hint">
|
|
<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 24 24" fill="none"
|
|
stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"
|
|
class="opacity-40 mr-2">
|
|
<circle cx="12" cy="12" r="10"/>
|
|
<line x1="12" y1="8" x2="12" y2="12"/>
|
|
<line x1="12" y1="16" x2="12.01" y2="16"/>
|
|
</svg>
|
|
请在列表中勾选一条记录,再切换到其他 Tab 查看详情
|
|
</div>
|
|
<!-- 选中行详情卡片(由 JS 填充) -->
|
|
<div id="homeCard" class="p-4 hidden"></div>
|
|
</div>
|
|
|
|
<!-- 修读要求 -->
|
|
<div id="panels-requirements" class="p-4 hidden">
|
|
<div id="requirementsLoading" class="text-center py-8 hidden">
|
|
<div class="w-8 h-8 border-2 border-black dark:border-white border-t-transparent rounded-full animate-spin mx-auto mb-3"></div>
|
|
<p class="text-gray-500 text-sm">正在加载修读要求...</p>
|
|
</div>
|
|
<div id="requirementsError" class="text-center py-8 hidden">
|
|
<p class="text-red-500 text-sm" id="requirementsErrorText"></p>
|
|
</div>
|
|
<div id="requirementsContent" class="xdyq-wrap"></div>
|
|
<div id="requirementsHint" class="no-selection-hint">
|
|
请先勾选一条记录
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 课程信息 -->
|
|
<div id="panels-courses" class="p-0 hidden">
|
|
<!-- 过滤条件 -->
|
|
<div class="px-4 py-3 border-b border-gray-100 dark:border-gray-800 flex flex-wrap gap-3 items-center">
|
|
<input id="courseKchInput" type="text" placeholder="课程号" class="px-3 py-1.5 rounded border border-gray-200 dark:border-gray-700 bg-white dark:bg-black/30 text-xs w-28">
|
|
<select id="courseShztSelect" class="px-3 py-1.5 rounded border border-gray-200 dark:border-gray-700 bg-white dark:bg-black/30 text-xs">
|
|
<option value="">审核状态(全部)</option>
|
|
<option value="1">通过</option>
|
|
<option value="2">不通过</option>
|
|
</select>
|
|
<button onclick="loadCourses(1)"
|
|
class="px-3 py-1.5 rounded bg-black dark:bg-white text-white dark:text-black text-xs font-medium hover:opacity-80 transition-opacity">
|
|
查询
|
|
</button>
|
|
<button id="coursesColToggle" onclick="toggleCourseCols()"
|
|
class="px-3 py-1.5 rounded border border-gray-200 dark:border-gray-700 bg-white dark:bg-black/30 text-xs font-medium hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors">
|
|
全部列
|
|
</button>
|
|
<span id="coursesCount" class="text-xs text-gray-400 ml-auto"></span>
|
|
</div>
|
|
<div id="coursesLoading" class="text-center py-8 hidden">
|
|
<div class="w-8 h-8 border-2 border-black dark:border-white border-t-transparent rounded-full animate-spin mx-auto mb-3"></div>
|
|
<p class="text-gray-500 text-sm">正在加载课程信息...</p>
|
|
</div>
|
|
<div id="coursesError" class="text-center py-8 hidden">
|
|
<p class="text-red-500 text-sm" id="coursesErrorText"></p>
|
|
</div>
|
|
<div id="coursesHint" class="no-selection-hint" style="min-height:150px">
|
|
请先勾选一条记录
|
|
</div>
|
|
<div id="coursesContent" class="overflow-auto max-h-[500px]">
|
|
<div id="coursesTableWrap" class="hidden"></div>
|
|
</div>
|
|
<!-- 分页 -->
|
|
<div id="coursesPagination" class="flex justify-center gap-1 py-3 border-t border-gray-100 dark:border-gray-800 hidden"></div>
|
|
</div>
|
|
|
|
<!-- 执行计划预览 -->
|
|
<div id="panels-preview" class="hidden">
|
|
<div id="previewLoading" class="text-center py-8 hidden">
|
|
<div class="w-8 h-8 border-2 border-black dark:border-white border-t-transparent rounded-full animate-spin mx-auto mb-3"></div>
|
|
<p class="text-gray-500 text-sm">正在加载执行计划预览...</p>
|
|
</div>
|
|
<div id="previewError" class="text-center py-8 hidden">
|
|
<p class="text-red-500 text-sm" id="previewErrorText"></p>
|
|
</div>
|
|
<div id="previewHint" class="no-selection-hint" style="min-height:150px">
|
|
请先勾选一条记录
|
|
</div>
|
|
<div id="previewContent" class="overflow-auto max-h-[600px]"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{% block extra_js %}
|
|
<script src="{{ url_for('static', filename='echarts.min.js') }}"></script>
|
|
<script>
|
|
let xzChart = null;
|
|
let gradeChart = null;
|
|
|
|
// ─── 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'); }
|
|
|
|
// ─── ECharts 图表 ─────────────────────────────────────────────────
|
|
|
|
function renderXzChart(items) {
|
|
const dom = document.getElementById('xzChart');
|
|
if (!dom || !items.length) return;
|
|
|
|
const xzMap = {};
|
|
items.forEach(item => {
|
|
const xz = (item.xz || '未知') + '年';
|
|
xzMap[xz] = (xzMap[xz] || 0) + 1;
|
|
});
|
|
const data = Object.entries(xzMap).map(([name, value]) => ({ name, value }));
|
|
|
|
const dark = isDarkMode();
|
|
if (!xzChart) xzChart = echarts.init(dom);
|
|
xzChart.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 });
|
|
xzChart.resize();
|
|
}
|
|
|
|
function renderGradeChart(items) {
|
|
const dom = document.getElementById('gradeChart');
|
|
if (!dom || !items.length) return;
|
|
|
|
const gradeMap = {};
|
|
items.forEach(item => {
|
|
const g = item.njmc || '未知';
|
|
if (!gradeMap[g]) gradeMap[g] = { count: 0, totalCourses: 0 };
|
|
gradeMap[g].count++;
|
|
gradeMap[g].totalCourses += parseInt(item.kcs) || 0;
|
|
});
|
|
const sorted = Object.entries(gradeMap).sort((a, b) => a[0].localeCompare(b[0]));
|
|
|
|
const dark = isDarkMode();
|
|
if (!gradeChart) gradeChart = echarts.init(dom);
|
|
gradeChart.setOption({
|
|
tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' } },
|
|
legend: {
|
|
data: ['专业数', '总课程数'],
|
|
bottom: 0,
|
|
textStyle: { color: dark ? '#9ca3af' : '#6b7280', fontSize: 11 }
|
|
},
|
|
grid: { left: '3%', right: '4%', top: 10, bottom: 40, containLabel: true },
|
|
xAxis: {
|
|
type: 'category', data: sorted.map(s => s[0]),
|
|
axisLabel: { color: dark ? '#9ca3af' : '#6b7280', fontSize: 11 }
|
|
},
|
|
yAxis: [
|
|
{
|
|
type: 'value', name: '专业数',
|
|
nameTextStyle: { color: dark ? '#9ca3af' : '#6b7280' },
|
|
axisLabel: { color: dark ? '#9ca3af' : '#6b7280' }
|
|
},
|
|
{
|
|
type: 'value', name: '总课程数',
|
|
nameTextStyle: { color: dark ? '#9ca3af' : '#6b7280' },
|
|
axisLabel: { color: dark ? '#9ca3af' : '#6b7280' }
|
|
}
|
|
],
|
|
series: [
|
|
{
|
|
name: '专业数', type: 'bar',
|
|
data: sorted.map(s => s[1].count),
|
|
itemStyle: { color: dark ? '#818cf8' : '#4f46e5', borderRadius: [6, 6, 0, 0] }
|
|
},
|
|
{
|
|
name: '总课程数', type: 'line', yAxisIndex: 1,
|
|
data: sorted.map(s => s[1].totalCourses),
|
|
lineStyle: { color: dark ? '#34d399' : '#10b981', width: 2 },
|
|
itemStyle: { color: dark ? '#34d399' : '#10b981' },
|
|
symbol: 'circle', symbolSize: 6
|
|
}
|
|
]
|
|
}, { notMerge: true });
|
|
gradeChart.resize();
|
|
}
|
|
|
|
function renderCharts(items) {
|
|
const row = document.getElementById('chartsRow');
|
|
if (row) row.classList.remove('hidden');
|
|
renderXzChart(items);
|
|
renderGradeChart(items);
|
|
}
|
|
|
|
function setupDarkObserver() {
|
|
const observer = new MutationObserver(() => {
|
|
if (xzChart) { xzChart.dispose(); xzChart = null; }
|
|
if (gradeChart) { gradeChart.dispose(); gradeChart = null; }
|
|
if (window._lastPlanItems && window._lastPlanItems.length) renderCharts(window._lastPlanItems);
|
|
});
|
|
observer.observe(document.documentElement, { attributes: true, attributeFilter: ['class'] });
|
|
}
|
|
|
|
window.addEventListener('resize', () => {
|
|
if (xzChart) xzChart.resize();
|
|
if (gradeChart) gradeChart.resize();
|
|
});
|
|
|
|
// ── 全局状态 ────────────────────────────────────────
|
|
let allItems = []; // 当前列表全部数据
|
|
let selectedId = null; // 当前选中的 jxzxjhxx_id
|
|
let selectedItem = null; // 当前选中的行数据
|
|
let loadedRequirements = {}; // 缓存: id -> html
|
|
let loadedCourses = {}; // 缓存: id -> {items, total, page, page_size}
|
|
let loadedPreview = {}; // 缓存: id -> html
|
|
let currentCoursesPage = 1;
|
|
|
|
// ── 初始化 ─────────────────────────────────────────
|
|
function getCurrentYear() {
|
|
const now = new Date();
|
|
const month = now.getMonth() + 1;
|
|
return month >= 9 ? now.getFullYear() : now.getFullYear() - 1;
|
|
}
|
|
|
|
function initGradeSelect() {
|
|
const select = document.getElementById('njdmSelect');
|
|
const current = getCurrentYear();
|
|
for (let y = current; y >= current - 8; y--) {
|
|
const opt = document.createElement('option');
|
|
opt.value = y;
|
|
opt.textContent = y + '级';
|
|
select.appendChild(opt);
|
|
}
|
|
select.value = current;
|
|
}
|
|
initGradeSelect();
|
|
|
|
// ── 列表刷新 ────────────────────────────────────────
|
|
async function refresh() {
|
|
document.getElementById('loadingIndicator').classList.remove('hidden');
|
|
document.getElementById('errorMessage').classList.add('hidden');
|
|
document.getElementById('dataContainer').classList.add('hidden');
|
|
document.getElementById('detailSection').classList.add('hidden');
|
|
const chartsRow = document.getElementById('chartsRow');
|
|
if (chartsRow) chartsRow.classList.add('hidden');
|
|
|
|
const njdm_id = document.getElementById('njdmSelect').value;
|
|
const zyh_id = document.getElementById('zyhInput').value.trim();
|
|
|
|
try {
|
|
const params = new URLSearchParams({ page_size: 500 });
|
|
if (njdm_id) params.set('njdm_id', njdm_id);
|
|
if (zyh_id) params.set('zyh_id', zyh_id);
|
|
const res = await fetch('/api/jwxt/teaching-plan?' + params);
|
|
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;
|
|
}
|
|
|
|
allItems = data.items || [];
|
|
if (!allItems.length) {
|
|
document.getElementById('dataContainer').classList.remove('hidden');
|
|
document.getElementById('emptyState').classList.remove('hidden');
|
|
document.getElementById('tableBody').innerHTML = '';
|
|
return;
|
|
}
|
|
document.getElementById('emptyState').classList.add('hidden');
|
|
renderTable(allItems);
|
|
window._lastPlanItems = allItems;
|
|
renderCharts(allItems);
|
|
document.getElementById('dataContainer').classList.remove('hidden');
|
|
} catch (e) {
|
|
document.getElementById('loadingIndicator').classList.add('hidden');
|
|
document.getElementById('errorText').textContent = '网络错误: ' + e.message;
|
|
document.getElementById('errorMessage').classList.remove('hidden');
|
|
}
|
|
}
|
|
|
|
// ── 渲染列表 ────────────────────────────────────────
|
|
function renderTable(items) {
|
|
const bjgsMap = { '1': '全日制', '2': '非全日制', '3': '其他' };
|
|
const tbody = document.getElementById('tableBody');
|
|
tbody.innerHTML = items.map((item, idx) => {
|
|
const bid = item.jxzxjhxx_id || item.WID || idx;
|
|
const bjgs = bjgsMap[item.bjgs] || item.bjgs || '--';
|
|
return '<tr class="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;" data-id="' + bid + '">' +
|
|
'<td class="py-3 px-4 text-center">' +
|
|
'<input type="radio" name="rowSelect" class="w-4 h-4 rounded accent-black dark:accent-white cursor-pointer" value="' + bid + '" onchange="onRowSelect(\'' + bid.replace(/'/g, "\\'") + '\')">' +
|
|
'</td>' +
|
|
'<td class="py-3 px-4 text-gray-400 dark:text-gray-500">' + (idx + 1) + '</td>' +
|
|
'<td class="py-3 px-4 font-medium">' + escHtml(item.zymc || '--') + '</td>' +
|
|
'<td class="py-3 px-4 text-gray-500 dark:text-gray-400 font-mono text-xs">' + escHtml(item.zyh || '--') + '</td>' +
|
|
'<td class="py-3 px-4 text-center text-gray-500 dark:text-gray-400">' + escHtml(item.njmc || '--') + '</td>' +
|
|
'<td class="py-3 px-4 text-center">' + (item.xz || '--') + '年</td>' +
|
|
'<td class="py-3 px-4 text-center font-semibold">' + (item.kcs || '--') + '</td>' +
|
|
'<td class="py-3 px-4 text-center text-gray-500 dark:text-gray-400">' + bjgs + '</td>' +
|
|
'<td class="py-3 px-4 text-gray-500 dark:text-gray-400">' + escHtml(item.dlbs || '--') + '</td>' +
|
|
'</tr>';
|
|
}).join('');
|
|
}
|
|
|
|
function escHtml(s) {
|
|
const d = document.createElement('div');
|
|
d.textContent = s;
|
|
return d.innerHTML;
|
|
}
|
|
|
|
// ── 行选择 ─────────────────────────────────────────
|
|
function onRowSelect(bid) {
|
|
selectedId = bid;
|
|
selectedItem = allItems.find(it => (it.jxzxjhxx_id || it.WID || allItems.indexOf(it)) == bid) || null;
|
|
|
|
// 取消全选
|
|
document.getElementById('selectAll').checked = false;
|
|
|
|
// 详情区
|
|
document.getElementById('detailSection').classList.remove('hidden');
|
|
document.getElementById('selectedRowText').textContent =
|
|
'当前选中:' + (selectedItem ? (selectedItem.zymc + ' ' + (selectedItem.njmc || '')) : bid);
|
|
document.getElementById('selectedRowInfo').classList.remove('hidden');
|
|
|
|
// 更新 home 卡片
|
|
renderHomeCard(selectedItem);
|
|
|
|
// 重新加载当前 tab
|
|
const activeTab = document.querySelector('.detail-tab.border-black, .detail-tab.dark\\:border-white') ||
|
|
document.querySelector('.detail-tab[style*="border-black"], .detail-tab[style*="border-white"]');
|
|
const currentTabName = activeTab ? activeTab.id.replace('tab-', '') : 'home';
|
|
loadTab(currentTabName);
|
|
}
|
|
|
|
function toggleSelectAll() {
|
|
const checked = document.getElementById('selectAll').checked;
|
|
document.querySelectorAll('input[name="rowSelect"]').forEach(cb => {
|
|
cb.checked = checked;
|
|
});
|
|
}
|
|
|
|
// ── Tab 切换 ────────────────────────────────────────
|
|
function switchTab(tabName) {
|
|
// 更新 tab 样式
|
|
document.querySelectorAll('.detail-tab').forEach(btn => {
|
|
btn.classList.remove('border-black', 'dark:border-white', 'text-black', 'dark:text-white');
|
|
btn.classList.add('border-transparent', 'text-gray-400', 'dark:text-gray-500');
|
|
});
|
|
const activeBtn = document.getElementById('tab-' + tabName);
|
|
if (activeBtn) {
|
|
activeBtn.classList.remove('border-transparent', 'text-gray-400', 'dark:text-gray-500');
|
|
activeBtn.classList.add('border-black', 'dark:border-white', 'text-black', 'dark:text-white');
|
|
}
|
|
|
|
// 切换面板
|
|
document.querySelectorAll('[id^="panels-"]').forEach(p => p.classList.add('hidden'));
|
|
const panel = document.getElementById('panels-' + tabName);
|
|
if (panel) panel.classList.remove('hidden');
|
|
|
|
// 加载数据
|
|
if (tabName !== 'home') {
|
|
loadTab(tabName);
|
|
}
|
|
}
|
|
|
|
function loadTab(tabName) {
|
|
if (!selectedId) return;
|
|
switch(tabName) {
|
|
case 'requirements': loadRequirements(); break;
|
|
case 'courses': loadCourses(1); break;
|
|
case 'preview': loadPreview(); break;
|
|
}
|
|
}
|
|
|
|
// ── 修读要求 ───────────────────────────────────────
|
|
async function loadRequirements() {
|
|
if (loadedRequirements[selectedId]) {
|
|
showRequirementsData(loadedRequirements[selectedId]);
|
|
return;
|
|
}
|
|
showEl('requirementsLoading');
|
|
hideEl('requirementsError');
|
|
hideEl('requirementsContent');
|
|
hideEl('requirementsHint');
|
|
|
|
try {
|
|
const res = await fetch('/api/jwxt/teaching-plan/requirements/' + encodeURIComponent(selectedId));
|
|
const data = await res.json();
|
|
hideEl('requirementsLoading');
|
|
|
|
if (!data.success) {
|
|
const msg = data.message || '加载失败';
|
|
if (data.error_type === 'permission_denied') {
|
|
showPermissionWarning('requirementsContent', msg);
|
|
} else {
|
|
document.getElementById('requirementsErrorText').textContent = msg;
|
|
showEl('requirementsError');
|
|
}
|
|
return;
|
|
}
|
|
|
|
// 优先使用原生解析树,回退到 iframe
|
|
const hasParsedTree = data.parsed_tree && data.parsed_tree.tree && data.parsed_tree.tree.length > 0;
|
|
if (hasParsedTree) {
|
|
renderRequirementsTree(data.parsed_tree.tree, data.parsed_tree.nodes);
|
|
} else if (data.html && data.html.trim() !== '') {
|
|
renderRequirementsFrame(data.html);
|
|
} else {
|
|
showEmptyData('requirementsContent', '该教学计划暂无修读要求数据');
|
|
}
|
|
|
|
loadedRequirements[selectedId] = data;
|
|
} catch (e) {
|
|
hideEl('requirementsLoading');
|
|
document.getElementById('requirementsErrorText').textContent = '网络错误: ' + e.message;
|
|
showEl('requirementsError');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 用 iframe srcdoc 渲染修读要求 HTML,使内部 JS(treeview 等)正常执行
|
|
*/
|
|
function renderRequirementsFrame(html) {
|
|
hideEl('requirementsHint');
|
|
hideEl('requirementsLoading');
|
|
hideEl('requirementsError');
|
|
|
|
const container = document.getElementById('requirementsContent');
|
|
container.innerHTML = '';
|
|
|
|
// 判断是否为完整 HTML 文档
|
|
const isFullDoc = /^\s*<!doctype/i.test(html) || /^\s*<html[\s>]/i.test(html);
|
|
|
|
let docHTML;
|
|
if (isFullDoc) {
|
|
docHTML = html;
|
|
} else {
|
|
// 片段 → 包裹成完整文档
|
|
docHTML = '<!DOCTYPE html>\n<html>\n<head>\n<meta charset="utf-8">\n<base href="' + '{{ jwxt_base_url }}/' + '">\n</head>\n<body>\n' + html + '\n</body>\n</html>';
|
|
}
|
|
|
|
// 深色模式:向 iframe 内注入样式
|
|
const isDark = document.documentElement.classList.contains('dark');
|
|
if (isDark) {
|
|
const darkCSS = '<style id="dark-mode-inject">' +
|
|
'*,*::before,*::after{scrollbar-color:#4b5563 #1f2937;}' +
|
|
'body{background:#111827!important;color:#d1d5db!important;}' +
|
|
'a{color:#93c5fd;}' +
|
|
'h1,h2,h3,h4,h5,h6,.page-header{color:#e5e7eb;border-color:#374151;}' +
|
|
'.treeview,.treeview ul{color:#d1d5db;background:transparent;}' +
|
|
'.treeview li{color:#d1d5db;}' +
|
|
'.treeview-hitarea{color:#9ca3af;}' +
|
|
'.treeview span{color:#d1d5db;}' +
|
|
'table{background:#1f2937!important;color:#d1d5db;border-color:#374151;}' +
|
|
'table th{background:#111827!important;color:#e5e7eb;border-color:#374151;}' +
|
|
'table td{background:#1f2937;border-color:#374151;}' +
|
|
'table tr:nth-child(even) td{background:#1a2332;}' +
|
|
'table tr:hover td{background:#374151!important;}' +
|
|
'input,select,textarea{background:#374151;color:#d1d5db;border-color:#4b5563;}' +
|
|
'.panel,.panel-default{background:#1f2937;border-color:#374151;color:#d1d5db;}' +
|
|
'.panel-heading{background:#111827;border-color:#374151;}' +
|
|
'.panel-body{background:#1f2937;color:#d1d5db;}' +
|
|
'.form-control{background:#374151;color:#d1d5db;border-color:#4b5563;}' +
|
|
'.form-control[disabled],.form-control[readonly]{background:#1f2937;}' +
|
|
'.label{color:#d1d5db;}' +
|
|
'.text-muted{color:#9ca3af!important;}' +
|
|
'.nav-tabs{border-color:#374151;}' +
|
|
'.nav-tabs>li>a{color:#9ca3af;}' +
|
|
'.nav-tabs>li.active>a{background:#1f2937;color:#e5e7eb;border-color:#374151;}' +
|
|
'.well{background:#1f2937;border-color:#374151;color:#d1d5db;}' +
|
|
'code,pre{background:#374151;color:#e5e7eb;}' +
|
|
'.alert-info{background:#1e3a5f;color:#93c5fd;border-color:#1e40af;}' +
|
|
'.alert-warning{background:#5c4a1f;color:#fbbf24;border-color:#92400e;}' +
|
|
'</style>';
|
|
docHTML = docHTML.replace('</head>', darkCSS + '\n</head>');
|
|
}
|
|
|
|
// 创建 iframe
|
|
const iframe = document.createElement('iframe');
|
|
iframe.id = 'requirementsFrame';
|
|
iframe.style.cssText = 'width:100%;border:none;min-height:300px;';
|
|
|
|
// onload 时调整高度
|
|
iframe.onload = function() {
|
|
try {
|
|
const doc = iframe.contentDocument || iframe.contentWindow.document;
|
|
const body = doc.body;
|
|
const de = doc.documentElement;
|
|
const h = Math.max(
|
|
body.scrollHeight, body.offsetHeight,
|
|
de.clientHeight, de.scrollHeight, de.offsetHeight
|
|
);
|
|
iframe.style.height = Math.max(h, 400) + 'px';
|
|
} catch(e) {
|
|
iframe.style.height = '500px';
|
|
}
|
|
};
|
|
|
|
container.appendChild(iframe);
|
|
iframe.srcdoc = docHTML;
|
|
showEl('requirementsContent');
|
|
}
|
|
|
|
function showRequirementsHtml(html) {
|
|
// 保留作为 iframe 回退的快捷入口
|
|
renderRequirementsFrame(html);
|
|
}
|
|
|
|
// ── 修读要求原生树形视图 ───────────────────────────
|
|
/**
|
|
* 使用原生 DOM 渲染修读要求树形结构
|
|
*/
|
|
function renderRequirementsTree(tree, nodes) {
|
|
hideEl('requirementsHint');
|
|
hideEl('requirementsLoading');
|
|
hideEl('requirementsError');
|
|
|
|
const container = document.getElementById('requirementsContent');
|
|
container.innerHTML = '';
|
|
|
|
if (!tree || tree.length === 0) {
|
|
showEmptyData('requirementsContent', '该教学计划暂无修读要求数据');
|
|
return;
|
|
}
|
|
|
|
// 工具栏:展开/折叠全部
|
|
const toolbar = document.createElement('div');
|
|
toolbar.className = 'flex items-center gap-2 mb-3 px-1';
|
|
toolbar.innerHTML = `
|
|
<span class="text-xs text-gray-400 dark:text-gray-500">共 ${nodes ? nodes.length : tree.length} 个节点</span>
|
|
<div class="flex-1"></div>
|
|
<button onclick="toggleRequirementsAll(true)" class="text-xs px-2 py-1 rounded border border-gray-200 dark:border-gray-700 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors">展开全部</button>
|
|
<button onclick="toggleRequirementsAll(false)" class="text-xs px-2 py-1 rounded border border-gray-200 dark:border-gray-700 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors">折叠全部</button>
|
|
`;
|
|
container.appendChild(toolbar);
|
|
|
|
// 树容器
|
|
const treeDiv = document.createElement('div');
|
|
treeDiv.className = 'requirements-tree';
|
|
treeDiv.innerHTML = tree.map(n => renderRequirementsNode(n, 0)).join('');
|
|
container.appendChild(treeDiv);
|
|
|
|
// 初始全部展开
|
|
_reqExpandedAll = true;
|
|
|
|
showEl('requirementsContent');
|
|
}
|
|
|
|
let _reqExpandedAll = true;
|
|
|
|
function renderRequirementsNode(node, depth) {
|
|
const hasChildren = node.children && node.children.length > 0;
|
|
const isLeaf = node.is_leaf || (!hasChildren);
|
|
const maxDepth = Math.min(depth, 4);
|
|
const indentClass = `req-indent-${maxDepth}`;
|
|
|
|
const nodeId = `req-node-${node.id}`;
|
|
const childrenId = `req-children-${node.id}`;
|
|
|
|
// 深度对应的字体样式
|
|
const textStyle = depth === 0
|
|
? 'text-base font-bold'
|
|
: depth === 1
|
|
? 'text-sm font-semibold'
|
|
: 'text-xs font-medium';
|
|
|
|
// 展开/折叠图标
|
|
const chevronHtml = hasChildren ? `
|
|
<svg class="tree-chevron" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"
|
|
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<polyline points="6 9 12 15 18 9"/>
|
|
</svg>` : `
|
|
<svg class="tree-leaf-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"
|
|
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<circle cx="12" cy="12" r="3"/><path d="M12 2v4m0 12v4m10-10h-4M6 12H2"/>
|
|
</svg>`;
|
|
|
|
// 学分显示
|
|
const required = node.required_credits || 0;
|
|
const earned = node.earned_credits || 0;
|
|
const creditHtml = (required > 0 || earned > 0) ? `
|
|
<span class="tree-credits">${earned}/${required} 学分</span>` : '';
|
|
|
|
// 关系标签 (并且/或者)
|
|
const relation = node.relation;
|
|
const relationHtml = (relation && !isLeaf) ? `
|
|
<span class="tree-relation ${relation === '或者' ? 'or' : ''}">${escHtml(relation)}</span>` : '';
|
|
|
|
// 叶子节点标记
|
|
const leafHtml = isLeaf && !hasChildren ? `
|
|
<span class="text-xs text-gray-300 dark:text-gray-600 flex-shrink-0">●</span>` : '';
|
|
|
|
const clickHandler = hasChildren ? `onclick="toggleRequirementsNode('${childrenId}', this)"` : '';
|
|
const toggleClass = hasChildren ? 'tree-toggle' : '';
|
|
|
|
return `
|
|
<div id="${nodeId}" class="tree-item depth-${depth}">
|
|
<div class="${toggleClass} tree-row ${indentClass}" ${clickHandler}>
|
|
${chevronHtml}
|
|
<span class="tree-name ${textStyle}">${escHtml(node.name)}</span>
|
|
${relationHtml}
|
|
${creditHtml}
|
|
${leafHtml}
|
|
</div>
|
|
${hasChildren ? `<div id="${childrenId}" class="tree-children">${node.children.map(c => renderRequirementsNode(c, depth + 1)).join('')}</div>` : ''}
|
|
</div>`;
|
|
}
|
|
|
|
function toggleRequirementsNode(childrenId, el) {
|
|
const container = document.getElementById(childrenId);
|
|
if (!container) return;
|
|
const chevron = el.querySelector('.tree-chevron');
|
|
if (container.classList.contains('collapsed')) {
|
|
container.classList.remove('collapsed');
|
|
if (chevron) chevron.classList.remove('collapsed');
|
|
} else {
|
|
container.classList.add('collapsed');
|
|
if (chevron) chevron.classList.add('collapsed');
|
|
}
|
|
}
|
|
|
|
function toggleRequirementsAll(expand) {
|
|
_reqExpandedAll = expand;
|
|
document.querySelectorAll('#requirementsContent .tree-children').forEach(el => {
|
|
if (expand) {
|
|
el.classList.remove('collapsed');
|
|
} else {
|
|
el.classList.add('collapsed');
|
|
}
|
|
});
|
|
document.querySelectorAll('#requirementsContent .tree-chevron').forEach(el => {
|
|
if (expand) {
|
|
el.classList.remove('collapsed');
|
|
} else {
|
|
el.classList.add('collapsed');
|
|
}
|
|
});
|
|
}
|
|
|
|
function showRequirementsData(data) {
|
|
hideEl('requirementsHint');
|
|
hideEl('requirementsLoading');
|
|
hideEl('requirementsError');
|
|
|
|
// 优先使用原生解析树
|
|
if (data.parsed_tree && data.parsed_tree.tree && data.parsed_tree.tree.length > 0) {
|
|
renderRequirementsTree(data.parsed_tree.tree, data.parsed_tree.nodes);
|
|
return;
|
|
}
|
|
|
|
const html = typeof data === 'string' ? data : (data.html || '');
|
|
if (!html || html.trim() === '' || (data.items && data.items.length === 0)) {
|
|
showEmptyData('requirementsContent', '该教学计划暂无修读要求数据');
|
|
return;
|
|
}
|
|
renderRequirementsFrame(html);
|
|
}
|
|
|
|
function showPermissionWarning(containerId, message) {
|
|
const container = document.getElementById(containerId);
|
|
if (!container) return;
|
|
hideEl('requirementsHint');
|
|
hideEl('requirementsLoading');
|
|
hideEl('requirementsError');
|
|
container.innerHTML = '<div class="permission-warning">' +
|
|
'<svg class="warning-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">' +
|
|
'<path d="M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"/>' +
|
|
'<line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/>' +
|
|
'</svg>' +
|
|
'<div class="warning-title">暂无查看权限</div>' +
|
|
'<div class="warning-desc">' + escHtml(message || '教务系统限制了学生账号查看此内容的权限') + '</div>' +
|
|
'</div>';
|
|
showEl(containerId);
|
|
}
|
|
|
|
function showEmptyData(containerId, message) {
|
|
const container = document.getElementById(containerId);
|
|
if (!container) return;
|
|
hideEl('requirementsHint');
|
|
hideEl('requirementsLoading');
|
|
hideEl('requirementsError');
|
|
container.innerHTML = '<div class="empty-data-hint">' +
|
|
'<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="opacity-40">' +
|
|
'<path d="M13 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V9z"/>' +
|
|
'<polyline points="13 2 13 9 20 9"/>' +
|
|
'</svg>' +
|
|
'<span>' + escHtml(message || '暂无数据') + '</span>' +
|
|
'</div>';
|
|
showEl(containerId);
|
|
}
|
|
|
|
// ── 课程信息 ────────────────────────────────────────
|
|
let showAllCourseCols = false;
|
|
|
|
// 全面的 JWXT 课程列中文标签映射(覆盖 jqGrid 返回的 ~70+ 键)
|
|
const COL_LABELS = {
|
|
// 基础信息
|
|
'kch': '课程号', 'kcmc': '课程名称', 'kclb': '课程类别', 'kclx': '课程类型',
|
|
'kcsx': '课程性质', 'kklxdm': '开课类型代码', 'kkbmdm': '开课部门代码',
|
|
'kkbm': '开课部门', 'kkbmmc': '开课部门名称',
|
|
// 学分/学时
|
|
'xf': '学分', 'zxs': '周学时', 'zxss': '总学时', 'llss': '理论学时',
|
|
'sjss': '实践学时', 'syxs': '实验学时', 'sxss': '上机学时',
|
|
'qtss': '其它学时', 'kcsj': '课程设计', 'qzzxs': '其中周学时',
|
|
// 容量/人数
|
|
'jxrl': '教学容量', 'yxrs': '已选人数', 'bxrl': '必需容量',
|
|
'yxrs_s': '已选上限', 'bxrs': '必修人数',
|
|
// 教师/教室
|
|
'teachername': '教师', 'jsmc': '教室', 'sksj': '上课时间',
|
|
'skjc': '上课节次', 'skdd': '上课地点', 'skzc': '上课周次',
|
|
// 考核/考试
|
|
'khfs': '考核方式', 'ksfs': '考试方式', 'ksxs': '考试形式',
|
|
// 学年/学期
|
|
'jyxdxnm': '教学年度', 'jyxdxqm': '教学学期',
|
|
'yxxdxnm': '运行学年', 'yxxdxqm': '运行学期',
|
|
'kknj': '开课年级', 'xqmc': '校区', 'xq': '校区代码',
|
|
// 专业方向
|
|
'zyfx': '专业方向', 'sszy': '所属专业', 'ssdl': '所属大类',
|
|
'njdm': '年级代码', 'njmc': '年级名称',
|
|
// 修读标记
|
|
'xdyqjd': '修读要求节点', 'xdyqjd_id': '修读要求节点ID',
|
|
'sxbj': '是否限选', 'sfxwkc': '是否学位课程',
|
|
'sfzyhxkc': '是否专业核心课程', 'sfzykkc': '是否专业开放课程',
|
|
'sfbx': '是否必修', 'sfxx': '是否选修', 'sfzhxs': '是否主修学生',
|
|
'sffx': '是否辅修', 'sfezy': '是否二专业', 'sfezw': '是否二学位',
|
|
// 实践/实验
|
|
'sfsjkc': '是否实践课', 'sfsykc': '是否实验课',
|
|
'sjzxs': '实践周学时', 'syzxs': '实验周学时',
|
|
// 周次/节次
|
|
'qsj': '起始周', 'jsj': '结束周', 'qsz': '起始周', 'jsz': '结束周',
|
|
'skzcsm': '上课周次说明', 'kkzc': '开课周次', 'jcdm': '节次代码',
|
|
// 修读建议
|
|
'jyxdxnm_advice': '建议修读学年', 'jyxdxqm_advice': '建议修读学期',
|
|
'yxxdxnm_allow': '允许修读学年', 'yxxdxqm_allow': '允许修读学期',
|
|
// 执行计划相关
|
|
'jxzxjhxx_id': '执行计划ID', 'zyh': '专业号', 'zymc': '专业名称',
|
|
'zymc_en': '专业英文名', 'zyh_id': '专业号ID',
|
|
'zydm': '专业代码', 'zydl': '专业大类',
|
|
// 班级/年级
|
|
'bj': '班级', 'bjmc': '班级名称', 'bjdm': '班级代码',
|
|
// 审核/状态
|
|
'shzt': '审核状态', 'zt': '状态', 'sfyx': '是否有效',
|
|
'sfqy': '是否启用', 'sfsc': '是否删除',
|
|
// 备注/其他
|
|
'bz': '备注', 'sm': '说明', 'bzxx': '备注信息',
|
|
'lrr': '录入人', 'lrsj': '录入时间', 'xgr': '修改人', 'xgsj': '修改时间',
|
|
'cjrxm': '创建人', 'cjsj': '创建时间',
|
|
// 教学班
|
|
'jxbmc': '教学班名称', 'jxbdm': '教学班代码', 'jxbrs': '教学班人数',
|
|
// 课程英文名
|
|
'kcmc_en': '课程英文名', 'kcym': '课程英文名',
|
|
// 模块代码
|
|
'gnmkdm': '功能模块代码',
|
|
};
|
|
|
|
// 默认显示的精选列(约18列,覆盖用户最关心的信息)
|
|
const DEFAULT_COURSE_COLS = [
|
|
'kch', 'kcmc', 'xf', 'zxs', 'zxss', 'llss', 'sjss',
|
|
'kclb', 'kcsx', 'kkbm', 'zyfx', 'khfs', 'ksfs',
|
|
'jyxdxnm', 'jyxdxqm', 'sxbj', 'sfxwkc', 'xqmc',
|
|
];
|
|
|
|
async function loadCourses(page) {
|
|
currentCoursesPage = page;
|
|
showEl('coursesLoading');
|
|
hideEl('coursesError');
|
|
hideEl('coursesTableWrap');
|
|
hideEl('coursesHint');
|
|
document.getElementById('coursesCount').textContent = '';
|
|
|
|
const kch = document.getElementById('courseKchInput').value.trim();
|
|
const shzt = document.getElementById('courseShztSelect').value;
|
|
|
|
try {
|
|
const params = new URLSearchParams({
|
|
jxzxjhxx_id: selectedId,
|
|
page: page,
|
|
page_size: 20,
|
|
});
|
|
if (kch) params.set('kch', kch);
|
|
if (shzt) params.set('shzt', shzt);
|
|
|
|
const res = await fetch('/api/jwxt/teaching-plan/courses?' + params);
|
|
const data = await res.json();
|
|
hideEl('coursesLoading');
|
|
|
|
if (!data.success) {
|
|
if (data.error_type === 'permission_denied') {
|
|
showEl('coursesContent');
|
|
document.getElementById('coursesTableWrap').innerHTML = '';
|
|
showPermissionWarning('coursesTableWrap', data.message || '教务系统限制');
|
|
document.getElementById('coursesPagination').classList.add('hidden');
|
|
} else {
|
|
document.getElementById('coursesErrorText').textContent = data.message || '加载失败';
|
|
showEl('coursesError');
|
|
}
|
|
return;
|
|
}
|
|
|
|
if (!data.items || data.items.length === 0) {
|
|
document.getElementById('coursesTableWrap').innerHTML = '';
|
|
showEl('coursesTableWrap');
|
|
showEl('coursesContent');
|
|
showEmptyData('coursesTableWrap', '暂无课程信息');
|
|
document.getElementById('coursesPagination').classList.add('hidden');
|
|
return;
|
|
}
|
|
|
|
showEl('coursesContent');
|
|
renderCoursesTable(data.items || [], data.total, page);
|
|
} catch (e) {
|
|
hideEl('coursesLoading');
|
|
document.getElementById('coursesErrorText').textContent = '网络错误: ' + e.message;
|
|
showEl('coursesError');
|
|
}
|
|
}
|
|
|
|
function renderCoursesTable(items, total, page) {
|
|
const pageSize = 20;
|
|
const totalPages = Math.ceil(total / pageSize);
|
|
|
|
document.getElementById('coursesCount').textContent = '共 ' + total + ' 条';
|
|
|
|
if (!items.length) {
|
|
document.getElementById('coursesTableWrap').innerHTML =
|
|
'<div class="text-center py-8 text-gray-400 text-sm">暂无课程信息</div>';
|
|
showEl('coursesTableWrap');
|
|
document.getElementById('coursesPagination').classList.add('hidden');
|
|
return;
|
|
}
|
|
|
|
// 确定显示列:精选模式 或 全列模式
|
|
const first = items[0];
|
|
const allKeys = Object.keys(first).filter(k => COL_LABELS.hasOwnProperty(k) || !/^[A-Z_]+$/.test(k));
|
|
const colKeys = showAllCourseCols
|
|
? allKeys
|
|
: DEFAULT_COURSE_COLS.filter(k => first.hasOwnProperty(k));
|
|
|
|
// 更新 toggle 按钮文本
|
|
const toggleBtn = document.getElementById('coursesColToggle');
|
|
if (toggleBtn) {
|
|
toggleBtn.textContent = showAllCourseCols ? '精简列' : '全部列 (' + allKeys.length + ')';
|
|
}
|
|
|
|
// 为窄列加 nowrap
|
|
const narrowCols = new Set(['kch','xf','zxs','zxss','llss','sjss','jyxdxnm','jyxdxqm','sxbj','sfxwkc','xqmc']);
|
|
|
|
let html = '<table class="course-table"><thead><tr>';
|
|
html += '<th class="text-center w-10 sticky left-0 z-10 bg-gray-50/95 dark:bg-gray-800/95">#</th>';
|
|
for (const k of colKeys) {
|
|
const label = COL_LABELS[k] || k;
|
|
const extraClass = narrowCols.has(k) ? ' whitespace-nowrap' : '';
|
|
html += '<th class="' + extraClass + '">' + escHtml(label) + '</th>';
|
|
}
|
|
html += '</tr></thead><tbody>';
|
|
for (let i = 0; i < items.length; i++) {
|
|
const it = items[i];
|
|
html += '<tr><td class="text-center text-gray-400 sticky left-0 z-10 bg-white dark:bg-black/90">' + ((page - 1) * pageSize + i + 1) + '</td>';
|
|
for (const k of colKeys) {
|
|
const v = it[k];
|
|
const display = (v === null || v === undefined || v === '') ? '--' : String(v);
|
|
const cellClass = narrowCols.has(k) ? 'whitespace-nowrap' : '';
|
|
// 审核状态着色
|
|
let badgeHtml = '';
|
|
if (k === 'shzt') {
|
|
if (display === '1' || display === '通过') badgeHtml = '<span class="text-green-600 dark:text-green-400 text-xs font-medium">通过</span>';
|
|
else if (display === '2' || display === '不通过') badgeHtml = '<span class="text-red-500 text-xs">不通过</span>';
|
|
else badgeHtml = escHtml(display);
|
|
}
|
|
if (k === 'sxbj' || k === 'sfxwkc' || k === 'sfzyhxkc') {
|
|
const map = {'1':'是','0':'否','是':'是','否':'否'};
|
|
badgeHtml = map[display] || escHtml(display);
|
|
}
|
|
html += '<td class="' + cellClass + '">' + (badgeHtml || escHtml(display)) + '</td>';
|
|
}
|
|
html += '</tr>';
|
|
}
|
|
html += '</tbody></table>';
|
|
|
|
document.getElementById('coursesTableWrap').innerHTML = html;
|
|
showEl('coursesTableWrap');
|
|
|
|
// 分页
|
|
if (totalPages > 1) {
|
|
const pg = document.getElementById('coursesPagination');
|
|
pg.innerHTML = '';
|
|
const maxBtns = 5;
|
|
const start = Math.max(1, page - 2);
|
|
const end = Math.min(totalPages, start + maxBtns - 1);
|
|
|
|
function mkBtn(num, label, disabled) {
|
|
return '<button onclick="loadCourses(' + num + ')" ' +
|
|
(disabled ? 'disabled ' : '') +
|
|
'class="px-3 py-1 rounded text-xs border border-gray-200 dark:border-gray-700 ' +
|
|
(disabled ? 'opacity-40 cursor-not-allowed' : 'hover:bg-gray-100 dark:hover:bg-gray-800 cursor-pointer') +
|
|
(num === page ? ' bg-black dark:bg-white text-white dark:text-black font-medium' : ' text-gray-600 dark:text-gray-400') +
|
|
'">' + (label || num) + '</button>';
|
|
}
|
|
|
|
pg.innerHTML = mkBtn(1, '首页', page === 1);
|
|
pg.innerHTML += mkBtn(page - 1, '上一页', page === 1);
|
|
for (let n = start; n <= end; n++) {
|
|
pg.innerHTML += mkBtn(n, null, false);
|
|
}
|
|
pg.innerHTML += mkBtn(page + 1, '下一页', page === totalPages);
|
|
pg.innerHTML += mkBtn(totalPages, '末页', page === totalPages);
|
|
pg.classList.remove('hidden');
|
|
} else {
|
|
document.getElementById('coursesPagination').classList.add('hidden');
|
|
}
|
|
}
|
|
|
|
function toggleCourseCols() {
|
|
showAllCourseCols = !showAllCourseCols;
|
|
// 重新渲染当前已加载的课程
|
|
if (selectedId && loadedCourses[selectedId]) {
|
|
const cached = loadedCourses[selectedId];
|
|
renderCoursesTable(cached.items, cached.total, currentCoursesPage);
|
|
}
|
|
}
|
|
|
|
// ── 执行计划预览 ─────────────────────────────────────
|
|
async function loadPreview() {
|
|
if (loadedPreview[selectedId]) {
|
|
showPreviewData(loadedPreview[selectedId]);
|
|
return;
|
|
}
|
|
showEl('previewLoading');
|
|
hideEl('previewError');
|
|
hideEl('previewContent');
|
|
hideEl('previewHint');
|
|
|
|
try {
|
|
const res = await fetch('/api/jwxt/teaching-plan/preview/' + encodeURIComponent(selectedId));
|
|
const data = await res.json();
|
|
hideEl('previewLoading');
|
|
|
|
if (!data.success) {
|
|
if (data.error_type === 'permission_denied') {
|
|
showPermissionWarning('previewContent', data.message || '教务系统限制');
|
|
hideEl('previewHint');
|
|
} else {
|
|
document.getElementById('previewErrorText').textContent = data.message || '加载失败';
|
|
showEl('previewError');
|
|
}
|
|
return;
|
|
}
|
|
|
|
hideEl('previewHint');
|
|
loadedPreview[selectedId] = data;
|
|
showPreviewData(data);
|
|
} catch (e) {
|
|
hideEl('previewLoading');
|
|
document.getElementById('previewErrorText').textContent = '网络错误: ' + e.message;
|
|
showEl('previewError');
|
|
}
|
|
}
|
|
|
|
function showPreviewData(data) {
|
|
hideEl('previewHint');
|
|
hideEl('previewLoading');
|
|
hideEl('previewError');
|
|
|
|
// PDF 类型
|
|
if (data.type === 'pdf' && data.pdf_base64) {
|
|
const pdfBlob = base64ToBlob(data.pdf_base64, 'application/pdf');
|
|
const pdfUrl = URL.createObjectURL(pdfBlob);
|
|
document.getElementById('previewContent').innerHTML =
|
|
'<embed src="' + pdfUrl + '" type="application/pdf" width="100%" height="600px" />';
|
|
showEl('previewContent');
|
|
return;
|
|
}
|
|
|
|
const html = typeof data === 'string' ? data : (data.html || '');
|
|
if (!html || html.trim() === '') {
|
|
showEmptyData('previewContent', '暂无预览数据');
|
|
} else {
|
|
document.getElementById('previewContent').innerHTML = html;
|
|
}
|
|
showEl('previewContent');
|
|
}
|
|
|
|
function base64ToBlob(base64, mimeType) {
|
|
const byteChars = atob(base64);
|
|
const byteArrays = [];
|
|
for (let offset = 0; offset < byteChars.length; offset += 512) {
|
|
const slice = byteChars.slice(offset, offset + 512);
|
|
const byteNumbers = new Array(slice.length);
|
|
for (let i = 0; i < slice.length; i++) {
|
|
byteNumbers[i] = slice.charCodeAt(i);
|
|
}
|
|
byteArrays.push(new Uint8Array(byteNumbers));
|
|
}
|
|
return new Blob(byteArrays, { type: mimeType });
|
|
}
|
|
|
|
// ── 大类专业信息卡片 ────────────────────────────────
|
|
function renderHomeCard(item) {
|
|
const card = document.getElementById('homeCard');
|
|
if (!item) { card.classList.add('hidden'); return; }
|
|
card.classList.remove('hidden');
|
|
|
|
const bjgsMap = { '1': '全日制', '2': '非全日制', '3': '其他' };
|
|
const bjgs = bjgsMap[item.bjgs] || item.bjgs || '--';
|
|
|
|
// 提取关键字段
|
|
const fields = [
|
|
['专业名称', item.zymc],
|
|
['专业号', item.zyh],
|
|
['年级', item.njmc],
|
|
['学制', item.xz ? item.xz + '年' : '--'],
|
|
['课程数', item.kcs],
|
|
['办学形式', bjgs],
|
|
['大类标识', item.dlbs],
|
|
['是否归档', item.sfgazy],
|
|
].filter(([,v]) => v != null && v !== '' && v !== undefined);
|
|
|
|
let html = '<div class="grid grid-cols-2 md:grid-cols-4 gap-3">';
|
|
for (const [label, val] of fields) {
|
|
html += '<div class="bg-white dark:bg-black/20 rounded-xl p-3 border border-gray-100 dark:border-gray-800">' +
|
|
'<div class="text-xs text-gray-400 mb-1">' + escHtml(label) + '</div>' +
|
|
'<div class="text-sm font-semibold break-all">' + escHtml(String(val)) + '</div></div>';
|
|
}
|
|
html += '</div>';
|
|
card.innerHTML = html;
|
|
|
|
// 隐藏提示,显示卡片
|
|
document.getElementById('homeHint').classList.add('hidden');
|
|
}
|
|
|
|
// ── 定位我的专业 ─────────────────────────────────────
|
|
let myPlanId = null;
|
|
|
|
async function locateMyPlan() {
|
|
const btn = document.getElementById('locateMyPlanBtn');
|
|
btn.disabled = true;
|
|
btn.innerHTML = '<div class="w-4 h-4 border-2 border-black dark:border-white border-t-transparent rounded-full animate-spin"></div> 查找中...';
|
|
|
|
// 获取学生信息
|
|
let zyhId = null; // 专业号ID (如 33BA3199B8142DC7E065000000000001)
|
|
let majorName = null; // 专业名称 (如 "虚拟现实技术")
|
|
try {
|
|
const res = await fetch('/api/jwxt/student-info');
|
|
const data = await res.json();
|
|
if (data.success && data.info) {
|
|
zyhId = data.info['招生专业ID'] || data.info['zyh_id'] || null;
|
|
const rawZy = data.info['招生专业'] || null;
|
|
if (rawZy) {
|
|
// 「招生专业」的值可能是 ID(长 hex)或名称(中文),按格式区分
|
|
if (/^[A-F0-9]{20,}$/i.test(rawZy)) {
|
|
zyhId = zyhId || rawZy; // 是 ID,当作 zyh_id 用
|
|
} else {
|
|
majorName = rawZy; // 是名称,当作专业名用
|
|
}
|
|
}
|
|
}
|
|
} catch (e) {
|
|
console.error('获取学生信息失败:', e);
|
|
}
|
|
|
|
if (!zyhId && !majorName) {
|
|
btn.disabled = false;
|
|
btn.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="10" r="3"/><path d="M12 21.7C17.3 17 20 13 20 10a8 8 0 10-16 0c0 3 2.7 7 8 11.7z"/></svg> 我的专业';
|
|
alert('无法获取您的专业信息,请手动选择');
|
|
return;
|
|
}
|
|
|
|
// 通过 zyh_id 精确过滤(只返回 1 条),或拉全部列表按名称匹配
|
|
document.getElementById('njdmSelect').value = '';
|
|
document.getElementById('zyhInput').value = zyhId || '';
|
|
await refresh();
|
|
|
|
btn.disabled = false;
|
|
btn.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="10" r="3"/><path d="M12 21.7C17.3 17 20 13 20 10a8 8 0 10-16 0c0 3 2.7 7 8 11.7z"/></svg> 我的专业';
|
|
|
|
// 找匹配项
|
|
let item = null;
|
|
if (zyhId) {
|
|
item = allItems.length > 0 ? allItems[0] : null;
|
|
} else {
|
|
item = allItems.find(it => it.zymc === majorName);
|
|
}
|
|
|
|
if (item) {
|
|
myPlanId = item.jxzxjhxx_id || item.WID;
|
|
onRowSelect(myPlanId);
|
|
// 滚动到选中行
|
|
const row = document.querySelector('tr[data-id="' + myPlanId.replace(/"/g, '\\"') + '"]');
|
|
if (row) {
|
|
row.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
|
row.classList.add('bg-black/5', 'dark:bg-white/5');
|
|
setTimeout(() => row.classList.remove('bg-black/5', 'dark:bg-white/5'), 2000);
|
|
}
|
|
} else {
|
|
const hint = zyhId ? ('zyh_id=' + zyhId.substring(0, 8) + '...') : ('名称「' + majorName + '」');
|
|
alert('未找到匹配的教学计划 (' + hint + '),请尝试手动筛选');
|
|
}
|
|
}
|
|
|
|
// ── 工具 ───────────────────────────────────────────
|
|
function showEl(id) {
|
|
document.getElementById(id).classList.remove('hidden');
|
|
}
|
|
function hideEl(id) {
|
|
document.getElementById(id).classList.add('hidden');
|
|
}
|
|
|
|
// ── 启动 ───────────────────────────────────────────
|
|
initSession().then(() => { setupDarkObserver(); refresh(); });
|
|
</script>
|
|
{% endblock %}
|