|
|
|
|
@ -21,7 +21,9 @@
|
|
|
|
|
<div class="header-content">
|
|
|
|
|
<div class="header-icon">
|
|
|
|
|
<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="#00aaff" 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="#00aaff" stroke-width="1.5" stroke-linecap="round" />
|
|
|
|
|
<path d="M9 12h6M9 16h6" stroke="#00aaff" stroke-width="1.5" stroke-linecap="round" />
|
|
|
|
|
</svg>
|
|
|
|
|
</div>
|
|
|
|
|
@ -47,25 +49,30 @@
|
|
|
|
|
<div class="toolbar-left">
|
|
|
|
|
<div class="class-filter">
|
|
|
|
|
<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" />
|
|
|
|
|
<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" />
|
|
|
|
|
</svg>
|
|
|
|
|
教学班
|
|
|
|
|
</span>
|
|
|
|
|
<el-select v-model="selectedTeachingClassId" :loading="classesLoading" placeholder="请选择教学班" class="class-select" @change="queryTasks">
|
|
|
|
|
<el-option v-for="schoolClass in teachingClassList" :key="schoolClass.schoolClassId" :label="schoolClass.className" :value="schoolClass.schoolClassId" />
|
|
|
|
|
<el-select v-model="selectedTeachingClassId" :loading="classesLoading" placeholder="请选择教学班"
|
|
|
|
|
class="class-select" @change="queryTasks">
|
|
|
|
|
<el-option v-for="schoolClass in teachingClassList" :key="schoolClass.schoolClassId"
|
|
|
|
|
:label="schoolClass.className" :value="schoolClass.schoolClassId" />
|
|
|
|
|
</el-select>
|
|
|
|
|
</div>
|
|
|
|
|
<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" />
|
|
|
|
|
<path d="M21 21l-4.35-4.35" />
|
|
|
|
|
</svg>
|
|
|
|
|
<el-input v-model.trim="keyword" clearable placeholder="搜索任务名称..." @keyup.enter="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" />
|
|
|
|
|
<path d="M21 21l-4.35-4.35" />
|
|
|
|
|
</svg>
|
|
|
|
|
@ -76,26 +83,30 @@
|
|
|
|
|
<div class="toolbar-right">
|
|
|
|
|
<div class="status-indicator">
|
|
|
|
|
<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" />
|
|
|
|
|
</svg>
|
|
|
|
|
班级配置模式
|
|
|
|
|
</el-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" />
|
|
|
|
|
</svg>
|
|
|
|
|
默认任务
|
|
|
|
|
</el-tag>
|
|
|
|
|
</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">
|
|
|
|
|
<path d="M3 12a9 9 0 109-9 9.75 9.75 0 00-6.74 2.74L3 8" />
|
|
|
|
|
<path d="M3 3v5h5" />
|
|
|
|
|
</svg>
|
|
|
|
|
恢复默认
|
|
|
|
|
</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">
|
|
|
|
|
<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" />
|
|
|
|
|
@ -118,7 +129,9 @@
|
|
|
|
|
<span class="tab-name">全部</span>
|
|
|
|
|
<span class="tab-count">{{ tasks.length }}</span>
|
|
|
|
|
</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-count">{{ project.count }}</span>
|
|
|
|
|
</button>
|
|
|
|
|
@ -133,7 +146,8 @@
|
|
|
|
|
|
|
|
|
|
<!-- 任务卡片网格 -->
|
|
|
|
|
<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">
|
|
|
|
|
<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" />
|
|
|
|
|
@ -154,7 +168,8 @@
|
|
|
|
|
<div class="card-content">
|
|
|
|
|
<div class="card-header">
|
|
|
|
|
<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" />
|
|
|
|
|
</svg>
|
|
|
|
|
{{ task.project || "默认实训任务" }}
|
|
|
|
|
@ -168,14 +183,16 @@
|
|
|
|
|
|
|
|
|
|
<div class="task-meta">
|
|
|
|
|
<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="M21 12v7a2 2 0 01-2 2H5a2 2 0 01-2-2V5a2 2 0 012-2h11" />
|
|
|
|
|
</svg>
|
|
|
|
|
{{ task.objectives?.length || 0 }} 个目标
|
|
|
|
|
</span>
|
|
|
|
|
<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" />
|
|
|
|
|
<polyline points="14 2 14 8 20 8" />
|
|
|
|
|
</svg>
|
|
|
|
|
@ -186,7 +203,8 @@
|
|
|
|
|
|
|
|
|
|
<div class="card-actions" @click.stop>
|
|
|
|
|
<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="M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z" />
|
|
|
|
|
</svg>
|
|
|
|
|
@ -199,7 +217,8 @@
|
|
|
|
|
</article>
|
|
|
|
|
<el-empty v-if="!filteredTasks.length && !loading" class="task-empty" description="暂无匹配的实训任务">
|
|
|
|
|
<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" />
|
|
|
|
|
<rect x="9" y="3" width="6" height="4" rx="1" />
|
|
|
|
|
</svg>
|
|
|
|
|
@ -208,12 +227,14 @@
|
|
|
|
|
</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">
|
|
|
|
|
<header class="drawer-header">
|
|
|
|
|
<div class="drawer-heading">
|
|
|
|
|
<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" />
|
|
|
|
|
<path d="M12 8v4l3 3" />
|
|
|
|
|
</svg>
|
|
|
|
|
@ -223,7 +244,8 @@
|
|
|
|
|
<p>维护教学班实训任务配置,包括任务名称、说明、目标、要求和步骤等内容</p>
|
|
|
|
|
</div>
|
|
|
|
|
<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="6" y1="6" x2="18" y2="18" />
|
|
|
|
|
</svg>
|
|
|
|
|
@ -232,7 +254,8 @@
|
|
|
|
|
|
|
|
|
|
<div class="drawer-identity">
|
|
|
|
|
<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" />
|
|
|
|
|
</svg>
|
|
|
|
|
<div class="identity-content">
|
|
|
|
|
@ -241,7 +264,8 @@
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<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" />
|
|
|
|
|
<rect x="9" y="3" width="6" height="4" rx="1" />
|
|
|
|
|
</svg>
|
|
|
|
|
@ -251,7 +275,8 @@
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<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" />
|
|
|
|
|
<polyline points="22 4 12 14.01 9 11.01" />
|
|
|
|
|
</svg>
|
|
|
|
|
@ -291,18 +316,23 @@
|
|
|
|
|
</div>
|
|
|
|
|
<el-form-item label="实训目标:">
|
|
|
|
|
<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>
|
|
|
|
|
<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)">
|
|
|
|
|
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
|
|
|
<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">
|
|
|
|
|
<line x1="18" y1="6" x2="6" y2="18" />
|
|
|
|
|
<line x1="6" y1="6" x2="18" y2="18" />
|
|
|
|
|
</svg>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
<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">
|
|
|
|
|
<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">
|
|
|
|
|
<line x1="12" y1="5" x2="12" y2="19" />
|
|
|
|
|
<line x1="5" y1="12" x2="19" y2="12" />
|
|
|
|
|
</svg>
|
|
|
|
|
@ -326,18 +356,22 @@
|
|
|
|
|
</div>
|
|
|
|
|
<div class="material-row">
|
|
|
|
|
<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" />
|
|
|
|
|
<polyline points="14 2 14 8 20 8" />
|
|
|
|
|
</svg>
|
|
|
|
|
<div class="material-text">
|
|
|
|
|
<span v-if="hasTaskMaterial" class="material-link">{{ taskForm.materialName }}</span>
|
|
|
|
|
<span v-if="hasTaskMaterial" class="material-link">{{ taskForm.materialName
|
|
|
|
|
}}</span>
|
|
|
|
|
<span v-else class="material-placeholder">暂未上传案例资料</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<el-upload v-if="!isReadonly" action="#" :auto-upload="false" :show-file-list="false" :on-change="handleMaterialChange">
|
|
|
|
|
<el-upload v-if="!isReadonly" action="#" :auto-upload="false" :show-file-list="false"
|
|
|
|
|
:on-change="handleMaterialChange">
|
|
|
|
|
<el-button type="primary" :loading="materialUploading" 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" />
|
|
|
|
|
<polyline points="17 8 12 3 7 8" />
|
|
|
|
|
<line x1="12" y1="3" x2="12" y2="15" />
|
|
|
|
|
@ -352,22 +386,27 @@
|
|
|
|
|
<div v-for="(step, index) in taskForm.steps" :key="step.id" class="step-item">
|
|
|
|
|
<div class="step-connector" v-if="index > 0">
|
|
|
|
|
<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>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="step-content">
|
|
|
|
|
<span class="step-number">{{ index + 1 }}</span>
|
|
|
|
|
<el-input v-model="step.name" placeholder="步骤名称" />
|
|
|
|
|
<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">
|
|
|
|
|
<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">
|
|
|
|
|
<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>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<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="5" y1="12" x2="19" y2="12" />
|
|
|
|
|
</svg>
|
|
|
|
|
@ -382,15 +421,18 @@
|
|
|
|
|
<el-button class="cancel-btn" @click="dialogVisible = false">
|
|
|
|
|
{{ isReadonly ? "关闭" : "取消" }}
|
|
|
|
|
</el-button>
|
|
|
|
|
<el-button v-if="!isReadonly" type="danger" plain class="toolbar-btn toolbar-btn-danger" :loading="restoring" @click="restoreTaskDefault">
|
|
|
|
|
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
|
|
|
<el-button v-if="!isReadonly" type="danger" plain class="toolbar-btn toolbar-btn-danger"
|
|
|
|
|
: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 3v5h5" />
|
|
|
|
|
</svg>
|
|
|
|
|
恢复默认
|
|
|
|
|
</el-button>
|
|
|
|
|
<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" />
|
|
|
|
|
<polyline points="17 21 17 13 7 13 7 21" />
|
|
|
|
|
<polyline points="7 3 7 8 15 8" />
|
|
|
|
|
@ -404,154 +446,154 @@
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
import { listTrainingTasks, listClassTrainingTasks, saveClassTrainingTask, restoreClassTrainingTaskDefault, restoreClassTrainingTasksDefaults, uploadTrainingTaskMaterial } from "@/api/trainingTask";
|
|
|
|
|
import { createStudentDemoSession } from "@/api/studentDemo";
|
|
|
|
|
import * as indexApi from "@/api/teacher";
|
|
|
|
|
import useUserStore from "@/store/modules/user";
|
|
|
|
|
|
|
|
|
|
const { proxy } = getCurrentInstance();
|
|
|
|
|
const userStore = useUserStore();
|
|
|
|
|
|
|
|
|
|
const activeProject = ref("");
|
|
|
|
|
const keyword = ref("");
|
|
|
|
|
const loading = ref(false);
|
|
|
|
|
const classesLoading = ref(false);
|
|
|
|
|
const saving = ref(false);
|
|
|
|
|
const restoring = ref(false);
|
|
|
|
|
const materialUploading = ref(false);
|
|
|
|
|
const tasks = ref([]);
|
|
|
|
|
const classList = ref([]);
|
|
|
|
|
const selectedTeachingClassId = ref("");
|
|
|
|
|
const dialogVisible = ref(false);
|
|
|
|
|
const dialogMode = ref("view");
|
|
|
|
|
const taskForm = reactive(createEmptyTask());
|
|
|
|
|
const currentUserId = computed(() => userStore.userInfo.userId);
|
|
|
|
|
const isReadonly = computed(() => dialogMode.value === "view");
|
|
|
|
|
const hasTaskMaterial = computed(() => isRealMaterial(taskForm.materialName, taskForm.materialUrl));
|
|
|
|
|
const projects = computed(() => [...new Set(tasks.value.map((task) => task.project).filter(Boolean))]);
|
|
|
|
|
import { listTrainingTasks, listClassTrainingTasks, saveClassTrainingTask, restoreClassTrainingTaskDefault, restoreClassTrainingTasksDefaults, uploadTrainingTaskMaterial } from "@/api/trainingTask"
|
|
|
|
|
import { createStudentDemoSession } from "@/api/studentDemo"
|
|
|
|
|
import * as indexApi from "@/api/teacher"
|
|
|
|
|
import useUserStore from "@/store/modules/user"
|
|
|
|
|
|
|
|
|
|
const { proxy } = getCurrentInstance()
|
|
|
|
|
const userStore = useUserStore()
|
|
|
|
|
|
|
|
|
|
const activeProject = ref("")
|
|
|
|
|
const keyword = ref("")
|
|
|
|
|
const loading = ref(false)
|
|
|
|
|
const classesLoading = ref(false)
|
|
|
|
|
const saving = ref(false)
|
|
|
|
|
const restoring = ref(false)
|
|
|
|
|
const materialUploading = ref(false)
|
|
|
|
|
const tasks = ref([])
|
|
|
|
|
const classList = ref([])
|
|
|
|
|
const selectedTeachingClassId = ref("")
|
|
|
|
|
const dialogVisible = ref(false)
|
|
|
|
|
const dialogMode = ref("view")
|
|
|
|
|
const taskForm = reactive(createEmptyTask())
|
|
|
|
|
const currentUserId = computed(() => userStore.userInfo.userId)
|
|
|
|
|
const isReadonly = computed(() => dialogMode.value === "view")
|
|
|
|
|
const hasTaskMaterial = computed(() => isRealMaterial(taskForm.materialName, taskForm.materialUrl))
|
|
|
|
|
const projects = computed(() => [...new Set(tasks.value.map((task) => task.project).filter(Boolean))])
|
|
|
|
|
const projectOptions = computed(() => {
|
|
|
|
|
return projects.value.map((project) => ({
|
|
|
|
|
name: project,
|
|
|
|
|
count: tasks.value.filter((task) => task.project === project).length,
|
|
|
|
|
}));
|
|
|
|
|
});
|
|
|
|
|
}))
|
|
|
|
|
})
|
|
|
|
|
const teachingClassList = computed(() => {
|
|
|
|
|
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(() => {
|
|
|
|
|
return teachingClassList.value.find((schoolClass) => schoolClass.schoolClassId === selectedTeachingClassId.value);
|
|
|
|
|
});
|
|
|
|
|
return teachingClassList.value.find((schoolClass) => schoolClass.schoolClassId === selectedTeachingClassId.value)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const filteredTasks = computed(() => {
|
|
|
|
|
const text = keyword.value.trim();
|
|
|
|
|
const text = keyword.value.trim()
|
|
|
|
|
return tasks.value.filter((task) => {
|
|
|
|
|
const matchProject = !activeProject.value || task.project === activeProject.value;
|
|
|
|
|
const matchKeyword = !text || task.title.includes(text);
|
|
|
|
|
return matchProject && matchKeyword;
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
const matchProject = !activeProject.value || task.project === activeProject.value
|
|
|
|
|
const matchKeyword = !text || task.title.includes(text)
|
|
|
|
|
return matchProject && matchKeyword
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
setTrainingTaskMainTheme(true);
|
|
|
|
|
loadTeachingClasses();
|
|
|
|
|
});
|
|
|
|
|
setTrainingTaskMainTheme(true)
|
|
|
|
|
loadTeachingClasses()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
onActivated(() => {
|
|
|
|
|
setTrainingTaskMainTheme(true);
|
|
|
|
|
});
|
|
|
|
|
setTrainingTaskMainTheme(true)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
onDeactivated(() => {
|
|
|
|
|
setTrainingTaskMainTheme(false);
|
|
|
|
|
});
|
|
|
|
|
setTrainingTaskMainTheme(false)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
onBeforeUnmount(() => {
|
|
|
|
|
setTrainingTaskMainTheme(false);
|
|
|
|
|
});
|
|
|
|
|
setTrainingTaskMainTheme(false)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
function setTrainingTaskMainTheme(enabled) {
|
|
|
|
|
const main = document.querySelector(".teacher-main");
|
|
|
|
|
if (!main) return;
|
|
|
|
|
main.classList.toggle("training-task-main-theme", enabled);
|
|
|
|
|
const main = document.querySelector(".teacher-main")
|
|
|
|
|
if (!main) return
|
|
|
|
|
main.classList.toggle("training-task-main-theme", enabled)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function toggleProject(project) {
|
|
|
|
|
activeProject.value = activeProject.value === project ? "" : project;
|
|
|
|
|
activeProject.value = activeProject.value === project ? "" : project
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function queryTasks() {
|
|
|
|
|
if (!selectedTeachingClassId.value) {
|
|
|
|
|
await queryDefaultTasks();
|
|
|
|
|
return;
|
|
|
|
|
await queryDefaultTasks()
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
loading.value = true;
|
|
|
|
|
loading.value = true
|
|
|
|
|
try {
|
|
|
|
|
const res = await listClassTrainingTasks(selectedTeachingClassId.value, { enabledOnly: false });
|
|
|
|
|
tasks.value = (res.data || []).map(normalizeTask);
|
|
|
|
|
resetInvalidProject();
|
|
|
|
|
const res = await listClassTrainingTasks(selectedTeachingClassId.value, { enabledOnly: false })
|
|
|
|
|
tasks.value = (res.data || []).map(normalizeTask)
|
|
|
|
|
resetInvalidProject()
|
|
|
|
|
} catch (error) {
|
|
|
|
|
await queryDefaultTasks();
|
|
|
|
|
proxy?.$modal?.msgWarning?.("班级任务加载失败,已显示系统默认任务");
|
|
|
|
|
await queryDefaultTasks()
|
|
|
|
|
proxy?.$modal?.msgWarning?.("班级任务加载失败,已显示系统默认任务")
|
|
|
|
|
} finally {
|
|
|
|
|
loading.value = false;
|
|
|
|
|
loading.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function queryDefaultTasks() {
|
|
|
|
|
loading.value = true;
|
|
|
|
|
loading.value = true
|
|
|
|
|
try {
|
|
|
|
|
const res = await listTrainingTasks({ enabledOnly: false });
|
|
|
|
|
tasks.value = (res.data || []).map(normalizeTask);
|
|
|
|
|
resetInvalidProject();
|
|
|
|
|
const res = await listTrainingTasks({ enabledOnly: false })
|
|
|
|
|
tasks.value = (res.data || []).map(normalizeTask)
|
|
|
|
|
resetInvalidProject()
|
|
|
|
|
} catch (error) {
|
|
|
|
|
tasks.value = [];
|
|
|
|
|
tasks.value = []
|
|
|
|
|
} finally {
|
|
|
|
|
loading.value = false;
|
|
|
|
|
loading.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function resetInvalidProject() {
|
|
|
|
|
if (activeProject.value && !projects.value.includes(activeProject.value)) {
|
|
|
|
|
activeProject.value = "";
|
|
|
|
|
activeProject.value = ""
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function loadTeachingClasses() {
|
|
|
|
|
classesLoading.value = true;
|
|
|
|
|
classesLoading.value = true
|
|
|
|
|
try {
|
|
|
|
|
const res = await indexApi.getClassListBySchoolId({ schoolId: userStore.userInfo.schoolId });
|
|
|
|
|
classList.value = res.data || [];
|
|
|
|
|
selectedTeachingClassId.value = teachingClassList.value[0]?.schoolClassId || "";
|
|
|
|
|
await queryTasks();
|
|
|
|
|
const res = await indexApi.getClassListBySchoolId({ schoolId: userStore.userInfo.schoolId })
|
|
|
|
|
classList.value = res.data || []
|
|
|
|
|
selectedTeachingClassId.value = teachingClassList.value[0]?.schoolClassId || ""
|
|
|
|
|
await queryTasks()
|
|
|
|
|
} catch (error) {
|
|
|
|
|
classList.value = [];
|
|
|
|
|
selectedTeachingClassId.value = "";
|
|
|
|
|
await queryDefaultTasks();
|
|
|
|
|
classList.value = []
|
|
|
|
|
selectedTeachingClassId.value = ""
|
|
|
|
|
await queryDefaultTasks()
|
|
|
|
|
} finally {
|
|
|
|
|
classesLoading.value = false;
|
|
|
|
|
classesLoading.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function normalizeClassType(schoolClass) {
|
|
|
|
|
if (schoolClass?.classType) return schoolClass.classType;
|
|
|
|
|
return schoolClass?.createdBy ? "TEACHING" : "ADMIN";
|
|
|
|
|
if (schoolClass?.classType) return schoolClass.classType
|
|
|
|
|
return schoolClass?.createdBy ? "TEACHING" : "ADMIN"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function viewTask(task) {
|
|
|
|
|
openTaskDialog(task, "view");
|
|
|
|
|
openTaskDialog(task, "view")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function editTask(task) {
|
|
|
|
|
openTaskDialog(task, "edit");
|
|
|
|
|
openTaskDialog(task, "edit")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function handleTaskAction(task) {
|
|
|
|
|
if (!selectedTeachingClass.value) {
|
|
|
|
|
viewTask(task);
|
|
|
|
|
return;
|
|
|
|
|
viewTask(task)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
editTask(task);
|
|
|
|
|
editTask(task)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function createEmptyTask() {
|
|
|
|
|
@ -568,11 +610,11 @@ function createEmptyTask() {
|
|
|
|
|
steps: createBuiltinSteps(),
|
|
|
|
|
sort: 0,
|
|
|
|
|
enabled: true,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function normalizeTask(task) {
|
|
|
|
|
const material = normalizeMaterial(task.materialName, task.materialUrl);
|
|
|
|
|
const material = normalizeMaterial(task.materialName, task.materialUrl)
|
|
|
|
|
return {
|
|
|
|
|
id: task.id,
|
|
|
|
|
taskKey: task.taskKey,
|
|
|
|
|
@ -586,72 +628,72 @@ function normalizeTask(task) {
|
|
|
|
|
steps: normalizeSteps(parseArray(task.steps, createBuiltinSteps())),
|
|
|
|
|
sort: task.sort || 0,
|
|
|
|
|
enabled: task.enabled !== false,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function normalizeMaterial(materialName, materialUrl) {
|
|
|
|
|
const name = String(materialName || "").trim();
|
|
|
|
|
const url = normalizeMaterialUrl(materialUrl);
|
|
|
|
|
return isRealMaterial(name, url) ? { name, url } : { name: "", url: "" };
|
|
|
|
|
const name = String(materialName || "").trim()
|
|
|
|
|
const url = normalizeMaterialUrl(materialUrl)
|
|
|
|
|
return isRealMaterial(name, url) ? { name, url } : { name: "", url: "" }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function isRealMaterial(materialName, materialUrl) {
|
|
|
|
|
const name = String(materialName || "").trim();
|
|
|
|
|
const url = String(materialUrl || "").trim();
|
|
|
|
|
return Boolean(name && url) && !(name === "案例资料.rar" && url === "/file/example.rar");
|
|
|
|
|
const name = String(materialName || "").trim()
|
|
|
|
|
const url = String(materialUrl || "").trim()
|
|
|
|
|
return Boolean(name && url) && !(name === "案例资料.rar" && url === "/file/example.rar")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function normalizeMaterialUrl(rawUrl) {
|
|
|
|
|
const url = String(rawUrl || "").trim();
|
|
|
|
|
const url = String(rawUrl || "").trim()
|
|
|
|
|
if (!url) {
|
|
|
|
|
return "";
|
|
|
|
|
return ""
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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/")) {
|
|
|
|
|
return `${parsed.pathname}${parsed.search}${parsed.hash}`;
|
|
|
|
|
return `${parsed.pathname}${parsed.search}${parsed.hash}`
|
|
|
|
|
}
|
|
|
|
|
} catch {
|
|
|
|
|
// 相对地址无需转换。
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return url;
|
|
|
|
|
return url
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function parseArray(value, fallback) {
|
|
|
|
|
if (Array.isArray(value)) {
|
|
|
|
|
return value.length ? value : fallback;
|
|
|
|
|
return value.length ? value : fallback
|
|
|
|
|
}
|
|
|
|
|
if (!value) {
|
|
|
|
|
return fallback;
|
|
|
|
|
return fallback
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
const parsed = JSON.parse(value);
|
|
|
|
|
return Array.isArray(parsed) && parsed.length ? parsed : fallback;
|
|
|
|
|
const parsed = JSON.parse(value)
|
|
|
|
|
return Array.isArray(parsed) && parsed.length ? parsed : fallback
|
|
|
|
|
} catch (error) {
|
|
|
|
|
return String(value)
|
|
|
|
|
.split(/[;;||]/)
|
|
|
|
|
.map((item) => item.trim())
|
|
|
|
|
.filter(Boolean);
|
|
|
|
|
.filter(Boolean)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function normalizeSteps(steps) {
|
|
|
|
|
const source = Array.isArray(steps) ? steps : [];
|
|
|
|
|
const source = Array.isArray(steps) ? steps : []
|
|
|
|
|
const result = source
|
|
|
|
|
.map((item, index) => {
|
|
|
|
|
const raw = item && typeof item === "object" ? item : {};
|
|
|
|
|
const name = typeof item === "object" ? String(raw.name || "").trim() : String(item || "").trim();
|
|
|
|
|
const kind = raw.kind === "custom" ? "custom" : index < 4 ? "builtin" : "custom";
|
|
|
|
|
return createStep(name, kind, raw.id);
|
|
|
|
|
const raw = item && typeof item === "object" ? item : {}
|
|
|
|
|
const name = typeof item === "object" ? String(raw.name || "").trim() : String(item || "").trim()
|
|
|
|
|
const kind = raw.kind === "custom" ? "custom" : index < 4 ? "builtin" : "custom"
|
|
|
|
|
return createStep(name, kind, raw.id)
|
|
|
|
|
})
|
|
|
|
|
.filter((item) => item.name);
|
|
|
|
|
return result.length ? result : [createStep()];
|
|
|
|
|
.filter((item) => item.name)
|
|
|
|
|
return result.length ? result : [createStep()]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 = "") {
|
|
|
|
|
@ -659,13 +701,13 @@ function createStep(name = "", kind = "custom", id = "") {
|
|
|
|
|
id: id || `custom-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
|
|
|
|
|
name,
|
|
|
|
|
kind,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function openTaskDialog(task, mode) {
|
|
|
|
|
dialogMode.value = mode;
|
|
|
|
|
Object.assign(taskForm, cloneTask(task));
|
|
|
|
|
dialogVisible.value = true;
|
|
|
|
|
dialogMode.value = mode
|
|
|
|
|
Object.assign(taskForm, cloneTask(task))
|
|
|
|
|
dialogVisible.value = true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function cloneTask(task) {
|
|
|
|
|
@ -673,131 +715,131 @@ function cloneTask(task) {
|
|
|
|
|
...task,
|
|
|
|
|
objectives: [...(task.objectives?.length ? task.objectives : [""])],
|
|
|
|
|
steps: normalizeSteps(task.steps?.length ? task.steps : createBuiltinSteps()),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function addObjective() {
|
|
|
|
|
taskForm.objectives.push("");
|
|
|
|
|
taskForm.objectives.push("")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function removeObjective(index) {
|
|
|
|
|
if (taskForm.objectives.length <= 1) return;
|
|
|
|
|
taskForm.objectives.splice(index, 1);
|
|
|
|
|
if (taskForm.objectives.length <= 1) return
|
|
|
|
|
taskForm.objectives.splice(index, 1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function addStep() {
|
|
|
|
|
taskForm.steps.push(createStep());
|
|
|
|
|
taskForm.steps.push(createStep())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function removeStep(index) {
|
|
|
|
|
if (taskForm.steps.length <= 1) return;
|
|
|
|
|
taskForm.steps.splice(index, 1);
|
|
|
|
|
if (taskForm.steps.length <= 1) return
|
|
|
|
|
taskForm.steps.splice(index, 1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function handleMaterialChange(file) {
|
|
|
|
|
const rawFile = file?.raw;
|
|
|
|
|
if (!rawFile) return;
|
|
|
|
|
const data = new FormData();
|
|
|
|
|
data.append("file", rawFile);
|
|
|
|
|
materialUploading.value = true;
|
|
|
|
|
const rawFile = file?.raw
|
|
|
|
|
if (!rawFile) return
|
|
|
|
|
const data = new FormData()
|
|
|
|
|
data.append("file", rawFile)
|
|
|
|
|
materialUploading.value = true
|
|
|
|
|
try {
|
|
|
|
|
const res = await uploadTrainingTaskMaterial(data);
|
|
|
|
|
taskForm.materialName = res?.originalFilename || rawFile.name || file?.name || taskForm.materialName;
|
|
|
|
|
taskForm.materialUrl = normalizeMaterialUrl(res?.url || res?.fileName || "");
|
|
|
|
|
proxy?.$modal?.msgSuccess("案例资料上传成功");
|
|
|
|
|
const res = await uploadTrainingTaskMaterial(data)
|
|
|
|
|
taskForm.materialName = res?.originalFilename || rawFile.name || file?.name || taskForm.materialName
|
|
|
|
|
taskForm.materialUrl = normalizeMaterialUrl(res?.url || res?.fileName || "")
|
|
|
|
|
proxy?.$modal?.msgSuccess("案例资料上传成功")
|
|
|
|
|
} catch (error) {
|
|
|
|
|
proxy?.$modal?.msgError?.("案例资料上传失败");
|
|
|
|
|
proxy?.$modal?.msgError?.("案例资料上传失败")
|
|
|
|
|
} finally {
|
|
|
|
|
materialUploading.value = false;
|
|
|
|
|
materialUploading.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function submitTask() {
|
|
|
|
|
if (!selectedTeachingClass.value || !taskForm.taskKey) {
|
|
|
|
|
proxy?.$modal?.msgError?.("请选择教学班后再保存");
|
|
|
|
|
return;
|
|
|
|
|
proxy?.$modal?.msgError?.("请选择教学班后再保存")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
saving.value = true;
|
|
|
|
|
saving.value = true
|
|
|
|
|
try {
|
|
|
|
|
await saveClassTrainingTask(selectedTeachingClassId.value, taskForm.taskKey, buildPayload());
|
|
|
|
|
dialogVisible.value = false;
|
|
|
|
|
proxy?.$modal?.msgSuccess("保存成功");
|
|
|
|
|
await queryTasks();
|
|
|
|
|
await saveClassTrainingTask(selectedTeachingClassId.value, taskForm.taskKey, buildPayload())
|
|
|
|
|
dialogVisible.value = false
|
|
|
|
|
proxy?.$modal?.msgSuccess("保存成功")
|
|
|
|
|
await queryTasks()
|
|
|
|
|
} finally {
|
|
|
|
|
saving.value = false;
|
|
|
|
|
saving.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function restoreTaskDefault() {
|
|
|
|
|
if (!selectedTeachingClass.value || !taskForm.taskKey) return;
|
|
|
|
|
const confirmed = await confirmRestoreDefault("恢复此任务默认内容");
|
|
|
|
|
if (!confirmed) return;
|
|
|
|
|
restoring.value = true;
|
|
|
|
|
if (!selectedTeachingClass.value || !taskForm.taskKey) return
|
|
|
|
|
const confirmed = await confirmRestoreDefault("恢复此任务默认内容")
|
|
|
|
|
if (!confirmed) return
|
|
|
|
|
restoring.value = true
|
|
|
|
|
try {
|
|
|
|
|
await restoreClassTrainingTaskDefault(selectedTeachingClassId.value, taskForm.taskKey);
|
|
|
|
|
dialogVisible.value = false;
|
|
|
|
|
proxy?.$modal?.msgSuccess("已恢复此任务的默认内容");
|
|
|
|
|
await queryTasks();
|
|
|
|
|
await restoreClassTrainingTaskDefault(selectedTeachingClassId.value, taskForm.taskKey)
|
|
|
|
|
dialogVisible.value = false
|
|
|
|
|
proxy?.$modal?.msgSuccess("已恢复此任务的默认内容")
|
|
|
|
|
await queryTasks()
|
|
|
|
|
} finally {
|
|
|
|
|
restoring.value = false;
|
|
|
|
|
restoring.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function restoreAllTasksDefaults() {
|
|
|
|
|
if (!selectedTeachingClass.value) return;
|
|
|
|
|
const confirmed = await confirmRestoreDefault("恢复本班全部默认任务");
|
|
|
|
|
if (!confirmed) return;
|
|
|
|
|
restoring.value = true;
|
|
|
|
|
if (!selectedTeachingClass.value) return
|
|
|
|
|
const confirmed = await confirmRestoreDefault("恢复本班全部默认任务")
|
|
|
|
|
if (!confirmed) return
|
|
|
|
|
restoring.value = true
|
|
|
|
|
try {
|
|
|
|
|
await restoreClassTrainingTasksDefaults(selectedTeachingClassId.value);
|
|
|
|
|
proxy?.$modal?.msgSuccess("已恢复本班全部默认任务");
|
|
|
|
|
await queryTasks();
|
|
|
|
|
await restoreClassTrainingTasksDefaults(selectedTeachingClassId.value)
|
|
|
|
|
proxy?.$modal?.msgSuccess("已恢复本班全部默认任务")
|
|
|
|
|
await queryTasks()
|
|
|
|
|
} finally {
|
|
|
|
|
restoring.value = false;
|
|
|
|
|
restoring.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function openStudentDemo() {
|
|
|
|
|
if (!selectedTeachingClass.value) return;
|
|
|
|
|
const child = window.open("/student-demo", "_blank");
|
|
|
|
|
if (!selectedTeachingClass.value) return
|
|
|
|
|
const child = window.open("/student-demo", "_blank")
|
|
|
|
|
if (!child) {
|
|
|
|
|
proxy?.$modal?.msgError?.("浏览器拦截了演示窗口,请允许弹窗后重试");
|
|
|
|
|
return;
|
|
|
|
|
proxy?.$modal?.msgError?.("浏览器拦截了演示窗口,请允许弹窗后重试")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
let ticket = "";
|
|
|
|
|
let childReady = false;
|
|
|
|
|
const cleanup = () => window.removeEventListener("message", listener);
|
|
|
|
|
let ticket = ""
|
|
|
|
|
let childReady = false
|
|
|
|
|
const cleanup = () => window.removeEventListener("message", listener)
|
|
|
|
|
const sendTicket = () => {
|
|
|
|
|
if (!childReady || !ticket) return;
|
|
|
|
|
child.postMessage({ type: "STUDENT_DEMO_TICKET", ticket }, window.location.origin);
|
|
|
|
|
cleanup();
|
|
|
|
|
};
|
|
|
|
|
if (!childReady || !ticket) return
|
|
|
|
|
child.postMessage({ type: "STUDENT_DEMO_TICKET", ticket }, window.location.origin)
|
|
|
|
|
cleanup()
|
|
|
|
|
}
|
|
|
|
|
const listener = (event) => {
|
|
|
|
|
if (event.origin !== window.location.origin || event.source !== child || event.data?.type !== "STUDENT_DEMO_READY") return;
|
|
|
|
|
childReady = true;
|
|
|
|
|
sendTicket();
|
|
|
|
|
};
|
|
|
|
|
window.addEventListener("message", listener);
|
|
|
|
|
const timeout = window.setTimeout(cleanup, 60 * 1000);
|
|
|
|
|
if (event.origin !== window.location.origin || event.source !== child || event.data?.type !== "STUDENT_DEMO_READY") return
|
|
|
|
|
childReady = true
|
|
|
|
|
sendTicket()
|
|
|
|
|
}
|
|
|
|
|
window.addEventListener("message", listener)
|
|
|
|
|
const timeout = window.setTimeout(cleanup, 60 * 1000)
|
|
|
|
|
try {
|
|
|
|
|
const res = await createStudentDemoSession(selectedTeachingClassId.value);
|
|
|
|
|
ticket = res?.data?.ticket || "";
|
|
|
|
|
if (!ticket) throw new Error("missing demo ticket");
|
|
|
|
|
sendTicket();
|
|
|
|
|
const res = await createStudentDemoSession(selectedTeachingClassId.value)
|
|
|
|
|
ticket = res?.data?.ticket || ""
|
|
|
|
|
if (!ticket) throw new Error("missing demo ticket")
|
|
|
|
|
sendTicket()
|
|
|
|
|
} catch (error) {
|
|
|
|
|
window.clearTimeout(timeout);
|
|
|
|
|
cleanup();
|
|
|
|
|
child.close();
|
|
|
|
|
proxy?.$modal?.msgError?.("无法创建学生端讲解会话");
|
|
|
|
|
window.clearTimeout(timeout)
|
|
|
|
|
cleanup()
|
|
|
|
|
child.close()
|
|
|
|
|
proxy?.$modal?.msgError?.("无法创建学生端讲解会话")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function confirmRestoreDefault(action) {
|
|
|
|
|
try {
|
|
|
|
|
await proxy?.$modal?.confirm(`确认${action}吗?仅恢复当前教学班的实训任务内容,不影响学生已提交数据、成绩、进度及其他班级。`, "确认恢复默认内容");
|
|
|
|
|
return true;
|
|
|
|
|
await proxy?.$modal?.confirm(`确认${action}吗?仅恢复当前教学班的实训任务内容,不影响学生已提交数据、成绩、进度及其他班级。`, "确认恢复默认内容")
|
|
|
|
|
return true
|
|
|
|
|
} catch (error) {
|
|
|
|
|
return false;
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -814,14 +856,14 @@ function buildPayload() {
|
|
|
|
|
materialUrl: taskForm.materialUrl,
|
|
|
|
|
sort: taskForm.sort,
|
|
|
|
|
enabled: taskForm.enabled,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.training-task-page {
|
|
|
|
|
min-height: calc(100vh - 96px);
|
|
|
|
|
margin: 22px 24px 28px;
|
|
|
|
|
// margin: 22px 24px 28px;
|
|
|
|
|
padding: 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -1176,14 +1218,17 @@ function buildPayload() {
|
|
|
|
|
top: 8px;
|
|
|
|
|
left: 8px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&.top-right {
|
|
|
|
|
top: 8px;
|
|
|
|
|
right: 8px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&.bottom-left {
|
|
|
|
|
bottom: 8px;
|
|
|
|
|
left: 8px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&.bottom-right {
|
|
|
|
|
bottom: 8px;
|
|
|
|
|
right: 8px;
|
|
|
|
|
@ -1333,6 +1378,7 @@ function buildPayload() {
|
|
|
|
|
0% {
|
|
|
|
|
left: -100%;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
100% {
|
|
|
|
|
left: 200%;
|
|
|
|
|
}
|
|
|
|
|
@ -1476,6 +1522,7 @@ function buildPayload() {
|
|
|
|
|
|
|
|
|
|
.status-value {
|
|
|
|
|
color: #ff6b6b;
|
|
|
|
|
|
|
|
|
|
&.enabled {
|
|
|
|
|
color: #00ff9d;
|
|
|
|
|
}
|
|
|
|
|
@ -1846,19 +1893,17 @@ function buildPayload() {
|
|
|
|
|
</style>
|
|
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
|
// 暗色模式专属规则:教师端已切换亮色(body.teacher-light-mode),不再注入这些全局暗色覆盖
|
|
|
|
|
body:not(.teacher-light-mode) {
|
|
|
|
|
.teacher-main.training-task-main-theme {
|
|
|
|
|
height: calc(100vh - 50px);
|
|
|
|
|
background: linear-gradient(135deg, #03070e 0%, #061827 48%, #02060d 100%) !important;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Element Plus 抽屉暗色化
|
|
|
|
|
.el-drawer {
|
|
|
|
|
// 移除自定义背景色,使用系统默认
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 输入框文字白色
|
|
|
|
|
.el-input__inner {
|
|
|
|
|
color: #ffffff !important;
|
|
|
|
|
|
|
|
|
|
&::placeholder {
|
|
|
|
|
color: rgba(200, 230, 255, 0.5) !important;
|
|
|
|
|
}
|
|
|
|
|
@ -1894,4 +1939,5 @@ function buildPayload() {
|
|
|
|
|
.el-input.is-disabled .el-input__inner {
|
|
|
|
|
color: rgba(200, 230, 255, 0.5) !important;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
|