@ -1,35 +1,29 @@
< 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"
< svg width = "14" height = "14" viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" stroke -width = " 2 " >
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 = "请选择教学班"
< el -select v-model ="selectedTeachingClassId" :loading="classesLoading" placeholder="请选择教学班" class="class-select" @change="queryTasks" >
class = "class-select" @ change = "queryTasks" >
< el -option v -for = " schoolClass in teachingClassList " :key ="schoolClass.schoolClassId" :label ="schoolClass.className" :value ="schoolClass.schoolClassId" / >
< el -option v -for = " schoolClass in teachingClassList " :key ="schoolClass.schoolClassId"
: label = "schoolClass.className" : value = "schoolClass.schoolClassId" / >
< / e l - s e l e c t >
< / e l - s e l e c t >
< / 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"
< svg class = "search-icon" width = "16" height = "16" viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" stroke -width = " 2 " >
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"
< svg width = "14" height = "14" viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" stroke -width = " 2 " >
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 >
@ -40,30 +34,26 @@
< 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"
< svg width = "12" height = "12" viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" stroke -width = " 2 " >
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 >
班级配置模式
班级配置模式
< / e l - t a g >
< / e l - t a g >
< 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"
< svg width = "12" height = "12" viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" stroke -width = " 2 " >
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 >
默认任务
默认任务
< / e l - t a g >
< / e l - t a g >
< / div >
< / div >
< el -button v -if = " selectedTeachingClass " type = "danger" plain class = "toolbar-btn toolbar-btn-danger"
< el -button v-if ="selectedTeachingClass" type="danger" plain class="toolbar-btn toolbar-btn-danger" :loading="restoring" @click="restoreAllTasksDefaults" >
: 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 >
恢复默认
恢复默认
< / e l - b u t t o n >
< / e l - b u t t o n >
< el -button v -if = " selectedTeachingClass " type = "success" plain class = "toolbar-btn toolbar-btn-success"
< el -button v-if ="selectedTeachingClass" type="success" plain class="toolbar-btn toolbar-btn-success" @click="openStudentDemo" >
@ 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" / >
@ -86,9 +76,7 @@
< 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"
< button v-for ="project in projectOptions" :key="project.name" type="button" :class="['project-tab', { active: activeProject === project.name }]" @click="toggleProject(project.name)" >
: 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 >
@ -103,8 +91,7 @@
<!-- 任务卡片网格 -- >
<!-- 任务卡片网格 -- >
< 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"
< 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)" >
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" / >
@ -125,8 +112,7 @@
< 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"
< svg width = "12" height = "12" viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" stroke -width = " 2 " >
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 || "默认实训任务" } }
@ -140,16 +126,14 @@
< 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"
< svg width = "12" height = "12" viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" stroke -width = " 2 " >
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"
< svg width = "12" height = "12" viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" stroke -width = " 2 " >
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 >
@ -160,8 +144,7 @@
< 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"
< svg width = "14" height = "14" viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" stroke -width = " 2 " >
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 >
@ -174,8 +157,7 @@
< / 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 "
< svg width = "80" height = "80" viewBox = "0 0 24 24" fill = "none" stroke = "#00aaff" stroke -width = " 1 " opacity = "0.3" >
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 >
@ -184,14 +166,12 @@
< / section >
< / section >
<!-- 编辑抽屉 -- >
<!-- 编辑抽屉 -- >
< el -drawer v -model = " dialogVisible " :size ="860" class = "training-task-drawer" append -to -body destroy -on -close
< el -drawer v-model ="dialogVisible" :size="860" class="training-task-drawer" append-to-body destroy-on-close :with-header="false" >
: 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"
< svg width = "12" height = "12" viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" stroke -width = " 2 " >
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 >
@ -201,8 +181,7 @@
< 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"
< svg width = "18" height = "18" viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" stroke -width = " 2 " >
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 >
@ -211,8 +190,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"
< svg width = "16" height = "16" viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" stroke -width = " 2 " >
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" >
@ -221,8 +199,7 @@
< / 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"
< svg width = "16" height = "16" viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" stroke -width = " 2 " >
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 >
@ -232,8 +209,7 @@
< / 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"
< svg width = "16" height = "16" viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" stroke -width = " 2 " >
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 >
@ -273,23 +249,18 @@
< / 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"
< div v-for ="(objective, index) in taskForm.objectives" :key="index" class="objective-row" >
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"
< button v-if ="!isReadonly" type="button" class="remove-btn" :disabled="taskForm.objectives.length <= 1" @click="removeObjective(index)" >
: 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"
< button v-if ="!isReadonly" type="button" class="add-objective-button" @click="addObjective" >
@ 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 >
@ -308,30 +279,25 @@
< 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"
< svg width = "20" height = "20" viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" stroke -width = " 2 " >
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" > {{
< span v-if ="hasMaterial(slot.key)" class="material-link" > {{ taskForm [ ` $ { slot.key } Name ` ] }} < / span >
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"
< el -upload v-if ="!isReadonly" action="#" :auto-upload="false" :show-file-list="false" :on-change="(file) => handleMaterialChange(slot.key, file)" >
: 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"
< svg width = "14" height = "14" viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" stroke -width = " 2 " >
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" / >
@ -339,8 +305,7 @@
{ { uploadingField === slot . key ? "上传中..." : "上传" } }
{ { uploadingField === slot . key ? "上传中..." : "上传" } }
< / e l - b u t t o n >
< / e l - b u t t o n >
< / e l - u p l o a d >
< / e l - u p l o a d >
< el -button v -if = " ! isReadonly & & hasMaterial ( slot.key ) " type = "danger" plain
< el -button v-if ="!isReadonly && hasMaterial(slot.key)" type="danger" plain class="clear-material-btn" @click="clearMaterial(slot.key)" > 清 除 < / el -button >
class = "clear-material-btn" @ click = "clearMaterial(slot.key)" > 清除 < / e l - b u t t o n >
< / div >
< / div >
< / div >
< / div >
@ -354,18 +319,14 @@
< 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 "
< path d = "M0 6h16M12 1l4 5-4 5" stroke = "#00aaff" stroke -width = " 1.5 " fill = "none" opacity = "0.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"
< el -button v-if ="!isReadonly" type="primary" class="step-question-btn" @click="choiceEditorVisible = true" > 编 辑 题 目 {{ stepOneQuestionCount ? ` ( $ { stepOneQuestionCount } 题 ) ` : " " }} < / el -button >
@ click = "choiceEditorVisible = true" >
编辑题目 { { stepOneQuestionCount ? ` ( ${ stepOneQuestionCount } 题) ` : "" } }
< / e l - b u t t o n >
< span v -else class = "step-question-tag" > 已配置 { { stepOneQuestionCount } } 道题 < / span >
< span v -else class = "step-question-tag" > 已配置 { { stepOneQuestionCount } } 道题 < / span >
< / template >
< / template >
< / div >
< / div >
@ -379,18 +340,15 @@
< el -button class = "cancel-btn" @ click = "dialogVisible = false" >
< el -button class = "cancel-btn" @ click = "dialogVisible = false" >
{ { isReadonly ? "关闭" : "取消" } }
{ { isReadonly ? "关闭" : "取消" } }
< / e l - b u t t o n >
< / e l - b u t t o n >
< el -button v -if = " ! isReadonly " type = "danger" plain class = "toolbar-btn toolbar-btn-danger"
< el -button v-if ="!isReadonly" type="danger" plain class="toolbar-btn toolbar-btn-danger" :loading="restoring" @click="restoreTaskDefault" >
: loading = "restoring" @ click = "restoreTaskDefault" >
< 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 >
恢复默认
恢复默认
< / e l - b u t t o n >
< / e l - b u t t o n >
< 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"
< svg width = "14" height = "14" viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" stroke -width = " 2 " >
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" / >
@ -404,167 +362,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 ) ;
/ / 四 类 资 料 槽 位 : k e y 对 应 t a s k F o r m 的 ` $ { k e y } N a m e ` / ` $ { k e y } U r l ` 字 段 , 不 限 制 文 件 类 型
/ / 四 类 资 料 槽 位 : k e y 对 应 t a s k F o r m 的 ` $ { k e y } N a m e ` / ` $ { k e y } U r l ` 字 段 , 不 限 制 文 件 类 型
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 ( ) {
@ -588,37 +546,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 ,
@ -639,72 +597,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 = "" ) {
@ -712,13 +670,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 ) {
@ -726,128 +684,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 ;
/ / 项 目 使 用 h a s h 路 由 ; 显 式 带 上 h a s h , 避 免 新 窗 口 先 落 到 默 认 的 教 师 首 页 。
/ / 项 目 使 用 h a s h 路 由 ; 显 式 带 上 h a s h , 避 免 新 窗 口 先 落 到 默 认 的 教 师 首 页 。
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 ;
}
}
}
}
@ -871,7 +829,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 >
@ -1687,4 +1645,3 @@ function buildPayload() {
}
}
}
}
< / style >
< / style >