Compare commits

..

No commits in common. 'd77b307457532e8814260e0a8b65adfaba32ef00' and '30e5c9ee112f5d61f090b79a8225953001801951' have entirely different histories.

@ -6,23 +6,23 @@
<svg class="decoration-lines" viewBox="0 0 400 60" preserveAspectRatio="xMidYMid slice"> <svg class="decoration-lines" viewBox="0 0 400 60" preserveAspectRatio="xMidYMid slice">
<defs> <defs>
<linearGradient id="headerGrad" x1="0%" y1="0%" x2="100%" y2="0%"> <linearGradient id="headerGrad" x1="0%" y1="0%" x2="100%" y2="0%">
<stop offset="0%" style="stop-color: #2563eb; stop-opacity: 0" /> <stop offset="0%" style="stop-color:#2563eb;stop-opacity:0" />
<stop offset="50%" style="stop-color: #2563eb; stop-opacity: 0.3" /> <stop offset="50%" style="stop-color:#2563eb;stop-opacity:0.3" />
<stop offset="100%" style="stop-color: #2ba471; stop-opacity: 0" /> <stop offset="100%" style="stop-color:#2ba471;stop-opacity:0" />
</linearGradient> </linearGradient>
</defs> </defs>
<line x1="0" y1="58" x2="400" y2="58" stroke="url(#headerGrad)" stroke-width="1" /> <line x1="0" y1="58" x2="400" y2="58" stroke="url(#headerGrad)" stroke-width="1"/>
<circle cx="50" cy="30" r="3" fill="#2563eb" opacity="0.2" /> <circle cx="50" cy="30" r="3" fill="#2563eb" opacity="0.2"/>
<circle cx="150" cy="20" r="2" fill="#2ba471" opacity="0.2" /> <circle cx="150" cy="20" r="2" fill="#2ba471" opacity="0.2"/>
<circle cx="250" cy="40" r="2.5" fill="#2563eb" opacity="0.15" /> <circle cx="250" cy="40" r="2.5" fill="#2563eb" opacity="0.15"/>
<circle cx="350" cy="25" r="2" fill="#2ba471" opacity="0.2" /> <circle cx="350" cy="25" r="2" fill="#2ba471" opacity="0.2"/>
</svg> </svg>
</div> </div>
<div class="header-content"> <div class="header-content">
<div class="header-icon"> <div class="header-icon">
<svg width="32" height="32" viewBox="0 0 24 24" fill="none"> <svg width="32" height="32" viewBox="0 0 24 24" fill="none">
<path d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2" stroke="#2563eb" stroke-width="1.5" stroke-linecap="round" /> <path d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2" stroke="#2563eb" stroke-width="1.5" stroke-linecap="round"/>
<path d="M9 12h6M9 16h6" stroke="#2563eb" stroke-width="1.5" stroke-linecap="round" /> <path d="M9 12h6M9 16h6" stroke="#2563eb" stroke-width="1.5" stroke-linecap="round"/>
</svg> </svg>
</div> </div>
<div class="header-text"> <div class="header-text">
@ -48,16 +48,22 @@
<div class="search-area"> <div class="search-area">
<div class="search-box"> <div class="search-box">
<svg class="search-icon" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <svg class="search-icon" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="11" cy="11" r="8" /> <circle cx="11" cy="11" r="8"/>
<path d="M21 21l-4.35-4.35" /> <path d="M21 21l-4.35-4.35"/>
</svg> </svg>
<input v-model.trim="keyword" type="text" placeholder="输入实训任务名称搜索..." class="search-input" @keyup.enter="queryTasks" /> <input
v-model.trim="keyword"
type="text"
placeholder="输入实训任务名称搜索..."
class="search-input"
@keyup.enter="queryTasks"
/>
<button v-if="keyword" class="clear-btn" @click="keyword = ''">×</button> <button v-if="keyword" class="clear-btn" @click="keyword = ''">×</button>
</div> </div>
<el-button type="primary" class="search-btn" @click="queryTasks"> <el-button type="primary" class="search-btn" @click="queryTasks">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="11" cy="11" r="8" /> <circle cx="11" cy="11" r="8"/>
<path d="M21 21l-4.35-4.35" /> <path d="M21 21l-4.35-4.35"/>
</svg> </svg>
<span>查询</span> <span>查询</span>
</el-button> </el-button>
@ -65,18 +71,18 @@
<div class="toolbar-actions"> <div class="toolbar-actions">
<button class="tool-btn" @click="downloadTemplate"> <button class="tool-btn" @click="downloadTemplate">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4" /> <path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"/>
<polyline points="7 10 12 15 17 10" /> <polyline points="7 10 12 15 17 10"/>
<line x1="12" y1="15" x2="12" y2="3" /> <line x1="12" y1="15" x2="12" y2="3"/>
</svg> </svg>
<span>下载模板</span> <span>下载模板</span>
</button> </button>
<el-upload action="#" :auto-upload="false" :show-file-list="false" :on-change="handleImportChange"> <el-upload action="#" :auto-upload="false" :show-file-list="false" :on-change="handleImportChange">
<button class="tool-btn"> <button class="tool-btn">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4" /> <path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"/>
<polyline points="17 8 12 3 7 8" /> <polyline points="17 8 12 3 7 8"/>
<line x1="12" y1="3" x2="12" y2="15" /> <line x1="12" y1="3" x2="12" y2="15"/>
</svg> </svg>
<span>导入配置</span> <span>导入配置</span>
</button> </button>
@ -87,23 +93,33 @@
<div class="project-filter"> <div class="project-filter">
<span class="filter-label"> <span class="filter-label">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M22 19a2 2 0 01-2 2H4a2 2 0 01-2-2V5a2 2 0 012-2h5l2 3h9a2 2 0 012 2z" /> <path d="M22 19a2 2 0 01-2 2H4a2 2 0 01-2-2V5a2 2 0 012-2h5l2 3h9a2 2 0 012 2z"/>
</svg> </svg>
所属项目: 所属项目:
</span> </span>
<div class="project-tabs"> <div class="project-tabs">
<button type="button" :class="['project-tab', { active: !activeProject }]" @click="activeProject = ''"> <button
type="button"
:class="['project-tab', { active: !activeProject }]"
@click="activeProject = ''"
>
<span class="tab-name">全部</span> <span class="tab-name">全部</span>
<span class="tab-count">{{ tasks.length }}</span> <span class="tab-count">{{ tasks.length }}</span>
</button> </button>
<button v-for="project in projectOptions" :key="project.name" type="button" :class="['project-tab', { active: activeProject === project.name }]" @click="toggleProject(project.name)"> <button
v-for="project in projectOptions"
:key="project.name"
type="button"
:class="['project-tab', { active: activeProject === project.name }]"
@click="toggleProject(project.name)"
>
<span class="tab-name">{{ project.name }}</span> <span class="tab-name">{{ project.name }}</span>
<span class="tab-count">{{ project.count }}</span> <span class="tab-count">{{ project.count }}</span>
</button> </button>
</div> </div>
<div class="filter-result"> <div class="filter-result">
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<polyline points="20 6 9 17 4 12" /> <polyline points="20 6 9 17 4 12"/>
</svg> </svg>
<span>显示 {{ filteredTasks.length }} / {{ tasks.length }} 条</span> <span>显示 {{ filteredTasks.length }} / {{ tasks.length }} 条</span>
</div> </div>
@ -112,19 +128,27 @@
<!-- 任务网格 --> <!-- 任务网格 -->
<section v-loading="loading" class="task-grid"> <section v-loading="loading" class="task-grid">
<article v-for="(task, index) in filteredTasks" :key="task.id || task.taskKey" class="task-card" role="button" tabindex="0" @click="viewTask(task)" @keydown.enter.prevent="viewTask(task)"> <article
v-for="(task, index) in filteredTasks"
:key="task.id || task.taskKey"
class="task-card"
role="button"
tabindex="0"
@click="viewTask(task)"
@keydown.enter.prevent="viewTask(task)"
>
<div class="card-decoration"> <div class="card-decoration">
<svg class="corner-decoration top-left" width="24" height="24" viewBox="0 0 24 24"> <svg class="corner-decoration top-left" width="24" height="24" viewBox="0 0 24 24">
<path d="M2 8V2h6" stroke="#2563eb" stroke-width="2" fill="none" opacity="0.6" /> <path d="M2 8V2h6" stroke="#2563eb" stroke-width="2" fill="none" opacity="0.6"/>
</svg> </svg>
<svg class="corner-decoration top-right" width="24" height="24" viewBox="0 0 24 24"> <svg class="corner-decoration top-right" width="24" height="24" viewBox="0 0 24 24">
<path d="M22 8V2h-6" stroke="#2563eb" stroke-width="2" fill="none" opacity="0.6" /> <path d="M22 8V2h-6" stroke="#2563eb" stroke-width="2" fill="none" opacity="0.6"/>
</svg> </svg>
<svg class="corner-decoration bottom-left" width="24" height="24" viewBox="0 0 24 24"> <svg class="corner-decoration bottom-left" width="24" height="24" viewBox="0 0 24 24">
<path d="M2 16v6h6" stroke="#2ba471" stroke-width="2" fill="none" opacity="0.4" /> <path d="M2 16v6h6" stroke="#2ba471" stroke-width="2" fill="none" opacity="0.4"/>
</svg> </svg>
<svg class="corner-decoration bottom-right" width="24" height="24" viewBox="0 0 24 24"> <svg class="corner-decoration bottom-right" width="24" height="24" viewBox="0 0 24 24">
<path d="M22 16v6h-6" stroke="#2ba471" stroke-width="2" fill="none" opacity="0.4" /> <path d="M22 16v6h-6" stroke="#2ba471" stroke-width="2" fill="none" opacity="0.4"/>
</svg> </svg>
</div> </div>
@ -134,12 +158,12 @@
<div class="card-header"> <div class="card-header">
<span class="task-project"> <span class="task-project">
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M22 19a2 2 0 01-2 2H4a2 2 0 01-2-2V5a2 2 0 012-2h5l2 3h9a2 2 0 012 2z" /> <path d="M22 19a2 2 0 01-2 2H4a2 2 0 01-2-2V5a2 2 0 012-2h5l2 3h9a2 2 0 012 2z"/>
</svg> </svg>
{{ task.project || "默认实训任务" }} {{ task.project || "默认实训任务" }}
</span> </span>
<span :class="['task-status', { enabled: task.enabled }]"> <span :class="['task-status', { enabled: task.enabled }]">
{{ task.enabled ? "启用" : "停用" }} {{ task.enabled ? '启用' : '停用' }}
</span> </span>
</div> </div>
@ -148,15 +172,15 @@
<div class="task-meta"> <div class="task-meta">
<span class="meta-item"> <span class="meta-item">
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M9 11l3 3L22 4" /> <path d="M9 11l3 3L22 4"/>
<path d="M21 12v7a2 2 0 01-2 2H5a2 2 0 01-2-2V5a2 2 0 012-2h11" /> <path d="M21 12v7a2 2 0 01-2 2H5a2 2 0 01-2-2V5a2 2 0 012-2h11"/>
</svg> </svg>
{{ task.objectives?.length || 0 }} 个目标 {{ task.objectives?.length || 0 }} 个目标
</span> </span>
<span class="meta-item"> <span class="meta-item">
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z" /> <path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"/>
<polyline points="14 2 14 8 20 8" /> <polyline points="14 2 14 8 20 8"/>
</svg> </svg>
{{ task.steps?.length || 0 }} 个步骤 {{ task.steps?.length || 0 }} 个步骤
</span> </span>
@ -166,8 +190,8 @@
<div class="card-actions" @click.stop> <div class="card-actions" @click.stop>
<el-button type="primary" class="edit-btn" @click="editTask(task)"> <el-button type="primary" class="edit-btn" @click="editTask(task)">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7" /> <path d="M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7"/>
<path d="M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z" /> <path d="M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z"/>
</svg> </svg>
编辑任务 编辑任务
</el-button> </el-button>
@ -180,32 +204,39 @@
<el-empty v-if="!filteredTasks.length && !loading" class="task-empty" description="暂无匹配的实训任务"> <el-empty v-if="!filteredTasks.length && !loading" class="task-empty" description="暂无匹配的实训任务">
<template #image> <template #image>
<svg width="80" height="80" viewBox="0 0 24 24" fill="none" stroke="#2563eb" stroke-width="1" opacity="0.3"> <svg width="80" height="80" viewBox="0 0 24 24" fill="none" stroke="#2563eb" stroke-width="1" opacity="0.3">
<path d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2" /> <path d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2"/>
<rect x="9" y="3" width="6" height="4" rx="1" /> <rect x="9" y="3" width="6" height="4" rx="1"/>
</svg> </svg>
</template> </template>
</el-empty> </el-empty>
</section> </section>
<!-- 抽屉编辑 --> <!-- 抽屉编辑 -->
<el-drawer v-model="dialogVisible" :size="860" class="training-task-drawer" append-to-body destroy-on-close :with-header="false"> <el-drawer
v-model="dialogVisible"
:size="860"
class="training-task-drawer"
append-to-body
destroy-on-close
:with-header="false"
>
<div class="drawer-shell"> <div class="drawer-shell">
<header class="drawer-header"> <header class="drawer-header">
<div class="drawer-heading"> <div class="drawer-heading">
<span class="drawer-kicker"> <span class="drawer-kicker">
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="12" cy="12" r="10" /> <circle cx="12" cy="12" r="10"/>
<path d="M12 8v4l3 3" /> <path d="M12 8v4l3 3"/>
</svg> </svg>
{{ dialogMode === "view" ? "Training Task Preview" : "Training Task Editor" }} {{ dialogMode === "view" ? 'Training Task Preview' : 'Training Task Editor' }}
</span> </span>
<h3>{{ dialogMode === "view" ? "查看实训任务" : "编辑实训任务" }}</h3> <h3>{{ dialogMode === "view" ? "查看实训任务" : "编辑实训任务" }}</h3>
<p>管理员维护系统默认实训配置,教学班未单独配置时学生端使用这里的实训背景、目标、要求和案例文档。</p> <p>管理员维护系统默认实训配置,教学班未单独配置时学生端使用这里的实训背景、目标、要求和案例文档。</p>
</div> </div>
<button class="drawer-close-button" aria-label="关闭抽屉" @click="dialogVisible = false"> <button class="drawer-close-button" aria-label="关闭抽屉" @click="dialogVisible = false">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<line x1="18" y1="6" x2="6" y2="18" /> <line x1="18" y1="6" x2="6" y2="18"/>
<line x1="6" y1="6" x2="18" y2="18" /> <line x1="6" y1="6" x2="18" y2="18"/>
</svg> </svg>
</button> </button>
</header> </header>
@ -213,7 +244,7 @@
<div class="drawer-identity"> <div class="drawer-identity">
<div class="identity-item"> <div class="identity-item">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M22 19a2 2 0 01-2 2H4a2 2 0 01-2-2V5a2 2 0 012-2h5l2 3h9a2 2 0 012 2z" /> <path d="M22 19a2 2 0 01-2 2H4a2 2 0 01-2-2V5a2 2 0 012-2h5l2 3h9a2 2 0 012 2z"/>
</svg> </svg>
<div class="identity-content"> <div class="identity-content">
<span class="identity-label">所属项目</span> <span class="identity-label">所属项目</span>
@ -222,8 +253,8 @@
</div> </div>
<div class="identity-item"> <div class="identity-item">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2" /> <path d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2"/>
<rect x="9" y="3" width="6" height="4" rx="1" /> <rect x="9" y="3" width="6" height="4" rx="1"/>
</svg> </svg>
<div class="identity-content"> <div class="identity-content">
<span class="identity-label">实训任务</span> <span class="identity-label">实训任务</span>
@ -232,8 +263,8 @@
</div> </div>
<div class="identity-item status"> <div class="identity-item status">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M22 11.08V12a10 10 0 11-5.93-9.14" /> <path d="M22 11.08V12a10 10 0 11-5.93-9.14"/>
<polyline points="22 4 12 14.01 9 11.01" /> <polyline points="22 4 12 14.01 9 11.01"/>
</svg> </svg>
<div class="identity-content"> <div class="identity-content">
<span class="identity-label">任务状态</span> <span class="identity-label">任务状态</span>
@ -267,7 +298,7 @@
<el-form-item label="任务状态:"> <el-form-item label="任务状态:">
<div class="switch-wrapper"> <div class="switch-wrapper">
<el-switch v-model="taskForm.enabled" /> <el-switch v-model="taskForm.enabled" />
<span class="switch-label">{{ taskForm.enabled ? "已启用" : "已停用" }}</span> <span class="switch-label">{{ taskForm.enabled ? '已启用' : '已停用' }}</span>
</div> </div>
</el-form-item> </el-form-item>
<el-form-item label="实训背景:"> <el-form-item label="实训背景:">
@ -288,17 +319,23 @@
<div v-for="(objective, index) in taskForm.objectives" :key="index" class="objective-row"> <div v-for="(objective, index) in taskForm.objectives" :key="index" class="objective-row">
<div class="objective-number">{{ index + 1 }}</div> <div class="objective-number">{{ index + 1 }}</div>
<el-input v-model="taskForm.objectives[index]" placeholder="请输入实训目标" /> <el-input v-model="taskForm.objectives[index]" placeholder="请输入实训目标" />
<button v-if="!isReadonly" type="button" class="remove-btn" :disabled="taskForm.objectives.length <= 1" @click="removeObjective(index)"> <button
v-if="!isReadonly"
type="button"
class="remove-btn"
:disabled="taskForm.objectives.length <= 1"
@click="removeObjective(index)"
>
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<line x1="18" y1="6" x2="6" y2="18" /> <line x1="18" y1="6" x2="6" y2="18"/>
<line x1="6" y1="6" x2="18" y2="18" /> <line x1="6" y1="6" x2="18" y2="18"/>
</svg> </svg>
</button> </button>
</div> </div>
<button v-if="!isReadonly" type="button" class="add-objective-button" @click="addObjective"> <button v-if="!isReadonly" type="button" class="add-objective-button" @click="addObjective">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<line x1="12" y1="5" x2="12" y2="19" /> <line x1="12" y1="5" x2="12" y2="19"/>
<line x1="5" y1="12" x2="19" y2="12" /> <line x1="5" y1="12" x2="19" y2="12"/>
</svg> </svg>
新增目标 新增目标
</button> </button>
@ -315,14 +352,14 @@
<span class="section-number">03</span> <span class="section-number">03</span>
<div class="section-info"> <div class="section-info">
<h4>资料与步骤</h4> <h4>资料与步骤</h4>
<p>上传案例资料、案例数据、实训指导手册与AI排错指导手册,配置实训步骤</p> <p>上传案例资料、案例视频、实训指导手册与AI排错指导手册,配置实训步骤</p>
</div> </div>
</div> </div>
<div v-for="slot in materialSlots" :key="slot.key" class="material-row"> <div v-for="slot in materialSlots" :key="slot.key" class="material-row">
<div class="material-info"> <div class="material-info">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z" /> <path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"/>
<polyline points="14 2 14 8 20 8" /> <polyline points="14 2 14 8 20 8"/>
</svg> </svg>
<div class="material-text"> <div class="material-text">
<span class="material-label">{{ slot.label }}</span> <span class="material-label">{{ slot.label }}</span>
@ -331,17 +368,29 @@
</div> </div>
</div> </div>
<div class="material-ops"> <div class="material-ops">
<el-upload v-if="!isReadonly" action="#" :auto-upload="false" :show-file-list="false" :on-change="(file) => handleMaterialChange(slot.key, file)"> <el-upload
v-if="!isReadonly"
action="#"
:auto-upload="false"
:show-file-list="false"
:on-change="(file) => handleMaterialChange(slot.key, file)"
>
<el-button type="primary" :loading="uploadingField === slot.key" class="upload-btn"> <el-button type="primary" :loading="uploadingField === slot.key" class="upload-btn">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4" /> <path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"/>
<polyline points="17 8 12 3 7 8" /> <polyline points="17 8 12 3 7 8"/>
<line x1="12" y1="3" x2="12" y2="15" /> <line x1="12" y1="3" x2="12" y2="15"/>
</svg> </svg>
{{ uploadingField === slot.key ? "上传中..." : "上传" }} {{ uploadingField === slot.key ? '上传中...' : '上传' }}
</el-button> </el-button>
</el-upload> </el-upload>
<el-button v-if="!isReadonly && hasMaterial(slot.key)" type="danger" plain class="clear-material-btn" @click="clearMaterial(slot.key)">清除</el-button> <el-button
v-if="!isReadonly && hasMaterial(slot.key)"
type="danger"
plain
class="clear-material-btn"
@click="clearMaterial(slot.key)"
>清除</el-button>
</div> </div>
</div> </div>
@ -354,28 +403,35 @@
<div v-for="(step, index) in taskForm.steps" :key="step.id" class="step-item"> <div v-for="(step, index) in taskForm.steps" :key="step.id" class="step-item">
<div class="step-connector" v-if="index > 0"> <div class="step-connector" v-if="index > 0">
<svg width="20" height="12" viewBox="0 0 20 12"> <svg width="20" height="12" viewBox="0 0 20 12">
<path d="M0 6h16M12 1l4 5-4 5" stroke="#2563eb" stroke-width="1.5" fill="none" opacity="0.5" /> <path d="M0 6h16M12 1l4 5-4 5" stroke="#2563eb" stroke-width="1.5" fill="none" opacity="0.5"/>
</svg> </svg>
</div> </div>
<div class="step-content"> <div class="step-content">
<span class="step-number">{{ index + 1 }}</span> <span class="step-number">{{ index + 1 }}</span>
<el-input v-model="step.name" placeholder="步骤名称" /> <el-input v-model="step.name" placeholder="步骤名称" />
<template v-if="index === 0 && supportsStepOneChoice(taskForm.taskKey)"> <template v-if="index === 0 && supportsStepOneChoice(taskForm.taskKey)">
<el-button v-if="!isReadonly" type="primary" class="step-question-btn" @click="choiceEditorVisible = true">编辑题目{{ stepOneQuestionCount ? `(${stepOneQuestionCount}题)` : "" }}</el-button> <el-button v-if="!isReadonly" type="primary" class="step-question-btn" @click="choiceEditorVisible = true">
编辑题目{{ stepOneQuestionCount ? `(${stepOneQuestionCount}题)` : "" }}
</el-button>
<span v-else class="step-question-tag">已配置 {{ stepOneQuestionCount }} 道题</span> <span v-else class="step-question-tag">已配置 {{ stepOneQuestionCount }} 道题</span>
</template> </template>
<button v-if="!isReadonly && taskForm.steps.length > 1" type="button" class="remove-btn" @click="removeStep(index)"> <button
v-if="!isReadonly && taskForm.steps.length > 1"
type="button"
class="remove-btn"
@click="removeStep(index)"
>
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<polyline points="3 6 5 6 21 6" /> <polyline points="3 6 5 6 21 6"/>
<path d="M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2" /> <path d="M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2"/>
</svg> </svg>
</button> </button>
</div> </div>
</div> </div>
<button v-if="!isReadonly" type="button" class="add-step-button" @click="addStep"> <button v-if="!isReadonly" type="button" class="add-step-button" @click="addStep">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<line x1="12" y1="5" x2="12" y2="19" /> <line x1="12" y1="5" x2="12" y2="19"/>
<line x1="5" y1="12" x2="19" y2="12" /> <line x1="5" y1="12" x2="19" y2="12"/>
</svg> </svg>
新增步骤 新增步骤
</button> </button>
@ -386,13 +442,13 @@
<footer class="drawer-footer"> <footer class="drawer-footer">
<el-button class="cancel-btn" @click="dialogVisible = false"> <el-button class="cancel-btn" @click="dialogVisible = false">
{{ isReadonly ? "关闭" : "取消" }} {{ isReadonly ? '关闭' : '取消' }}
</el-button> </el-button>
<el-button v-if="!isReadonly" type="primary" class="save-btn" :loading="saving" @click="submitTask"> <el-button v-if="!isReadonly" type="primary" class="save-btn" :loading="saving" @click="submitTask">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M19 21H5a2 2 0 01-2-2V5a2 2 0 012-2h11l5 5v11a2 2 0 01-2 2z" /> <path d="M19 21H5a2 2 0 01-2-2V5a2 2 0 012-2h11l5 5v11a2 2 0 01-2 2z"/>
<polyline points="17 21 17 13 7 13 7 21" /> <polyline points="17 21 17 13 7 13 7 21"/>
<polyline points="7 3 7 8 15 8" /> <polyline points="7 3 7 8 15 8"/>
</svg> </svg>
保存配置 保存配置
</el-button> </el-button>
@ -403,7 +459,13 @@
</template> </template>
<script setup> <script setup>
import { downloadTrainingTaskTemplate, importTrainingTasks, listTrainingTasks, updateTrainingTask, uploadTrainingTaskMaterial } from "@/api/trainingTask"; import {
downloadTrainingTaskTemplate,
importTrainingTasks,
listTrainingTasks,
updateTrainingTask,
uploadTrainingTaskMaterial,
} from "@/api/trainingTask";
import StepOneChoiceQuestionEditor from "@/views/components/StepOneChoiceQuestionEditor.vue"; import StepOneChoiceQuestionEditor from "@/views/components/StepOneChoiceQuestionEditor.vue";
import StepOneQuestionBankPicker from "@/views/components/StepOneQuestionBankPicker.vue"; import StepOneQuestionBankPicker from "@/views/components/StepOneQuestionBankPicker.vue";
import { parseStepOneChoiceQuestions, supportsStepOneChoiceQuestions } from "@/utils/stepOneChoiceQuestions"; import { parseStepOneChoiceQuestions, supportsStepOneChoiceQuestions } from "@/utils/stepOneChoiceQuestions";
@ -421,9 +483,9 @@ const bankPickerVisible = ref(false);
// 四类资料槽位:key 对应 taskForm 的 `${key}Name` / `${key}Url` 字段 // 四类资料槽位:key 对应 taskForm 的 `${key}Name` / `${key}Url` 字段
const materialSlots = [ const materialSlots = [
{ key: "material", label: "案例资料" }, { key: "material", label: "案例资料" },
{ key: "trainingData", label: "案例数据" }, { key: "trainingData", label: "案例视频" },
{ key: "guideManual", label: "实训指导手册" }, { key: "guideManual", label: "实训指导手册" },
{ key: "aiManual", label: "AI辅助指导手册" }, { key: "aiManual", label: "AI排错指导手册" },
]; ];
const tasks = ref([]); const tasks = ref([]);
const dialogVisible = ref(false); const dialogVisible = ref(false);
@ -433,7 +495,7 @@ const taskForm = reactive(createEmptyTask());
const isReadonly = computed(() => dialogMode.value === "view"); const isReadonly = computed(() => dialogMode.value === "view");
const stepOneQuestionCount = computed(() => taskForm.stepOneQuestions?.length || 0); const stepOneQuestionCount = computed(() => taskForm.stepOneQuestions?.length || 0);
const enabledCount = computed(() => tasks.value.filter((t) => t.enabled).length); const enabledCount = computed(() => tasks.value.filter(t => t.enabled).length);
const projects = computed(() => [...new Set(tasks.value.map((task) => task.project).filter(Boolean))]); const projects = computed(() => [...new Set(tasks.value.map((task) => task.project).filter(Boolean))]);
const projectOptions = computed(() => { const projectOptions = computed(() => {
@ -1081,9 +1143,7 @@ function buildPayload() {
&:hover { &:hover {
border-color: rgba(37, 99, 235, 0.45); border-color: rgba(37, 99, 235, 0.45);
transform: translateY(-4px); transform: translateY(-4px);
box-shadow: box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), 0 0 30px rgba(37, 99, 235, 0.15);
0 20px 40px rgba(0, 0, 0, 0.4),
0 0 30px rgba(37, 99, 235, 0.15);
.card-glow { .card-glow {
opacity: 1; opacity: 1;
@ -1101,22 +1161,10 @@ function buildPayload() {
opacity: 0.6; opacity: 0.6;
transition: opacity 0.3s ease; transition: opacity 0.3s ease;
&.top-left { &.top-left { top: 8px; left: 8px; }
top: 8px; &.top-right { top: 8px; right: 8px; }
left: 8px; &.bottom-left { bottom: 8px; left: 8px; }
} &.bottom-right { bottom: 8px; right: 8px; }
&.top-right {
top: 8px;
right: 8px;
}
&.bottom-left {
bottom: 8px;
left: 8px;
}
&.bottom-right {
bottom: 8px;
right: 8px;
}
} }
} }
@ -1247,12 +1295,8 @@ function buildPayload() {
} }
@keyframes scanline { @keyframes scanline {
0% { 0% { left: -100%; }
left: -100%; 100% { left: 200%; }
}
100% {
left: 200%;
}
} }
.task-empty { .task-empty {
@ -1402,9 +1446,7 @@ function buildPayload() {
.status-value { .status-value {
color: #ff6b6b; color: #ff6b6b;
&.enabled { &.enabled { color: #2ba471; }
color: #2ba471;
}
} }
} }
@ -1563,8 +1605,7 @@ function buildPayload() {
border: 1px solid rgba(37, 99, 235, 0.4) !important; border: 1px solid rgba(37, 99, 235, 0.4) !important;
box-shadow: none !important; box-shadow: none !important;
&:hover, &:hover, &.is-focus {
&.is-focus {
border-color: rgba(37, 99, 235, 0.6) !important; border-color: rgba(37, 99, 235, 0.6) !important;
} }
} }
@ -1791,8 +1832,7 @@ function buildPayload() {
border: 1px solid rgba(37, 99, 235, 0.4) !important; border: 1px solid rgba(37, 99, 235, 0.4) !important;
box-shadow: none !important; box-shadow: none !important;
&:hover, &:hover, &.is-focus {
&.is-focus {
border-color: rgba(37, 99, 235, 0.6) !important; border-color: rgba(37, 99, 235, 0.6) !important;
} }
} }

File diff suppressed because it is too large Load Diff

@ -1,29 +1,35 @@
<template> <template>
<div class="training-task-page"> <div class="training-task-page">
<!-- 筛选工具栏 --> <!-- 筛选工具栏 -->
<div class="task-toolbar"> <div class="task-toolbar">
<div class="toolbar-left"> <div class="toolbar-left">
<div class="class-filter"> <div class="class-filter">
<span class="filter-label"> <span class="filter-label">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2">
<path d="M17 21v-2a4 4 0 00-4-4H5a4 4 0 00-4 4v2" /> <path d="M17 21v-2a4 4 0 00-4-4H5a4 4 0 00-4 4v2" />
<circle cx="9" cy="7" r="4" /> <circle cx="9" cy="7" r="4" />
<path d="M23 21v-2a4 4 0 00-3-3.87M16 3.13a4 4 0 010 7.75" /> <path d="M23 21v-2a4 4 0 00-3-3.87M16 3.13a4 4 0 010 7.75" />
</svg> </svg>
教学班 教学班
</span> </span>
<el-select v-model="selectedTeachingClassId" :loading="classesLoading" placeholder="请选择教学班" class="class-select" @change="queryTasks"> <el-select v-model="selectedTeachingClassId" :loading="classesLoading" placeholder="请选择教学班"
<el-option v-for="schoolClass in teachingClassList" :key="schoolClass.schoolClassId" :label="schoolClass.className" :value="schoolClass.schoolClassId" /> class="class-select" @change="queryTasks">
<el-option v-for="schoolClass in teachingClassList" :key="schoolClass.schoolClassId"
:label="schoolClass.className" :value="schoolClass.schoolClassId" />
</el-select> </el-select>
</div> </div>
<div class="search-box"> <div class="search-box">
<svg class="search-icon" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <svg class="search-icon" width="16" height="16" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="2">
<circle cx="11" cy="11" r="8" /> <circle cx="11" cy="11" r="8" />
<path d="M21 21l-4.35-4.35" /> <path d="M21 21l-4.35-4.35" />
</svg> </svg>
<el-input v-model.trim="keyword" clearable placeholder="输入实训任务名称搜索..." @keyup.enter="queryTasks" /> <el-input v-model.trim="keyword" clearable placeholder="输入实训任务名称搜索..." @keyup.enter="queryTasks" />
<el-button type="primary" class="search-btn" @click="queryTasks"> <el-button type="primary" class="search-btn" @click="queryTasks">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2">
<circle cx="11" cy="11" r="8" /> <circle cx="11" cy="11" r="8" />
<path d="M21 21l-4.35-4.35" /> <path d="M21 21l-4.35-4.35" />
</svg> </svg>
@ -34,26 +40,30 @@
<div class="toolbar-right"> <div class="toolbar-right">
<div class="status-indicator"> <div class="status-indicator">
<el-tag v-if="selectedTeachingClass" type="success" effect="dark" size="small" class="status-tag"> <el-tag v-if="selectedTeachingClass" type="success" effect="dark" size="small" class="status-tag">
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2">
<path d="M22 19a2 2 0 01-2 2H4a2 2 0 01-2-2V5a2 2 0 012-2h5l2 3h9a2 2 0 012 2z" /> <path d="M22 19a2 2 0 01-2 2H4a2 2 0 01-2-2V5a2 2 0 012-2h5l2 3h9a2 2 0 012 2z" />
</svg> </svg>
班级配置模式 班级配置模式
</el-tag> </el-tag>
<el-tag v-else effect="plain" size="small" class="status-tag"> <el-tag v-else effect="plain" size="small" class="status-tag">
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2">
<path d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2" /> <path d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2" />
</svg> </svg>
默认任务 默认任务
</el-tag> </el-tag>
</div> </div>
<el-button v-if="selectedTeachingClass" type="danger" plain class="toolbar-btn toolbar-btn-danger" :loading="restoring" @click="restoreAllTasksDefaults"> <el-button v-if="selectedTeachingClass" type="danger" plain class="toolbar-btn toolbar-btn-danger"
:loading="restoring" @click="restoreAllTasksDefaults">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M3 12a9 9 0 109-9 9.75 9.75 0 00-6.74 2.74L3 8" /> <path d="M3 12a9 9 0 109-9 9.75 9.75 0 00-6.74 2.74L3 8" />
<path d="M3 3v5h5" /> <path d="M3 3v5h5" />
</svg> </svg>
恢复默认 恢复默认
</el-button> </el-button>
<el-button v-if="selectedTeachingClass" type="success" plain class="toolbar-btn toolbar-btn-success" @click="openStudentDemo"> <el-button v-if="selectedTeachingClass" type="success" plain class="toolbar-btn toolbar-btn-success"
@click="openStudentDemo">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" /> <path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" />
<circle cx="12" cy="12" r="3" /> <circle cx="12" cy="12" r="3" />
@ -76,7 +86,9 @@
<span class="tab-name">全部</span> <span class="tab-name">全部</span>
<span class="tab-count">{{ tasks.length }}</span> <span class="tab-count">{{ tasks.length }}</span>
</button> </button>
<button v-for="project in projectOptions" :key="project.name" type="button" :class="['project-tab', { active: activeProject === project.name }]" @click="toggleProject(project.name)"> <button v-for="project in projectOptions" :key="project.name" type="button"
:class="['project-tab', { active: activeProject === project.name }]"
@click="toggleProject(project.name)">
<span class="tab-name">{{ project.name }}</span> <span class="tab-name">{{ project.name }}</span>
<span class="tab-count">{{ project.count }}</span> <span class="tab-count">{{ project.count }}</span>
</button> </button>
@ -91,7 +103,8 @@
<!-- 任务卡片网格 --> <!-- 任务卡片网格 -->
<section v-loading="loading" class="task-grid"> <section v-loading="loading" class="task-grid">
<article v-for="(task, index) in filteredTasks" :key="task.id || task.taskKey" class="task-card" role="button" tabindex="0" @click="viewTask(task)" @keydown.enter.prevent="viewTask(task)"> <article v-for="(task, index) in filteredTasks" :key="task.id || task.taskKey" class="task-card"
role="button" tabindex="0" @click="viewTask(task)" @keydown.enter.prevent="viewTask(task)">
<div class="card-decoration"> <div class="card-decoration">
<svg class="corner-decoration top-left" width="24" height="24" viewBox="0 0 24 24"> <svg class="corner-decoration top-left" width="24" height="24" viewBox="0 0 24 24">
<path d="M2 8V2h6" stroke="#00aaff" stroke-width="2" fill="none" opacity="0.6" /> <path d="M2 8V2h6" stroke="#00aaff" stroke-width="2" fill="none" opacity="0.6" />
@ -112,7 +125,8 @@
<div class="card-content"> <div class="card-content">
<div class="card-header"> <div class="card-header">
<span class="task-project"> <span class="task-project">
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2">
<path d="M22 19a2 2 0 01-2 2H4a2 2 0 01-2-2V5a2 2 0 012-2h5l2 3h9a2 2 0 012 2z" /> <path d="M22 19a2 2 0 01-2 2H4a2 2 0 01-2-2V5a2 2 0 012-2h5l2 3h9a2 2 0 012 2z" />
</svg> </svg>
{{ task.project || "默认实训任务" }} {{ task.project || "默认实训任务" }}
@ -126,14 +140,16 @@
<div class="task-meta"> <div class="task-meta">
<span class="meta-item"> <span class="meta-item">
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2">
<path d="M9 11l3 3L22 4" /> <path d="M9 11l3 3L22 4" />
<path d="M21 12v7a2 2 0 01-2 2H5a2 2 0 01-2-2V5a2 2 0 012-2h11" /> <path d="M21 12v7a2 2 0 01-2 2H5a2 2 0 01-2-2V5a2 2 0 012-2h11" />
</svg> </svg>
{{ task.objectives?.length || 0 }} 个目标 {{ task.objectives?.length || 0 }} 个目标
</span> </span>
<span class="meta-item"> <span class="meta-item">
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2">
<path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z" /> <path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z" />
<polyline points="14 2 14 8 20 8" /> <polyline points="14 2 14 8 20 8" />
</svg> </svg>
@ -144,7 +160,8 @@
<div class="card-actions" @click.stop> <div class="card-actions" @click.stop>
<el-button type="primary" class="edit-btn" @click="handleTaskAction(task)"> <el-button type="primary" class="edit-btn" @click="handleTaskAction(task)">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2">
<path d="M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7" /> <path d="M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7" />
<path d="M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z" /> <path d="M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z" />
</svg> </svg>
@ -157,7 +174,8 @@
</article> </article>
<el-empty v-if="!filteredTasks.length && !loading" class="task-empty" description="暂无匹配的实训任务"> <el-empty v-if="!filteredTasks.length && !loading" class="task-empty" description="暂无匹配的实训任务">
<template #image> <template #image>
<svg width="80" height="80" viewBox="0 0 24 24" fill="none" stroke="#00aaff" stroke-width="1" opacity="0.3"> <svg width="80" height="80" viewBox="0 0 24 24" fill="none" stroke="#00aaff" stroke-width="1"
opacity="0.3">
<path d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2" /> <path d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2" />
<rect x="9" y="3" width="6" height="4" rx="1" /> <rect x="9" y="3" width="6" height="4" rx="1" />
</svg> </svg>
@ -166,12 +184,14 @@
</section> </section>
<!-- 编辑抽屉 --> <!-- 编辑抽屉 -->
<el-drawer v-model="dialogVisible" :size="860" class="training-task-drawer" append-to-body destroy-on-close :with-header="false"> <el-drawer v-model="dialogVisible" :size="860" class="training-task-drawer" append-to-body destroy-on-close
:with-header="false">
<div class="drawer-shell"> <div class="drawer-shell">
<header class="drawer-header"> <header class="drawer-header">
<div class="drawer-heading"> <div class="drawer-heading">
<span class="drawer-kicker"> <span class="drawer-kicker">
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2">
<circle cx="12" cy="12" r="10" /> <circle cx="12" cy="12" r="10" />
<path d="M12 8v4l3 3" /> <path d="M12 8v4l3 3" />
</svg> </svg>
@ -181,7 +201,8 @@
<p>维护教学班实训任务配置,学生端将使用本班的实训背景、目标、要求和案例资料等内容</p> <p>维护教学班实训任务配置,学生端将使用本班的实训背景、目标、要求和案例资料等内容</p>
</div> </div>
<button class="drawer-close-button" aria-label="关闭抽屉" @click="dialogVisible = false"> <button class="drawer-close-button" aria-label="关闭抽屉" @click="dialogVisible = false">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2">
<line x1="18" y1="6" x2="6" y2="18" /> <line x1="18" y1="6" x2="6" y2="18" />
<line x1="6" y1="6" x2="18" y2="18" /> <line x1="6" y1="6" x2="18" y2="18" />
</svg> </svg>
@ -190,7 +211,8 @@
<div class="drawer-identity"> <div class="drawer-identity">
<div class="identity-item"> <div class="identity-item">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2">
<path d="M22 19a2 2 0 01-2 2H4a2 2 0 01-2-2V5a2 2 0 012-2h5l2 3h9a2 2 0 012 2z" /> <path d="M22 19a2 2 0 01-2 2H4a2 2 0 01-2-2V5a2 2 0 012-2h5l2 3h9a2 2 0 012 2z" />
</svg> </svg>
<div class="identity-content"> <div class="identity-content">
@ -199,7 +221,8 @@
</div> </div>
</div> </div>
<div class="identity-item"> <div class="identity-item">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2">
<path d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2" /> <path d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2" />
<rect x="9" y="3" width="6" height="4" rx="1" /> <rect x="9" y="3" width="6" height="4" rx="1" />
</svg> </svg>
@ -209,7 +232,8 @@
</div> </div>
</div> </div>
<div class="identity-item status"> <div class="identity-item status">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2">
<path d="M22 11.08V12a10 10 0 11-5.93-9.14" /> <path d="M22 11.08V12a10 10 0 11-5.93-9.14" />
<polyline points="22 4 12 14.01 9 11.01" /> <polyline points="22 4 12 14.01 9 11.01" />
</svg> </svg>
@ -249,18 +273,23 @@
</div> </div>
<el-form-item label="实训目标:"> <el-form-item label="实训目标:">
<div class="objective-list"> <div class="objective-list">
<div v-for="(objective, index) in taskForm.objectives" :key="index" class="objective-row"> <div v-for="(objective, index) in taskForm.objectives" :key="index"
class="objective-row">
<div class="objective-number">{{ index + 1 }}</div> <div class="objective-number">{{ index + 1 }}</div>
<el-input v-model="taskForm.objectives[index]" placeholder="请输入实训目标" /> <el-input v-model="taskForm.objectives[index]" placeholder="请输入实训目标" />
<button v-if="!isReadonly" type="button" class="remove-btn" :disabled="taskForm.objectives.length <= 1" @click="removeObjective(index)"> <button v-if="!isReadonly" type="button" class="remove-btn"
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> :disabled="taskForm.objectives.length <= 1" @click="removeObjective(index)">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="2">
<line x1="18" y1="6" x2="6" y2="18" /> <line x1="18" y1="6" x2="6" y2="18" />
<line x1="6" y1="6" x2="18" y2="18" /> <line x1="6" y1="6" x2="18" y2="18" />
</svg> </svg>
</button> </button>
</div> </div>
<button v-if="!isReadonly" type="button" class="add-objective-button" @click="addObjective"> <button v-if="!isReadonly" type="button" class="add-objective-button"
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> @click="addObjective">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2">
<line x1="12" y1="5" x2="12" y2="19" /> <line x1="12" y1="5" x2="12" y2="19" />
<line x1="5" y1="12" x2="19" y2="12" /> <line x1="5" y1="12" x2="19" y2="12" />
</svg> </svg>
@ -279,25 +308,30 @@
<span class="section-number">03</span> <span class="section-number">03</span>
<div class="section-info"> <div class="section-info">
<h4>资料与步骤</h4> <h4>资料与步骤</h4>
<p>上传案例资料、案例数据、实训指导手册与AI排错指导手册,配置实训步骤</p> <p>上传案例资料、案例视频、实训指导手册与AI排错指导手册,配置实训步骤</p>
</div> </div>
</div> </div>
<div v-for="slot in materialSlots" :key="slot.key" class="material-row"> <div v-for="slot in materialSlots" :key="slot.key" class="material-row">
<div class="material-info"> <div class="material-info">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2">
<path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z" /> <path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z" />
<polyline points="14 2 14 8 20 8" /> <polyline points="14 2 14 8 20 8" />
</svg> </svg>
<div class="material-text"> <div class="material-text">
<span class="material-label">{{ slot.label }}</span> <span class="material-label">{{ slot.label }}</span>
<span v-if="hasMaterial(slot.key)" class="material-link">{{ taskForm[`${slot.key}Name`] }}</span> <span v-if="hasMaterial(slot.key)" class="material-link">{{
taskForm[`${slot.key}Name`] }}</span>
<span v-else class="material-placeholder">暂未上传</span> <span v-else class="material-placeholder">暂未上传</span>
</div> </div>
</div> </div>
<div class="material-ops"> <div class="material-ops">
<el-upload v-if="!isReadonly" action="#" :auto-upload="false" :show-file-list="false" :on-change="(file) => handleMaterialChange(slot.key, file)"> <el-upload v-if="!isReadonly" action="#" :auto-upload="false" :show-file-list="false"
<el-button type="primary" :loading="uploadingField === slot.key" class="upload-btn"> :on-change="(file) => handleMaterialChange(slot.key, file)">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <el-button type="primary" :loading="uploadingField === slot.key"
class="upload-btn">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="2">
<path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4" /> <path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4" />
<polyline points="17 8 12 3 7 8" /> <polyline points="17 8 12 3 7 8" />
<line x1="12" y1="3" x2="12" y2="15" /> <line x1="12" y1="3" x2="12" y2="15" />
@ -305,7 +339,8 @@
{{ uploadingField === slot.key ? "上传中..." : "上传" }} {{ uploadingField === slot.key ? "上传中..." : "上传" }}
</el-button> </el-button>
</el-upload> </el-upload>
<el-button v-if="!isReadonly && hasMaterial(slot.key)" type="danger" plain class="clear-material-btn" @click="clearMaterial(slot.key)">清除</el-button> <el-button v-if="!isReadonly && hasMaterial(slot.key)" type="danger" plain
class="clear-material-btn" @click="clearMaterial(slot.key)">清除</el-button>
</div> </div>
</div> </div>
@ -319,14 +354,18 @@
<div v-for="(step, index) in taskForm.steps" :key="step.id" class="step-item"> <div v-for="(step, index) in taskForm.steps" :key="step.id" class="step-item">
<div class="step-connector" v-if="index > 0"> <div class="step-connector" v-if="index > 0">
<svg width="20" height="12" viewBox="0 0 20 12"> <svg width="20" height="12" viewBox="0 0 20 12">
<path d="M0 6h16M12 1l4 5-4 5" stroke="#00aaff" stroke-width="1.5" fill="none" opacity="0.5" /> <path d="M0 6h16M12 1l4 5-4 5" stroke="#00aaff" stroke-width="1.5"
fill="none" opacity="0.5" />
</svg> </svg>
</div> </div>
<div class="step-content"> <div class="step-content">
<span class="step-number">{{ index + 1 }}</span> <span class="step-number">{{ index + 1 }}</span>
<el-input v-model="step.name" placeholder="步骤名称" /> <el-input v-model="step.name" placeholder="步骤名称" />
<template v-if="index === 0 && supportsStepOneChoice(taskForm.taskKey)"> <template v-if="index === 0 && supportsStepOneChoice(taskForm.taskKey)">
<el-button v-if="!isReadonly" type="primary" class="step-question-btn" @click="choiceEditorVisible = true">编辑题目{{ stepOneQuestionCount ? `(${stepOneQuestionCount}题)` : "" }}</el-button> <el-button v-if="!isReadonly" type="primary" class="step-question-btn"
@click="choiceEditorVisible = true">
编辑题目{{ stepOneQuestionCount ? `(${stepOneQuestionCount}题)` : "" }}
</el-button>
<span v-else class="step-question-tag">已配置 {{ stepOneQuestionCount }} 道题</span> <span v-else class="step-question-tag">已配置 {{ stepOneQuestionCount }} 道题</span>
</template> </template>
</div> </div>
@ -340,15 +379,18 @@
<el-button class="cancel-btn" @click="dialogVisible = false"> <el-button class="cancel-btn" @click="dialogVisible = false">
{{ isReadonly ? "关闭" : "取消" }} {{ isReadonly ? "关闭" : "取消" }}
</el-button> </el-button>
<el-button v-if="!isReadonly" type="danger" plain class="toolbar-btn toolbar-btn-danger" :loading="restoring" @click="restoreTaskDefault"> <el-button v-if="!isReadonly" type="danger" plain class="toolbar-btn toolbar-btn-danger"
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> :loading="restoring" @click="restoreTaskDefault">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2">
<path d="M3 12a9 9 0 109-9 9.75 9.75 0 00-6.74 2.74L3 8" /> <path d="M3 12a9 9 0 109-9 9.75 9.75 0 00-6.74 2.74L3 8" />
<path d="M3 3v5h5" /> <path d="M3 3v5h5" />
</svg> </svg>
恢复默认 恢复默认
</el-button> </el-button>
<el-button v-if="!isReadonly" type="primary" class="save-btn" :loading="saving" @click="submitTask"> <el-button v-if="!isReadonly" type="primary" class="save-btn" :loading="saving" @click="submitTask">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2">
<path d="M19 21H5a2 2 0 01-2-2V5a2 2 0 012-2h11l5 5v11a2 2 0 01-2 2z" /> <path d="M19 21H5a2 2 0 01-2-2V5a2 2 0 012-2h11l5 5v11a2 2 0 01-2 2z" />
<polyline points="17 21 17 13 7 13 7 21" /> <polyline points="17 21 17 13 7 13 7 21" />
<polyline points="7 3 7 8 15 8" /> <polyline points="7 3 7 8 15 8" />
@ -362,167 +404,167 @@
</template> </template>
<script setup> <script setup>
import { listTrainingTasks, listClassTrainingTasks, saveClassTrainingTask, restoreClassTrainingTaskDefault, restoreClassTrainingTasksDefaults, uploadTrainingTaskMaterial } from "@/api/trainingTask"; import { listTrainingTasks, listClassTrainingTasks, saveClassTrainingTask, restoreClassTrainingTaskDefault, restoreClassTrainingTasksDefaults, uploadTrainingTaskMaterial } from "@/api/trainingTask"
import { createStudentDemoSession } from "@/api/studentDemo"; import { createStudentDemoSession } from "@/api/studentDemo"
import * as indexApi from "@/api/teacher"; import * as indexApi from "@/api/teacher"
import useUserStore from "@/store/modules/user"; import useUserStore from "@/store/modules/user"
import StepOneChoiceQuestionEditor from "@/views/components/StepOneChoiceQuestionEditor.vue"; import StepOneChoiceQuestionEditor from "@/views/components/StepOneChoiceQuestionEditor.vue"
import StepOneQuestionBankPicker from "@/views/components/StepOneQuestionBankPicker.vue"; import StepOneQuestionBankPicker from "@/views/components/StepOneQuestionBankPicker.vue"
import { parseStepOneChoiceQuestions, supportsStepOneChoiceQuestions } from "@/utils/stepOneChoiceQuestions"; import { parseStepOneChoiceQuestions, supportsStepOneChoiceQuestions } from "@/utils/stepOneChoiceQuestions"
import { getQuestions } from "@/api/exam"; import { getQuestions } from "@/api/exam"
const { proxy } = getCurrentInstance(); const { proxy } = getCurrentInstance()
const userStore = useUserStore(); const userStore = useUserStore()
const activeProject = ref(""); const activeProject = ref("")
const keyword = ref(""); const keyword = ref("")
const loading = ref(false); const loading = ref(false)
const classesLoading = ref(false); const classesLoading = ref(false)
const saving = ref(false); const saving = ref(false)
const restoring = ref(false); const restoring = ref(false)
const uploadingField = ref(""); const uploadingField = ref("")
const choiceEditorVisible = ref(false); const choiceEditorVisible = ref(false)
const bankPickerVisible = ref(false); const bankPickerVisible = ref(false)
// 四类资料槽位:key 对应 taskForm 的 `${key}Name` / `${key}Url` 字段,不限制文件类型 // 四类资料槽位:key 对应 taskForm 的 `${key}Name` / `${key}Url` 字段,不限制文件类型
const materialSlots = [ const materialSlots = [
{ key: "material", label: "案例资料" }, { key: "material", label: "案例资料" },
{ key: "trainingData", label: "案例数据" }, { key: "trainingData", label: "案例视频" },
{ key: "guideManual", label: "实训指导手册" }, { key: "guideManual", label: "实训指导手册" },
{ key: "aiManual", label: "AI辅助指导手册" }, { key: "aiManual", label: "AI排错指导手册" },
]; ]
const tasks = ref([]); const tasks = ref([])
const classList = ref([]); const classList = ref([])
const selectedTeachingClassId = ref(""); const selectedTeachingClassId = ref("")
const dialogVisible = ref(false); const dialogVisible = ref(false)
const dialogMode = ref("view"); const dialogMode = ref("view")
const taskForm = reactive(createEmptyTask()); const taskForm = reactive(createEmptyTask())
const currentUserId = computed(() => userStore.userInfo.userId); const currentUserId = computed(() => userStore.userInfo.userId)
const isReadonly = computed(() => dialogMode.value === "view"); const isReadonly = computed(() => dialogMode.value === "view")
const stepOneQuestionCount = computed(() => taskForm.stepOneQuestions?.length || 0); const stepOneQuestionCount = computed(() => taskForm.stepOneQuestions?.length || 0)
const projects = computed(() => [...new Set(tasks.value.map((task) => task.project).filter(Boolean))]); const projects = computed(() => [...new Set(tasks.value.map((task) => task.project).filter(Boolean))])
const projectOptions = computed(() => { const projectOptions = computed(() => {
return projects.value.map((project) => ({ return projects.value.map((project) => ({
name: project, name: project,
count: tasks.value.filter((task) => task.project === project).length, count: tasks.value.filter((task) => task.project === project).length,
})); }))
}); })
const teachingClassList = computed(() => { const teachingClassList = computed(() => {
return classList.value.filter((schoolClass) => { return classList.value.filter((schoolClass) => {
return normalizeClassType(schoolClass) === "TEACHING" && String(schoolClass.createdBy || "") === String(currentUserId.value || ""); return normalizeClassType(schoolClass) === "TEACHING" && String(schoolClass.createdBy || "") === String(currentUserId.value || "")
}); })
}); })
const selectedTeachingClass = computed(() => { const selectedTeachingClass = computed(() => {
return teachingClassList.value.find((schoolClass) => schoolClass.schoolClassId === selectedTeachingClassId.value); return teachingClassList.value.find((schoolClass) => schoolClass.schoolClassId === selectedTeachingClassId.value)
}); })
const filteredTasks = computed(() => { const filteredTasks = computed(() => {
const text = keyword.value.trim(); const text = keyword.value.trim()
return tasks.value.filter((task) => { return tasks.value.filter((task) => {
const matchProject = !activeProject.value || task.project === activeProject.value; const matchProject = !activeProject.value || task.project === activeProject.value
const matchKeyword = !text || task.title.includes(text); const matchKeyword = !text || task.title.includes(text)
return matchProject && matchKeyword; return matchProject && matchKeyword
}); })
}); })
onMounted(() => { onMounted(() => {
setTrainingTaskMainTheme(true); setTrainingTaskMainTheme(true)
loadTeachingClasses(); loadTeachingClasses()
}); })
onActivated(() => { onActivated(() => {
setTrainingTaskMainTheme(true); setTrainingTaskMainTheme(true)
}); })
onDeactivated(() => { onDeactivated(() => {
setTrainingTaskMainTheme(false); setTrainingTaskMainTheme(false)
}); })
onBeforeUnmount(() => { onBeforeUnmount(() => {
setTrainingTaskMainTheme(false); setTrainingTaskMainTheme(false)
}); })
function setTrainingTaskMainTheme(enabled) { function setTrainingTaskMainTheme(enabled) {
const main = document.querySelector(".teacher-main"); const main = document.querySelector(".teacher-main")
if (!main) return; if (!main) return
main.classList.toggle("training-task-main-theme", enabled); main.classList.toggle("training-task-main-theme", enabled)
} }
function toggleProject(project) { function toggleProject(project) {
activeProject.value = activeProject.value === project ? "" : project; activeProject.value = activeProject.value === project ? "" : project
} }
async function queryTasks() { async function queryTasks() {
if (!selectedTeachingClassId.value) { if (!selectedTeachingClassId.value) {
await queryDefaultTasks(); await queryDefaultTasks()
return; return
} }
loading.value = true; loading.value = true
try { try {
const res = await listClassTrainingTasks(selectedTeachingClassId.value, { enabledOnly: false }); const res = await listClassTrainingTasks(selectedTeachingClassId.value, { enabledOnly: false })
tasks.value = (res.data || []).map(normalizeTask); tasks.value = (res.data || []).map(normalizeTask)
resetInvalidProject(); resetInvalidProject()
} catch (error) { } catch (error) {
await queryDefaultTasks(); await queryDefaultTasks()
proxy?.$modal?.msgWarning?.("班级任务加载失败,已显示系统默认任务"); proxy?.$modal?.msgWarning?.("班级任务加载失败,已显示系统默认任务")
} finally { } finally {
loading.value = false; loading.value = false
} }
} }
async function queryDefaultTasks() { async function queryDefaultTasks() {
loading.value = true; loading.value = true
try { try {
const res = await listTrainingTasks({ enabledOnly: false }); const res = await listTrainingTasks({ enabledOnly: false })
tasks.value = (res.data || []).map(normalizeTask); tasks.value = (res.data || []).map(normalizeTask)
resetInvalidProject(); resetInvalidProject()
} catch (error) { } catch (error) {
tasks.value = []; tasks.value = []
} finally { } finally {
loading.value = false; loading.value = false
} }
} }
function resetInvalidProject() { function resetInvalidProject() {
if (activeProject.value && !projects.value.includes(activeProject.value)) { if (activeProject.value && !projects.value.includes(activeProject.value)) {
activeProject.value = ""; activeProject.value = ""
} }
} }
async function loadTeachingClasses() { async function loadTeachingClasses() {
classesLoading.value = true; classesLoading.value = true
try { try {
const res = await indexApi.getClassListBySchoolId({ schoolId: userStore.userInfo.schoolId }); const res = await indexApi.getClassListBySchoolId({ schoolId: userStore.userInfo.schoolId })
classList.value = res.data || []; classList.value = res.data || []
selectedTeachingClassId.value = teachingClassList.value[0]?.schoolClassId || ""; selectedTeachingClassId.value = teachingClassList.value[0]?.schoolClassId || ""
await queryTasks(); await queryTasks()
} catch (error) { } catch (error) {
classList.value = []; classList.value = []
selectedTeachingClassId.value = ""; selectedTeachingClassId.value = ""
await queryDefaultTasks(); await queryDefaultTasks()
} finally { } finally {
classesLoading.value = false; classesLoading.value = false
} }
} }
function normalizeClassType(schoolClass) { function normalizeClassType(schoolClass) {
if (schoolClass?.classType) return schoolClass.classType; if (schoolClass?.classType) return schoolClass.classType
return schoolClass?.createdBy ? "TEACHING" : "ADMIN"; return schoolClass?.createdBy ? "TEACHING" : "ADMIN"
} }
function viewTask(task) { function viewTask(task) {
openTaskDialog(task, "view"); openTaskDialog(task, "view")
} }
function editTask(task) { function editTask(task) {
openTaskDialog(task, "edit"); openTaskDialog(task, "edit")
} }
function handleTaskAction(task) { function handleTaskAction(task) {
if (!selectedTeachingClass.value) { if (!selectedTeachingClass.value) {
viewTask(task); viewTask(task)
return; return
} }
editTask(task); editTask(task)
} }
function createEmptyTask() { function createEmptyTask() {
@ -546,37 +588,37 @@ function createEmptyTask() {
steps: createBuiltinSteps(), steps: createBuiltinSteps(),
sort: 0, sort: 0,
enabled: true, enabled: true,
}; }
} }
function supportsStepOneChoice(taskKey) { function supportsStepOneChoice(taskKey) {
return supportsStepOneChoiceQuestions(taskKey); return supportsStepOneChoiceQuestions(taskKey)
} }
// 本校题库单选题(平台题 + 本校教师题,按学校过滤) // 本校题库单选题(平台题 + 本校教师题,按学校过滤)
async function loadBankQuestions() { async function loadBankQuestions() {
const res = await getQuestions({ scope: "school", type: "SINGLE" }); const res = await getQuestions({ scope: "school", type: "SINGLE" })
return res?.data || []; return res?.data || []
} }
function handleBankConfirm(questions) { function handleBankConfirm(questions) {
taskForm.stepOneQuestions = [...(taskForm.stepOneQuestions || []), ...questions]; taskForm.stepOneQuestions = [...(taskForm.stepOneQuestions || []), ...questions]
proxy?.$modal?.msgSuccess(`已从题库添加 ${questions.length} 道题,点击“保存配置”后生效`); proxy?.$modal?.msgSuccess(`已从题库添加 ${questions.length} 道题,点击“保存配置”后生效`)
} }
function hasMaterial(slotKey) { function hasMaterial(slotKey) {
return isRealMaterial(taskForm[`${slotKey}Name`], taskForm[`${slotKey}Url`]); return isRealMaterial(taskForm[`${slotKey}Name`], taskForm[`${slotKey}Url`])
} }
function materialLabel(slotKey) { function materialLabel(slotKey) {
return materialSlots.find((slot) => slot.key === slotKey)?.label || "资料"; return materialSlots.find((slot) => slot.key === slotKey)?.label || "资料"
} }
function normalizeTask(task) { function normalizeTask(task) {
const material = normalizeMaterial(task.materialName, task.materialUrl); const material = normalizeMaterial(task.materialName, task.materialUrl)
const trainingData = normalizeMaterial(task.trainingDataName, task.trainingDataUrl); const trainingData = normalizeMaterial(task.trainingDataName, task.trainingDataUrl)
const guideManual = normalizeMaterial(task.guideManualName, task.guideManualUrl); const guideManual = normalizeMaterial(task.guideManualName, task.guideManualUrl)
const aiManual = normalizeMaterial(task.aiManualName, task.aiManualUrl); const aiManual = normalizeMaterial(task.aiManualName, task.aiManualUrl)
return { return {
id: task.id, id: task.id,
taskKey: task.taskKey, taskKey: task.taskKey,
@ -597,72 +639,72 @@ function normalizeTask(task) {
steps: normalizeSteps(parseArray(task.steps, createBuiltinSteps())), steps: normalizeSteps(parseArray(task.steps, createBuiltinSteps())),
sort: task.sort || 0, sort: task.sort || 0,
enabled: task.enabled !== false, enabled: task.enabled !== false,
}; }
} }
function normalizeMaterial(materialName, materialUrl) { function normalizeMaterial(materialName, materialUrl) {
const name = String(materialName || "").trim(); const name = String(materialName || "").trim()
const url = normalizeMaterialUrl(materialUrl); const url = normalizeMaterialUrl(materialUrl)
return isRealMaterial(name, url) ? { name, url } : { name: "", url: "" }; return isRealMaterial(name, url) ? { name, url } : { name: "", url: "" }
} }
function isRealMaterial(materialName, materialUrl) { function isRealMaterial(materialName, materialUrl) {
const name = String(materialName || "").trim(); const name = String(materialName || "").trim()
const url = String(materialUrl || "").trim(); const url = String(materialUrl || "").trim()
return Boolean(name && url) && !(name === "案例资料.rar" && url === "/file/example.rar"); return Boolean(name && url) && !(name === "案例资料.rar" && url === "/file/example.rar")
} }
function normalizeMaterialUrl(rawUrl) { function normalizeMaterialUrl(rawUrl) {
const url = String(rawUrl || "").trim(); const url = String(rawUrl || "").trim()
if (!url) { if (!url) {
return ""; return ""
} }
try { try {
const parsed = new URL(url); const parsed = new URL(url)
if (["localhost", "127.0.0.1", "::1"].includes(parsed.hostname) && parsed.pathname.startsWith("/file/")) { if (["localhost", "127.0.0.1", "::1"].includes(parsed.hostname) && parsed.pathname.startsWith("/file/")) {
return `${parsed.pathname}${parsed.search}${parsed.hash}`; return `${parsed.pathname}${parsed.search}${parsed.hash}`
} }
} catch { } catch {
// 相对地址无需转换。 // 相对地址无需转换。
} }
return url; return url
} }
function parseArray(value, fallback) { function parseArray(value, fallback) {
if (Array.isArray(value)) { if (Array.isArray(value)) {
return value.length ? value : fallback; return value.length ? value : fallback
} }
if (!value) { if (!value) {
return fallback; return fallback
} }
try { try {
const parsed = JSON.parse(value); const parsed = JSON.parse(value)
return Array.isArray(parsed) && parsed.length ? parsed : fallback; return Array.isArray(parsed) && parsed.length ? parsed : fallback
} catch (error) { } catch (error) {
return String(value) return String(value)
.split(/[;;||]/) .split(/[;;||]/)
.map((item) => item.trim()) .map((item) => item.trim())
.filter(Boolean); .filter(Boolean)
} }
} }
function normalizeSteps(steps) { function normalizeSteps(steps) {
const source = Array.isArray(steps) ? steps : []; const source = Array.isArray(steps) ? steps : []
const result = source const result = source
.map((item, index) => { .map((item, index) => {
const raw = item && typeof item === "object" ? item : {}; const raw = item && typeof item === "object" ? item : {}
const name = typeof item === "object" ? String(raw.name || "").trim() : String(item || "").trim(); const name = typeof item === "object" ? String(raw.name || "").trim() : String(item || "").trim()
const kind = raw.kind === "custom" ? "custom" : index < 4 ? "builtin" : "custom"; const kind = raw.kind === "custom" ? "custom" : index < 4 ? "builtin" : "custom"
return createStep(name, kind, raw.id); return createStep(name, kind, raw.id)
}) })
.filter((item) => item.name); .filter((item) => item.name)
return result.length ? result : [createStep()]; return result.length ? result : [createStep()]
} }
function createBuiltinSteps() { function createBuiltinSteps() {
return [1, 2, 3, 4].map((index) => createStep("", "builtin", `builtin-${index}`)); return [1, 2, 3, 4].map((index) => createStep("", "builtin", `builtin-${index}`))
} }
function createStep(name = "", kind = "custom", id = "") { function createStep(name = "", kind = "custom", id = "") {
@ -670,13 +712,13 @@ function createStep(name = "", kind = "custom", id = "") {
id: id || `custom-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`, id: id || `custom-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
name, name,
kind, kind,
}; }
} }
function openTaskDialog(task, mode) { function openTaskDialog(task, mode) {
dialogMode.value = mode; dialogMode.value = mode
Object.assign(taskForm, cloneTask(task)); Object.assign(taskForm, cloneTask(task))
dialogVisible.value = true; dialogVisible.value = true
} }
function cloneTask(task) { function cloneTask(task) {
@ -684,128 +726,128 @@ function cloneTask(task) {
...task, ...task,
objectives: [...(task.objectives?.length ? task.objectives : [""])], objectives: [...(task.objectives?.length ? task.objectives : [""])],
steps: normalizeSteps(task.steps?.length ? task.steps : createBuiltinSteps()), steps: normalizeSteps(task.steps?.length ? task.steps : createBuiltinSteps()),
}; }
} }
function addObjective() { function addObjective() {
taskForm.objectives.push(""); taskForm.objectives.push("")
} }
function removeObjective(index) { function removeObjective(index) {
if (taskForm.objectives.length <= 1) return; if (taskForm.objectives.length <= 1) return
taskForm.objectives.splice(index, 1); taskForm.objectives.splice(index, 1)
} }
async function handleMaterialChange(slotKey, file) { async function handleMaterialChange(slotKey, file) {
const rawFile = file?.raw; const rawFile = file?.raw
if (!rawFile) return; if (!rawFile) return
const data = new FormData(); const data = new FormData()
data.append("file", rawFile); data.append("file", rawFile)
uploadingField.value = slotKey; uploadingField.value = slotKey
try { try {
const res = await uploadTrainingTaskMaterial(data); const res = await uploadTrainingTaskMaterial(data)
taskForm[`${slotKey}Name`] = res?.originalFilename || rawFile.name || file?.name || taskForm[`${slotKey}Name`]; taskForm[`${slotKey}Name`] = res?.originalFilename || rawFile.name || file?.name || taskForm[`${slotKey}Name`]
taskForm[`${slotKey}Url`] = normalizeMaterialUrl(res?.url || res?.fileName || ""); taskForm[`${slotKey}Url`] = normalizeMaterialUrl(res?.url || res?.fileName || "")
proxy?.$modal?.msgSuccess(`${materialLabel(slotKey)}上传成功`); proxy?.$modal?.msgSuccess(`${materialLabel(slotKey)}上传成功`)
} catch (error) { } catch (error) {
proxy?.$modal?.msgError?.(`${materialLabel(slotKey)}上传失败`); proxy?.$modal?.msgError?.(`${materialLabel(slotKey)}上传失败`)
} finally { } finally {
uploadingField.value = ""; uploadingField.value = ""
} }
} }
function clearMaterial(slotKey) { function clearMaterial(slotKey) {
taskForm[`${slotKey}Name`] = ""; taskForm[`${slotKey}Name`] = ""
taskForm[`${slotKey}Url`] = ""; taskForm[`${slotKey}Url`] = ""
} }
async function submitTask() { async function submitTask() {
if (!selectedTeachingClass.value || !taskForm.taskKey) { if (!selectedTeachingClass.value || !taskForm.taskKey) {
proxy?.$modal?.msgError?.("请选择教学班后再保存"); proxy?.$modal?.msgError?.("请选择教学班后再保存")
return; return
} }
saving.value = true; saving.value = true
try { try {
await saveClassTrainingTask(selectedTeachingClassId.value, taskForm.taskKey, buildPayload()); await saveClassTrainingTask(selectedTeachingClassId.value, taskForm.taskKey, buildPayload())
dialogVisible.value = false; dialogVisible.value = false
proxy?.$modal?.msgSuccess("保存成功"); proxy?.$modal?.msgSuccess("保存成功")
await queryTasks(); await queryTasks()
} finally { } finally {
saving.value = false; saving.value = false
} }
} }
async function restoreTaskDefault() { async function restoreTaskDefault() {
if (!selectedTeachingClass.value || !taskForm.taskKey) return; if (!selectedTeachingClass.value || !taskForm.taskKey) return
const confirmed = await confirmRestoreDefault("恢复此任务默认内容"); const confirmed = await confirmRestoreDefault("恢复此任务默认内容")
if (!confirmed) return; if (!confirmed) return
restoring.value = true; restoring.value = true
try { try {
await restoreClassTrainingTaskDefault(selectedTeachingClassId.value, taskForm.taskKey); await restoreClassTrainingTaskDefault(selectedTeachingClassId.value, taskForm.taskKey)
dialogVisible.value = false; dialogVisible.value = false
proxy?.$modal?.msgSuccess("已恢复此任务的默认内容"); proxy?.$modal?.msgSuccess("已恢复此任务的默认内容")
await queryTasks(); await queryTasks()
} finally { } finally {
restoring.value = false; restoring.value = false
} }
} }
async function restoreAllTasksDefaults() { async function restoreAllTasksDefaults() {
if (!selectedTeachingClass.value) return; if (!selectedTeachingClass.value) return
const confirmed = await confirmRestoreDefault("恢复本班全部默认任务"); const confirmed = await confirmRestoreDefault("恢复本班全部默认任务")
if (!confirmed) return; if (!confirmed) return
restoring.value = true; restoring.value = true
try { try {
await restoreClassTrainingTasksDefaults(selectedTeachingClassId.value); await restoreClassTrainingTasksDefaults(selectedTeachingClassId.value)
proxy?.$modal?.msgSuccess("已恢复本班全部默认任务"); proxy?.$modal?.msgSuccess("已恢复本班全部默认任务")
await queryTasks(); await queryTasks()
} finally { } finally {
restoring.value = false; restoring.value = false
} }
} }
async function openStudentDemo() { async function openStudentDemo() {
if (!selectedTeachingClass.value) return; if (!selectedTeachingClass.value) return
// 项目使用 hash 路由;显式带上 hash,避免新窗口先落到默认的教师首页。 // 项目使用 hash 路由;显式带上 hash,避免新窗口先落到默认的教师首页。
const child = window.open("/#/student-demo", "_blank"); const child = window.open("/#/student-demo", "_blank")
if (!child) { if (!child) {
proxy?.$modal?.msgError?.("浏览器拦截了演示窗口,请允许弹窗后重试"); proxy?.$modal?.msgError?.("浏览器拦截了演示窗口,请允许弹窗后重试")
return; return
} }
let ticket = ""; let ticket = ""
let childReady = false; let childReady = false
const cleanup = () => window.removeEventListener("message", listener); const cleanup = () => window.removeEventListener("message", listener)
const sendTicket = () => { const sendTicket = () => {
if (!childReady || !ticket) return; if (!childReady || !ticket) return
child.postMessage({ type: "STUDENT_DEMO_TICKET", ticket }, window.location.origin); child.postMessage({ type: "STUDENT_DEMO_TICKET", ticket }, window.location.origin)
cleanup(); cleanup()
}; }
const listener = (event) => { const listener = (event) => {
if (event.origin !== window.location.origin || event.source !== child || event.data?.type !== "STUDENT_DEMO_READY") return; if (event.origin !== window.location.origin || event.source !== child || event.data?.type !== "STUDENT_DEMO_READY") return
childReady = true; childReady = true
sendTicket(); sendTicket()
}; }
window.addEventListener("message", listener); window.addEventListener("message", listener)
const timeout = window.setTimeout(cleanup, 60 * 1000); const timeout = window.setTimeout(cleanup, 60 * 1000)
try { try {
const res = await createStudentDemoSession(selectedTeachingClassId.value); const res = await createStudentDemoSession(selectedTeachingClassId.value)
ticket = res?.data?.ticket || ""; ticket = res?.data?.ticket || ""
if (!ticket) throw new Error("missing demo ticket"); if (!ticket) throw new Error("missing demo ticket")
sendTicket(); sendTicket()
} catch (error) { } catch (error) {
window.clearTimeout(timeout); window.clearTimeout(timeout)
cleanup(); cleanup()
child.close(); child.close()
proxy?.$modal?.msgError?.("无法创建学生端讲解会话"); proxy?.$modal?.msgError?.("无法创建学生端讲解会话")
} }
} }
async function confirmRestoreDefault(action) { async function confirmRestoreDefault(action) {
try { try {
await proxy?.$modal?.confirm(`确认${action}吗?仅恢复当前教学班的实训任务内容,不影响学生已提交数据、成绩、进度及其他班级。`, "确认恢复默认内容"); await proxy?.$modal?.confirm(`确认${action}吗?仅恢复当前教学班的实训任务内容,不影响学生已提交数据、成绩、进度及其他班级。`, "确认恢复默认内容")
return true; return true
} catch (error) { } catch (error) {
return false; return false
} }
} }
@ -829,7 +871,7 @@ function buildPayload() {
stepOneQuestions: JSON.stringify(taskForm.stepOneQuestions || []), stepOneQuestions: JSON.stringify(taskForm.stepOneQuestions || []),
sort: taskForm.sort, sort: taskForm.sort,
enabled: taskForm.enabled, enabled: taskForm.enabled,
}; }
} }
</script> </script>
@ -1297,7 +1339,7 @@ function buildPayload() {
border: 1px solid var(--border-color); border: 1px solid var(--border-color);
border-radius: var(--r-control); border-radius: var(--r-control);
> svg { >svg {
flex-shrink: 0; flex-shrink: 0;
color: var(--edu-primary); color: var(--edu-primary);
} }
@ -1483,7 +1525,7 @@ function buildPayload() {
gap: var(--sp-2); gap: var(--sp-2);
min-width: 0; min-width: 0;
> svg { >svg {
flex-shrink: 0; flex-shrink: 0;
color: var(--edu-primary); color: var(--edu-primary);
} }
@ -1645,3 +1687,4 @@ function buildPayload() {
} }
} }
</style> </style>

Loading…
Cancel
Save