You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dianshang-qianduan/src/views/schoolAdmin/trainingTask/index.vue

2019 lines
55 KiB
Vue

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<template>
<div class="training-task-page">
<!-- 页面头部 -->
<section class="page-header">
<div class="header-decoration">
<svg class="decoration-lines" viewBox="0 0 400 60" preserveAspectRatio="xMidYMid slice">
<defs>
<linearGradient id="headerGrad" x1="0%" y1="0%" x2="100%" y2="0%">
<stop offset="0%" style="stop-color: #2563eb; stop-opacity: 0" />
<stop offset="50%" style="stop-color: #2563eb; stop-opacity: 0.3" />
<stop offset="100%" style="stop-color: #2ba471; stop-opacity: 0" />
</linearGradient>
</defs>
<line x1="0" y1="58" x2="400" y2="58" stroke="url(#headerGrad)" stroke-width="1" />
<circle cx="50" cy="30" r="3" fill="#2563eb" opacity="0.2" />
<circle cx="150" cy="20" r="2" fill="#2ba471" opacity="0.2" />
<circle cx="250" cy="40" r="2.5" fill="#2563eb" opacity="0.15" />
<circle cx="350" cy="25" r="2" fill="#2ba471" opacity="0.2" />
</svg>
</div>
<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="#2563eb" stroke-width="1.5" stroke-linecap="round" />
<path d="M9 12h6M9 16h6" stroke="#2563eb" stroke-width="1.5" stroke-linecap="round" />
</svg>
</div>
<div class="header-text">
<h1 class="page-title">实训任务管理</h1>
<p class="page-subtitle">维护系统默认实训配置,教学班未单独配置时学生端使用这里的实训背景、目标、要求和案例文档。</p>
</div>
<div class="header-stats">
<div class="stat-item">
<span class="stat-value">{{ tasks.length }}</span>
<span class="stat-label">总任务</span>
</div>
<div class="stat-item">
<span class="stat-value">{{ enabledCount }}</span>
<span class="stat-label">已启用</span>
</div>
</div>
</div>
</section>
<!-- 筛选区域 -->
<section class="task-filter">
<div class="filter-top">
<div class="search-area">
<div class="search-box">
<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>
<input v-model.trim="keyword" type="text" placeholder="输入实训任务名称搜索..." class="search-input" @keyup.enter="queryTasks" />
<button v-if="keyword" class="clear-btn" @click="keyword = ''">×</button>
</div>
<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">
<circle cx="11" cy="11" r="8" />
<path d="M21 21l-4.35-4.35" />
</svg>
<span>查询</span>
</el-button>
</div>
<div class="toolbar-actions">
<button class="tool-btn" @click="downloadTemplate">
<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="7 10 12 15 17 10" />
<line x1="12" y1="15" x2="12" y2="3" />
</svg>
<span>下载模板</span>
</button>
<el-upload action="#" :auto-upload="false" :show-file-list="false" :on-change="handleImportChange">
<button class="tool-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" />
<polyline points="17 8 12 3 7 8" />
<line x1="12" y1="3" x2="12" y2="15" />
</svg>
<span>导入配置</span>
</button>
</el-upload>
</div>
</div>
<div class="project-filter">
<span class="filter-label">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M22 19a2 2 0 01-2 2H4a2 2 0 01-2-2V5a2 2 0 012-2h5l2 3h9a2 2 0 012 2z" />
</svg>
所属项目:
</span>
<div class="project-tabs">
<button type="button" :class="['project-tab', { active: !activeProject }]" @click="activeProject = ''">
<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)">
<span class="tab-name">{{ project.name }}</span>
<span class="tab-count">{{ project.count }}</span>
</button>
</div>
<div class="filter-result">
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<polyline points="20 6 9 17 4 12" />
</svg>
<span>显示 {{ filteredTasks.length }} / {{ tasks.length }} 条</span>
</div>
</div>
</section>
<!-- 任务网格 -->
<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)">
<div class="card-decoration">
<svg class="corner-decoration top-left" width="24" height="24" viewBox="0 0 24 24">
<path d="M2 8V2h6" stroke="#2563eb" stroke-width="2" fill="none" opacity="0.6" />
</svg>
<svg class="corner-decoration top-right" width="24" height="24" viewBox="0 0 24 24">
<path d="M22 8V2h-6" stroke="#2563eb" stroke-width="2" fill="none" opacity="0.6" />
</svg>
<svg class="corner-decoration bottom-left" width="24" height="24" viewBox="0 0 24 24">
<path d="M2 16v6h6" stroke="#2ba471" stroke-width="2" fill="none" opacity="0.4" />
</svg>
<svg class="corner-decoration bottom-right" width="24" height="24" viewBox="0 0 24 24">
<path d="M22 16v6h-6" stroke="#2ba471" stroke-width="2" fill="none" opacity="0.4" />
</svg>
</div>
<div class="card-index">{{ String(index + 1).padStart(2, "0") }}</div>
<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">
<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 || "默认实训任务" }}
</span>
<span :class="['task-status', { enabled: task.enabled }]">
{{ task.enabled ? "启用" : "停用" }}
</span>
</div>
<h3 class="task-name">{{ task.title }}</h3>
<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">
<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">
<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>
{{ task.steps?.length || 0 }} 个步骤
</span>
</div>
</div>
<div class="card-actions" @click.stop>
<el-button type="primary" class="edit-btn" @click="editTask(task)">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<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>
编辑任务
</el-button>
</div>
<div class="card-glow"></div>
<div class="scanline"></div>
</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="#2563eb" stroke-width="1" opacity="0.3">
<path d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2" />
<rect x="9" y="3" width="6" height="4" rx="1" />
</svg>
</template>
</el-empty>
</section>
<!-- 抽屉编辑 -->
<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">
<circle cx="12" cy="12" r="10" />
<path d="M12 8v4l3 3" />
</svg>
{{ dialogMode === "view" ? "Training Task Preview" : "Training Task Editor" }}
</span>
<h3>{{ dialogMode === "view" ? "查看实训任务" : "编辑实训任务" }}</h3>
<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">
<line x1="18" y1="6" x2="6" y2="18" />
<line x1="6" y1="6" x2="18" y2="18" />
</svg>
</button>
</header>
<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">
<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">
<span class="identity-label">所属项目</span>
<strong>{{ taskForm.project || "未填写" }}</strong>
</div>
</div>
<div class="identity-item">
<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>
<div class="identity-content">
<span class="identity-label">实训任务</span>
<strong>{{ taskForm.title || "未填写" }}</strong>
</div>
</div>
<div class="identity-item status">
<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>
<div class="identity-content">
<span class="identity-label">任务状态</span>
<strong :class="['status-value', { enabled: taskForm.enabled }]">
{{ taskForm.enabled ? "启用" : "停用" }}
</strong>
</div>
</div>
</div>
<el-form class="task-form" label-position="top" :disabled="isReadonly">
<section class="drawer-section">
<div class="section-title">
<span class="section-number">01</span>
<div class="section-info">
<h4>基础说明</h4>
<p>设置任务的基本信息</p>
</div>
</div>
<div class="basic-grid">
<el-form-item label="所属项目:">
<el-input v-model="taskForm.project" placeholder="请输入所属项目" />
</el-form-item>
<el-form-item label="任务标识:">
<el-input v-model="taskForm.taskKey" :disabled="Boolean(currentTaskId)" placeholder="请输入唯一任务标识" />
</el-form-item>
</div>
<el-form-item label="实训任务名称:">
<el-input v-model="taskForm.title" placeholder="保存后会同步为学生端左侧导航名称" />
</el-form-item>
<el-form-item label="任务状态:">
<div class="switch-wrapper">
<el-switch v-model="taskForm.enabled" />
<span class="switch-label">{{ taskForm.enabled ? "已启用" : "已停用" }}</span>
</div>
</el-form-item>
<el-form-item label="实训背景:">
<el-input v-model="taskForm.background" type="textarea" :rows="4" placeholder="请输入实训背景" />
</el-form-item>
</section>
<section class="drawer-section">
<div class="section-title">
<span class="section-number">02</span>
<div class="section-info">
<h4>目标与要求</h4>
<p>定义实训的学习目标</p>
</div>
</div>
<el-form-item label="实训目标:">
<div class="objective-list">
<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">
<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">
<line x1="12" y1="5" x2="12" y2="19" />
<line x1="5" y1="12" x2="19" y2="12" />
</svg>
新增目标
</button>
</div>
</el-form-item>
<el-form-item label="实训要求:">
<el-input v-model="taskForm.requirements" type="textarea" :rows="4" placeholder="请输入实训要求" />
</el-form-item>
</section>
<section class="drawer-section">
<div class="section-title">
<span class="section-number">03</span>
<div class="section-info">
<h4>资料与步骤</h4>
<p>上传案例资料、案例数据、实训指导手册、AI辅助指导手册与参考答案,配置实训步骤</p>
</div>
</div>
<div v-for="slot in materialSlots" :key="slot.key" class="material-row">
<div class="material-info">
<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 class="material-label">{{ slot.label }}</span>
<span v-if="hasMaterial(slot.key)" class="material-link">{{ taskForm[`${slot.key}Name`] }}</span>
<span v-else class="material-placeholder">暂未上传</span>
</div>
</div>
<div class="material-ops">
<el-upload v-if="!isReadonly" action="#" :auto-upload="false" :show-file-list="false" :accept="slot.accept" :on-change="(file) => handleMaterialChange(slot.key, file)">
<el-button type="primary" :loading="uploadingField === slot.key" class="upload-btn">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4" />
<polyline points="17 8 12 3 7 8" />
<line x1="12" y1="3" x2="12" y2="15" />
</svg>
{{ uploadingField === slot.key ? "上传中..." : "上传" }}
</el-button>
</el-upload>
<el-button v-if="!isReadonly && hasMaterial(slot.key)" type="danger" plain class="clear-material-btn" @click="clearMaterial(slot.key)">清除</el-button>
</div>
</div>
<!-- 第一步选择题:编辑入口固定在第一个步骤行旁,仅三个白名单任务显示 -->
<StepOneQuestionBankPicker v-model:visible="bankPickerVisible" :load-questions="loadBankQuestions" :existing="taskForm.stepOneQuestions" @confirm="handleBankConfirm" />
<StepOneChoiceQuestionEditor v-model:visible="choiceEditorVisible" v-model="taskForm.stepOneQuestions" :task-name="taskForm.title" :load-questions="loadBankQuestions" />
<el-form-item label="步骤名称:">
<div class="step-list">
<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="#2563eb" 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="步骤名称" />
<template v-if="index === 0 && supportsStepOneChoice(taskForm.taskKey)">
<el-button v-if="!isReadonly" type="primary" class="step-question-btn" @click="choiceEditorVisible = true">编辑题目{{ stepOneQuestionCount ? `(${stepOneQuestionCount}题)` : "" }}</el-button>
<span v-else class="step-question-tag">已配置 {{ stepOneQuestionCount }} 道题</span>
</template>
<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" />
</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">
<line x1="12" y1="5" x2="12" y2="19" />
<line x1="5" y1="12" x2="19" y2="12" />
</svg>
新增步骤
</button>
</div>
</el-form-item>
</section>
</el-form>
<footer class="drawer-footer">
<el-button class="cancel-btn" @click="dialogVisible = false">
{{ isReadonly ? "关闭" : "取消" }}
</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">
<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" />
</svg>
保存配置
</el-button>
</footer>
</div>
</el-drawer>
</div>
</template>
<script setup>
import { downloadTrainingTaskTemplate, importTrainingTasks, listTrainingTasks, updateTrainingTask, uploadTrainingTaskMaterial } from "@/api/trainingTask";
import StepOneChoiceQuestionEditor from "@/views/components/StepOneChoiceQuestionEditor.vue";
import StepOneQuestionBankPicker from "@/views/components/StepOneQuestionBankPicker.vue";
import { parseStepOneChoiceQuestions, supportsStepOneChoiceQuestions } from "@/utils/stepOneChoiceQuestions";
import { getPlatformQuestions } from "@/api/exam";
const { proxy } = getCurrentInstance();
const activeProject = ref("");
const keyword = ref("");
const loading = ref(false);
const saving = ref(false);
const uploadingField = ref("");
const choiceEditorVisible = ref(false);
const bankPickerVisible = ref(false);
// 五类资料槽位:key 对应 taskForm 的 `${key}Name` / `${key}Url` 字段。
const materialSlots = [
{ key: "material", label: "案例资料" },
{ key: "trainingData", label: "案例数据" },
{ key: "guideManual", label: "实训指导手册" },
{ key: "aiManual", label: "AI辅助指导手册" },
{ key: "referenceAnswer", label: "参考答案", accept: ".doc,.docx,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document" },
];
const tasks = ref([]);
const dialogVisible = ref(false);
const dialogMode = ref("view");
const currentTaskId = ref("");
const taskForm = reactive(createEmptyTask());
const isReadonly = computed(() => dialogMode.value === "view");
const stepOneQuestionCount = computed(() => taskForm.stepOneQuestions?.length || 0);
const enabledCount = computed(() => tasks.value.filter((t) => t.enabled).length);
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 filteredTasks = computed(() => {
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;
});
});
onMounted(() => {
setTrainingTaskMainTheme(true);
queryTasks();
});
onActivated(() => {
setTrainingTaskMainTheme(true);
});
onDeactivated(() => {
setTrainingTaskMainTheme(false);
});
onBeforeUnmount(() => {
setTrainingTaskMainTheme(false);
});
function setTrainingTaskMainTheme(enabled) {
const main = document.querySelector(".app-main2");
if (!main) return;
main.classList.toggle("training-task-main-theme", enabled);
}
function toggleProject(project) {
activeProject.value = activeProject.value === project ? "" : project;
}
async function queryTasks() {
loading.value = true;
try {
const res = await listTrainingTasks({ enabledOnly: false });
tasks.value = (res.data || []).map(normalizeTask);
if (activeProject.value && !projects.value.includes(activeProject.value)) {
activeProject.value = "";
}
} catch (error) {
tasks.value = [];
} finally {
loading.value = false;
}
}
function viewTask(task) {
openTaskDialog(task, "view");
}
function editTask(task) {
openTaskDialog(task, "edit");
}
function createEmptyTask() {
return {
id: "",
taskKey: "",
project: "",
title: "",
background: "",
objectives: [""],
requirements: "",
materialName: "",
materialUrl: "",
trainingDataName: "",
trainingDataUrl: "",
guideManualName: "",
guideManualUrl: "",
aiManualName: "",
aiManualUrl: "",
referenceAnswerName: "",
referenceAnswerUrl: "",
stepOneQuestions: [],
steps: createBuiltinSteps(),
sort: 0,
enabled: true,
};
}
function supportsStepOneChoice(taskKey) {
return supportsStepOneChoiceQuestions(taskKey);
}
// 平台题库单选题(平台管理员维护默认任务,题源为平台题库)
async function loadBankQuestions() {
const res = await getPlatformQuestions({ type: "SINGLE" });
return res?.data || [];
}
function handleBankConfirm(questions) {
taskForm.stepOneQuestions = [...(taskForm.stepOneQuestions || []), ...questions];
proxy?.$modal?.msgSuccess(`已从题库添加 ${questions.length} 道题,点击“保存配置”后生效`);
}
function hasMaterial(slotKey) {
return isRealMaterial(taskForm[`${slotKey}Name`], taskForm[`${slotKey}Url`]);
}
function materialLabel(slotKey) {
return materialSlots.find((slot) => slot.key === slotKey)?.label || "资料";
}
function normalizeTask(task) {
const material = normalizeMaterial(task.materialName, task.materialUrl);
const trainingData = normalizeMaterial(task.trainingDataName, task.trainingDataUrl);
const guideManual = normalizeMaterial(task.guideManualName, task.guideManualUrl);
const aiManual = normalizeMaterial(task.aiManualName, task.aiManualUrl);
const referenceAnswer = normalizeMaterial(task.referenceAnswerName, task.referenceAnswerUrl);
return {
id: task.id,
taskKey: task.taskKey,
project: task.projectName,
title: task.taskName,
background: task.background || "",
objectives: parseArray(task.objectives, [""]),
requirements: task.requirements || "",
materialName: material.name,
materialUrl: material.url,
trainingDataName: trainingData.name,
trainingDataUrl: trainingData.url,
guideManualName: guideManual.name,
guideManualUrl: guideManual.url,
aiManualName: aiManual.name,
aiManualUrl: aiManual.url,
referenceAnswerName: referenceAnswer.name,
referenceAnswerUrl: referenceAnswer.url,
stepOneQuestions: parseStepOneChoiceQuestions(task.stepOneQuestions),
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 = String(materialUrl || "").trim();
return isRealMaterial(name, url) ? { name, url } : { name: "", url: "" };
}
function isRealMaterial(materialName, materialUrl) {
const name = String(materialName || "").trim();
const url = String(materialUrl || "").trim();
if (!name) {
return false;
}
return !(name === "案例资料.rar" && (!url || url === "/file/example.rar"));
}
function parseArray(value, fallback) {
if (Array.isArray(value)) {
return value.length ? value : fallback;
}
if (!value) {
return fallback;
}
try {
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);
}
}
function normalizeSteps(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);
})
.filter((item) => item.name);
return result.length ? result : [createStep()];
}
function createBuiltinSteps() {
return [1, 2, 3, 4].map((index) => createStep("", "builtin", `builtin-${index}`));
}
function createStep(name = "", kind = "custom", id = "") {
return {
id: id || `custom-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
name,
kind,
};
}
function openTaskDialog(task, mode) {
dialogMode.value = mode;
currentTaskId.value = task.id;
Object.assign(taskForm, cloneTask(task));
dialogVisible.value = true;
}
function cloneTask(task) {
return {
...task,
objectives: [...(task.objectives?.length ? task.objectives : [""])],
steps: normalizeSteps(task.steps?.length ? task.steps : createBuiltinSteps()),
};
}
function addObjective() {
taskForm.objectives.push("");
}
function removeObjective(index) {
if (taskForm.objectives.length <= 1) return;
taskForm.objectives.splice(index, 1);
}
function addStep() {
taskForm.steps.push(createStep());
}
function removeStep(index) {
if (taskForm.steps.length <= 1) return;
taskForm.steps.splice(index, 1);
}
async function handleImportChange(file) {
if (!file?.raw) return;
await importTrainingTasks(file.raw);
proxy?.$modal?.msgSuccess("导入成功");
queryTasks();
}
async function handleMaterialChange(slotKey, file) {
const rawFile = file?.raw;
if (!rawFile) return;
if (slotKey === "referenceAnswer" && !isWordFile(rawFile)) {
proxy?.$modal?.msgError?.("参考答案仅支持 Word 文件(.doc 或 .docx)");
return;
}
const data = new FormData();
data.append("file", rawFile);
uploadingField.value = slotKey;
try {
const res = await uploadTrainingTaskMaterial(data);
taskForm[`${slotKey}Name`] = res?.originalFilename || rawFile.name || file?.name || taskForm[`${slotKey}Name`];
taskForm[`${slotKey}Url`] = res?.url || res?.fileName || "";
proxy?.$modal?.msgSuccess(`${materialLabel(slotKey)}上传成功`);
} catch (error) {
proxy?.$modal?.msgError?.(`${materialLabel(slotKey)}上传失败`);
} finally {
uploadingField.value = "";
}
}
function isWordFile(file) {
const name = String(file?.name || "").trim().toLowerCase();
return name.endsWith(".doc") || name.endsWith(".docx");
}
function clearMaterial(slotKey) {
taskForm[`${slotKey}Name`] = "";
taskForm[`${slotKey}Url`] = "";
}
async function downloadTemplate() {
const blob = await downloadTrainingTaskTemplate();
const url = URL.createObjectURL(new Blob([blob]));
const link = document.createElement("a");
link.href = url;
link.download = "实训任务导入模板.xlsx";
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
URL.revokeObjectURL(url);
}
async function submitTask() {
if (!currentTaskId.value) {
proxy?.$modal?.msgError?.("系统内置任务只能编辑,不能新增");
return;
}
saving.value = true;
try {
await updateTrainingTask(currentTaskId.value, buildPayload());
dialogVisible.value = false;
proxy?.$modal?.msgSuccess("保存成功");
await queryTasks();
} finally {
saving.value = false;
}
}
function buildPayload() {
return {
projectName: taskForm.project,
taskKey: taskForm.taskKey,
taskName: taskForm.title,
background: taskForm.background,
objectives: JSON.stringify(taskForm.objectives.map((item) => item.trim()).filter(Boolean)),
requirements: taskForm.requirements,
steps: JSON.stringify(taskForm.steps.map((item) => ({ ...item, name: item.name.trim() })).filter((item) => item.name)),
materialName: taskForm.materialName,
materialUrl: taskForm.materialUrl,
trainingDataName: taskForm.trainingDataName,
trainingDataUrl: taskForm.trainingDataUrl,
guideManualName: taskForm.guideManualName,
guideManualUrl: taskForm.guideManualUrl,
aiManualName: taskForm.aiManualName,
aiManualUrl: taskForm.aiManualUrl,
referenceAnswerName: taskForm.referenceAnswerName,
referenceAnswerUrl: taskForm.referenceAnswerUrl,
stepOneQuestions: JSON.stringify(taskForm.stepOneQuestions || []),
sort: taskForm.sort,
enabled: taskForm.enabled,
};
}
</script>
<style lang="scss" scoped>
.training-task-page {
min-height: calc(100vh - 96px);
margin: 22px 24px 28px;
padding: 0;
}
// 页面头部
.page-header {
position: relative;
margin-bottom: 24px;
padding: 28px 32px 24px;
border: 1px solid rgba(37, 99, 235, 0.2);
border-radius: 16px;
background: #ffffff;
overflow: hidden;
.header-decoration {
position: absolute;
top: 0;
left: 0;
right: 0;
height: 60px;
opacity: 0.6;
.decoration-lines {
width: 100%;
height: 100%;
}
}
.header-content {
position: relative;
display: flex;
align-items: center;
gap: 20px;
}
.header-icon {
flex-shrink: 0;
display: flex;
align-items: center;
justify-content: center;
width: 64px;
height: 64px;
border-radius: 16px;
background: linear-gradient(135deg, rgba(37, 99, 235, 0.2), rgba(43, 164, 113, 0.1));
border: 1px solid rgba(37, 99, 235, 0.3);
box-shadow: 0 0 30px rgba(37, 99, 235, 0.2);
}
.header-text {
flex: 1;
.page-title {
margin: 0 0 8px;
font-size: 24px;
font-weight: 700;
color: #ffffff;
text-shadow: 0 2px 10px rgba(37, 99, 235, 0.3);
}
.page-subtitle {
margin: 0;
color: #4b5563;
font-size: 14px;
line-height: 1.6;
}
}
.header-stats {
display: flex;
gap: 24px;
.stat-item {
display: flex;
flex-direction: column;
align-items: center;
padding: 12px 20px;
border-radius: 12px;
background: rgba(37, 99, 235, 0.1);
border: 1px solid rgba(37, 99, 235, 0.2);
.stat-value {
font-size: 28px;
font-weight: 700;
color: #2ba471;
text-shadow: 0 0 20px rgba(43, 164, 113, 0.4);
}
.stat-label {
font-size: 12px;
color: #6b7280;
margin-top: 4px;
}
}
}
}
// 筛选区域
.task-filter {
padding: 20px 24px;
margin-bottom: 24px;
border: 1px solid rgba(37, 99, 235, 0.2);
border-radius: 12px;
background: #ffffff;
}
.filter-top {
display: flex;
align-items: center;
justify-content: space-between;
gap: 20px;
margin-bottom: 16px;
}
.search-area {
display: flex;
align-items: center;
gap: 12px;
}
.search-box {
position: relative;
display: flex;
align-items: center;
flex: 1;
max-width: 400px;
height: 40px;
padding: 0 16px;
border-radius: 10px;
background: #f9fafb;
border: 1px solid rgba(37, 99, 235, 0.3);
transition: all 0.3s ease;
&:focus-within {
border-color: rgba(37, 99, 235, 0.6);
box-shadow: 0 0 20px rgba(37, 99, 235, 0.15);
}
.search-icon {
flex-shrink: 0;
color: rgba(37, 99, 235, 0.6);
}
.search-input {
flex: 1;
height: 100%;
padding: 0 12px;
color: #fff;
font-size: 14px;
background: transparent;
border: none;
outline: none;
&::placeholder {
color: #9ca3af;
}
}
.clear-btn {
flex-shrink: 0;
width: 20px;
height: 20px;
display: flex;
align-items: center;
justify-content: center;
color: #6b7280;
font-size: 16px;
background: rgba(37, 99, 235, 0.1);
border: none;
border-radius: 50%;
cursor: pointer;
transition: all 0.2s ease;
&:hover {
color: #fff;
background: rgba(37, 99, 235, 0.3);
}
}
}
.search-btn {
display: flex;
align-items: center;
gap: 8px;
height: 40px;
padding: 0 20px;
border: none;
border-radius: 10px;
background: linear-gradient(135deg, #2563eb, #1d4ed8);
color: #fff;
font-size: 14px;
font-weight: 600;
box-shadow: 0 4px 15px rgba(37, 99, 235, 0.3);
transition: all 0.3s ease;
&:hover {
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
}
}
.toolbar-actions {
display: flex;
align-items: center;
gap: 8px;
}
.tool-btn {
display: flex;
align-items: center;
gap: 8px;
height: 36px;
padding: 0 16px;
color: #374151;
font-size: 13px;
font-weight: 500;
background: rgba(37, 99, 235, 0.1);
border: 1px solid rgba(37, 99, 235, 0.2);
border-radius: 8px;
cursor: pointer;
transition: all 0.2s ease;
&:hover {
color: #fff;
background: rgba(37, 99, 235, 0.2);
border-color: rgba(37, 99, 235, 0.4);
}
}
.project-filter {
display: flex;
align-items: center;
gap: 12px;
flex-wrap: wrap;
}
.filter-label {
display: flex;
align-items: center;
gap: 6px;
color: #4b5563;
font-size: 13px;
font-weight: 600;
}
.project-tabs {
display: flex;
align-items: center;
gap: 8px;
flex-wrap: wrap;
}
.project-tab {
display: flex;
align-items: center;
gap: 8px;
height: 34px;
padding: 0 14px;
color: #4b5563;
font-size: 13px;
font-weight: 500;
background: #f9fafb;
border: 1px solid rgba(37, 99, 235, 0.15);
border-radius: 8px;
cursor: pointer;
transition: all 0.2s ease;
.tab-count {
padding: 2px 8px;
font-size: 11px;
font-weight: 700;
background: rgba(37, 99, 235, 0.15);
border-radius: 999px;
}
&:hover {
color: #fff;
border-color: rgba(37, 99, 235, 0.4);
background: rgba(37, 99, 235, 0.1);
}
&.active {
color: #fff;
border-color: rgba(37, 99, 235, 0.6);
background: linear-gradient(135deg, rgba(37, 99, 235, 0.25), rgba(37, 99, 235, 0.08));
box-shadow: 0 0 15px rgba(37, 99, 235, 0.2);
.tab-count {
background: #2ba471;
color: #1f2937;
}
}
}
.filter-result {
display: flex;
align-items: center;
gap: 6px;
margin-left: auto;
padding: 6px 14px;
color: #2ba471;
font-size: 12px;
font-weight: 600;
background: rgba(43, 164, 113, 0.1);
border: 1px solid rgba(43, 164, 113, 0.2);
border-radius: 999px;
}
// 任务网格
.task-grid {
display: grid;
grid-template-columns: repeat(3, minmax(280px, 1fr));
gap: 24px;
min-height: 300px;
}
.task-card {
position: relative;
padding: 24px;
border-radius: 16px;
background: #ffffff;
border: 1px solid rgba(37, 99, 235, 0.25);
cursor: pointer;
transition: all 0.3s ease;
overflow: hidden;
&:hover {
border-color: rgba(37, 99, 235, 0.45);
transform: translateY(-4px);
box-shadow:
0 20px 40px rgba(0, 0, 0, 0.4),
0 0 30px rgba(37, 99, 235, 0.15);
.card-glow {
opacity: 1;
}
.scanline {
animation: scanline 1.5s ease-in-out;
}
}
}
.card-decoration {
.corner-decoration {
position: absolute;
opacity: 0.6;
transition: opacity 0.3s ease;
&.top-left {
top: 8px;
left: 8px;
}
&.top-right {
top: 8px;
right: 8px;
}
&.bottom-left {
bottom: 8px;
left: 8px;
}
&.bottom-right {
bottom: 8px;
right: 8px;
}
}
}
.card-index {
position: absolute;
top: 16px;
right: 20px;
font-size: 48px;
font-weight: 800;
color: rgba(37, 99, 235, 0.08);
line-height: 1;
user-select: none;
}
.card-content {
position: relative;
z-index: 1;
}
.card-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 12px;
}
.task-project {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 4px 12px;
color: #2563eb;
font-size: 12px;
font-weight: 600;
background: rgba(37, 99, 235, 0.1);
border: 1px solid rgba(37, 99, 235, 0.2);
border-radius: 999px;
}
.task-status {
padding: 4px 10px;
font-size: 11px;
font-weight: 700;
color: rgba(255, 107, 107, 0.9);
background: rgba(255, 107, 107, 0.1);
border: 1px solid rgba(255, 107, 107, 0.2);
border-radius: 999px;
&.enabled {
color: #2ba471;
background: rgba(43, 164, 113, 0.1);
border-color: rgba(43, 164, 113, 0.2);
}
}
.task-name {
margin: 0 0 12px;
font-size: 18px;
font-weight: 700;
color: #fff;
line-height: 1.4;
}
.task-meta {
display: flex;
align-items: center;
gap: 16px;
}
.meta-item {
display: flex;
align-items: center;
gap: 6px;
color: #6b7280;
font-size: 12px;
}
.card-actions {
position: relative;
z-index: 1;
margin-top: 20px;
padding-top: 16px;
border-top: 1px solid rgba(37, 99, 235, 0.1);
}
.edit-btn {
display: flex;
align-items: center;
gap: 8px;
width: 100%;
justify-content: center;
height: 38px;
border: none;
border-radius: 10px;
background: linear-gradient(135deg, #2563eb, #1d4ed8);
color: #fff;
font-size: 13px;
font-weight: 600;
box-shadow: 0 4px 15px rgba(37, 99, 235, 0.25);
transition: all 0.3s ease;
&:hover {
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(37, 99, 235, 0.18);
}
}
.card-glow {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: radial-gradient(circle at 30% 0%, rgba(37, 99, 235, 0.15), transparent 60%);
opacity: 0;
transition: opacity 0.3s ease;
pointer-events: none;
}
.scanline {
position: absolute;
top: 0;
left: -100%;
width: 50%;
height: 100%;
background: linear-gradient(90deg, transparent, rgba(37, 99, 235, 0.1), transparent);
pointer-events: none;
}
@keyframes scanline {
0% {
left: -100%;
}
100% {
left: 200%;
}
}
.task-empty {
grid-column: 1 / -1;
}
// 抽屉样式
.training-task-drawer {
// 覆盖 Element Plus 默认白色样式
--el-drawer-bg-color: #1f2937 !important;
.el-drawer__body {
height: 100%;
padding: 0;
overflow: hidden;
background: #ffffff !important;
}
// 移除白色边框
&.el-drawer {
border: none !important;
box-shadow: -10px 0 40px rgba(0, 0, 0, 0.5) !important;
background: #ffffff !important;
}
}
// 抽屉遮罩层
.el-overlay {
background: rgba(0, 0, 0, 0.7) !important;
.training-task-drawer {
background: #ffffff !important;
}
}
.drawer-shell {
display: flex;
flex-direction: column;
height: 100%;
background: #ffffff;
}
.drawer-header {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 24px;
padding: 28px 32px 22px;
border-bottom: 1px solid rgba(37, 99, 235, 0.2);
background: linear-gradient(90deg, #dbeafe, #f3f4f6);
}
.drawer-heading {
.drawer-kicker {
display: inline-flex;
align-items: center;
gap: 8px;
padding: 6px 14px;
color: #2563eb;
font-size: 12px;
font-weight: 700;
background: rgba(37, 99, 235, 0.1);
border: 1px solid rgba(37, 99, 235, 0.3);
border-radius: 999px;
}
h3 {
margin: 12px 0 8px;
font-size: 22px;
font-weight: 700;
color: #fff;
}
p {
margin: 0;
color: #6b7280;
font-size: 13px;
line-height: 1.6;
}
}
.drawer-close-button {
display: flex;
align-items: center;
justify-content: center;
width: 36px;
height: 36px;
color: #4b5563;
background: rgba(37, 99, 235, 0.1);
border: 1px solid rgba(37, 99, 235, 0.2);
border-radius: 10px;
cursor: pointer;
transition: all 0.2s ease;
&:hover {
color: #fff;
background: rgba(37, 99, 235, 0.25);
border-color: rgba(37, 99, 235, 0.4);
}
}
.drawer-identity {
display: grid;
grid-template-columns: 1fr 1.5fr 120px;
gap: 16px;
padding: 20px 32px;
border-bottom: 1px solid rgba(37, 99, 235, 0.15);
background: #f9fafb;
}
.identity-item {
display: flex;
align-items: center;
gap: 12px;
padding: 14px 16px;
background: #f9fafb;
border: 1px solid rgba(37, 99, 235, 0.2);
border-radius: 12px;
> svg {
flex-shrink: 0;
color: #2563eb;
opacity: 0.7;
}
.identity-content {
min-width: 0;
}
.identity-label {
display: block;
margin-bottom: 4px;
color: #6b7280;
font-size: 11px;
font-weight: 600;
}
strong {
display: block;
overflow: hidden;
color: #fff;
font-size: 14px;
font-weight: 700;
text-overflow: ellipsis;
white-space: nowrap;
}
.status-value {
color: #ff6b6b;
&.enabled {
color: #2ba471;
}
}
}
.task-form {
flex: 1;
min-height: 0;
padding: 0;
overflow-y: auto;
.el-form-item {
margin-bottom: 20px;
}
.el-form-item__label {
color: #1f2937 !important;
font-weight: 600 !important;
font-size: 14px !important;
}
// 覆盖 Element Plus 输入框默认白色背景
.el-input__wrapper {
background-color: #f3f4f6 !important;
border: 1px solid rgba(37, 99, 235, 0.4) !important;
border-radius: 8px !important;
box-shadow: none !important;
padding: 2px 12px !important;
&:hover {
border-color: rgba(37, 99, 235, 0.6) !important;
}
&.is-focus {
border-color: #2563eb !important;
box-shadow: 0 0 12px rgba(37, 99, 235, 0.3) !important;
}
}
.el-input__inner {
color: #1f2937 !important;
font-size: 14px;
font-weight: 500;
&::placeholder {
color: #6b7280 !important;
}
&:hover {
color: #1f2937 !important;
}
}
// 文本域样式
.el-textarea__inner {
background-color: #f3f4f6 !important;
border: 1px solid rgba(37, 99, 235, 0.4) !important;
border-radius: 8px !important;
box-shadow: none !important;
color: #1f2937 !important;
font-size: 14px;
font-weight: 500;
padding: 12px !important;
&:hover {
border-color: rgba(37, 99, 235, 0.6) !important;
}
&.is-focus {
border-color: #2563eb !important;
box-shadow: 0 0 12px rgba(37, 99, 235, 0.3) !important;
}
&::placeholder {
color: #6b7280 !important;
}
}
}
.drawer-section {
padding: 24px;
margin-bottom: 20px;
background: #f9fafb;
border: 1px solid rgba(37, 99, 235, 0.2);
border-radius: 16px;
}
.section-title {
display: flex;
align-items: center;
gap: 16px;
margin-bottom: 20px;
.section-number {
display: flex;
align-items: center;
justify-content: center;
width: 40px;
height: 40px;
font-size: 16px;
font-weight: 800;
color: #2563eb;
background: rgba(37, 99, 235, 0.15);
border: 1px solid rgba(37, 99, 235, 0.3);
border-radius: 10px;
}
.section-info {
h4 {
margin: 0 0 4px;
font-size: 16px;
font-weight: 700;
color: #1f2937;
}
p {
margin: 0;
color: #6b7280;
font-size: 12px;
}
}
}
.basic-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 16px;
}
.switch-wrapper {
display: flex;
align-items: center;
gap: 12px;
.switch-label {
color: #4b5563;
font-size: 13px;
}
// Switch 组件暗色化
.el-switch {
--el-switch-off-color: rgba(255, 107, 107, 0.4);
--el-switch-on-color: rgba(43, 164, 113, 0.4);
--el-switch-border-color: rgba(37, 99, 235, 0.3);
&.is-checked {
--el-switch-border-color: rgba(43, 164, 113, 0.5);
}
}
}
.objective-list {
width: 100%;
.el-input {
.el-input__wrapper {
background-color: #f3f4f6 !important;
border: 1px solid rgba(37, 99, 235, 0.4) !important;
box-shadow: none !important;
&:hover,
&.is-focus {
border-color: rgba(37, 99, 235, 0.6) !important;
}
}
.el-input__inner {
color: #1f2937 !important;
font-weight: 500;
&::placeholder {
color: #6b7280 !important;
}
}
}
}
.objective-row {
display: flex;
align-items: center;
gap: 12px;
margin-bottom: 12px;
.objective-number {
flex-shrink: 0;
display: flex;
align-items: center;
justify-content: center;
width: 28px;
height: 28px;
font-size: 12px;
font-weight: 700;
color: #2563eb;
background: rgba(37, 99, 235, 0.1);
border: 1px solid rgba(37, 99, 235, 0.2);
border-radius: 6px;
}
.el-input {
flex: 1;
}
}
.remove-btn {
flex-shrink: 0;
display: flex;
align-items: center;
justify-content: center;
width: 32px;
height: 32px;
color: rgba(255, 107, 107, 0.7);
background: rgba(255, 107, 107, 0.1);
border: 1px solid rgba(255, 107, 107, 0.2);
border-radius: 8px;
cursor: pointer;
transition: all 0.2s ease;
&:hover:not(:disabled) {
color: #ff6b6b;
background: rgba(255, 107, 107, 0.2);
border-color: rgba(255, 107, 107, 0.4);
}
&:disabled {
opacity: 0.3;
cursor: not-allowed;
}
}
.add-objective-button,
.add-step-button {
display: flex;
align-items: center;
justify-content: center;
gap: 8px;
height: 38px;
padding: 0 18px;
color: #2563eb;
font-size: 13px;
font-weight: 600;
background: rgba(37, 99, 235, 0.08);
border: 1px dashed rgba(37, 99, 235, 0.3);
border-radius: 8px;
cursor: pointer;
transition: all 0.2s ease;
&:hover {
color: #2563eb;
background: rgba(37, 99, 235, 0.15);
border-color: rgba(37, 99, 235, 0.45);
}
}
.material-row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 20px;
padding: 16px;
margin-bottom: 16px;
background: #f9fafb;
border: 1px solid rgba(37, 99, 235, 0.15);
border-radius: 12px;
}
.material-info {
display: flex;
align-items: center;
gap: 12px;
min-width: 0;
> svg {
flex-shrink: 0;
color: #2563eb;
}
.material-text {
display: flex;
align-items: center;
gap: 8px;
min-width: 0;
}
.material-label {
flex-shrink: 0;
color: #1f2937;
font-weight: 600;
}
.material-link {
overflow: hidden;
color: #2563eb;
font-weight: 600;
text-overflow: ellipsis;
white-space: nowrap;
}
.material-placeholder {
color: #9ca3af;
font-style: italic;
}
}
.material-ops {
display: flex;
align-items: center;
flex-shrink: 0;
gap: 8px;
.clear-material-btn {
height: 32px;
font-weight: 600;
}
}
.upload-btn {
display: flex;
align-items: center;
gap: 8px;
background: linear-gradient(135deg, rgba(37, 99, 235, 0.2), rgba(37, 99, 235, 0.08)) !important;
border: 1px solid rgba(37, 99, 235, 0.4) !important;
color: #2563eb !important;
&:hover {
background: linear-gradient(135deg, rgba(37, 99, 235, 0.3), rgba(37, 99, 235, 0.15)) !important;
border-color: rgba(37, 99, 235, 0.6) !important;
color: #ffffff !important;
}
}
.step-list {
display: flex;
flex-direction: column;
gap: 12px;
}
.step-item {
display: flex;
align-items: center;
gap: 12px;
}
.step-connector {
flex-shrink: 0;
}
.step-content {
display: flex;
align-items: center;
gap: 12px;
flex: 1;
.step-number {
flex-shrink: 0;
display: flex;
align-items: center;
justify-content: center;
width: 32px;
height: 32px;
font-size: 13px;
font-weight: 700;
color: #2ba471;
background: rgba(43, 164, 113, 0.1);
border: 1px solid rgba(43, 164, 113, 0.2);
border-radius: 8px;
}
.step-question-btn {
flex-shrink: 0;
height: 32px;
font-weight: 600;
}
.step-question-tag {
flex-shrink: 0;
color: #6b7280;
font-size: 12px;
white-space: nowrap;
}
.el-input {
flex: 1;
.el-input__wrapper {
background-color: #f3f4f6 !important;
border: 1px solid rgba(37, 99, 235, 0.4) !important;
box-shadow: none !important;
&:hover,
&.is-focus {
border-color: rgba(37, 99, 235, 0.6) !important;
}
}
.el-input__inner {
color: #1f2937 !important;
font-weight: 500;
&::placeholder {
color: #6b7280 !important;
}
}
}
}
.drawer-footer {
position: absolute;
right: 0;
bottom: 0;
left: 0;
display: flex;
justify-content: flex-end;
gap: 14px;
padding: 18px 32px;
background: #ffffff;
border-top: 1px solid rgba(37, 99, 235, 0.2);
}
.cancel-btn {
height: 40px;
padding: 0 24px;
color: #374151 !important;
background: rgba(37, 99, 235, 0.1) !important;
border: 1px solid rgba(37, 99, 235, 0.25) !important;
border-radius: 10px;
&:hover {
color: #ffffff !important;
background: rgba(37, 99, 235, 0.2) !important;
border-color: rgba(37, 99, 235, 0.4) !important;
}
}
.save-btn {
display: flex;
align-items: center;
gap: 8px;
height: 40px;
padding: 0 24px;
border: none;
border-radius: 10px;
background: linear-gradient(135deg, #2563eb, #1d4ed8);
box-shadow: 0 4px 15px rgba(37, 99, 235, 0.3);
}
@media (max-width: 1280px) {
.task-grid {
grid-template-columns: repeat(2, 1fr);
}
}
@media (max-width: 768px) {
.training-task-page {
margin: 12px;
}
.page-header {
padding: 20px;
.header-content {
flex-direction: column;
align-items: flex-start;
}
.header-stats {
width: 100%;
justify-content: space-around;
}
}
.filter-top {
flex-direction: column;
align-items: stretch;
}
.search-box {
max-width: none;
}
.toolbar-actions {
justify-content: center;
}
.filter-result {
margin-left: 0;
width: 100%;
justify-content: center;
}
.task-grid {
grid-template-columns: 1fr;
}
.drawer-identity {
grid-template-columns: 1fr;
}
.basic-grid {
grid-template-columns: 1fr;
}
}
</style>
<style lang="scss">
.app-main2.training-task-main-theme {
height: calc(100vh - 50px);
overflow-x: hidden;
overflow-y: auto !important;
background: linear-gradient(135deg, #f7fafd 0%, #eef4fb 48%, #f5f8fc 100%) !important;
}
// 全局覆盖 Element Plus 抽屉白色边框
.el-drawer.training-task-drawer {
background: #ffffff !important;
border: none !important;
.el-drawer__body {
background: #ffffff !important;
}
}
// Element Plus 抽屉暗色化
.el-drawer {
--el-drawer-bg-color: #1f2937 !important;
background-color: #1f2937 !important;
}
// ===== 输入框全面暗色化覆盖 =====
// 输入框文字深色
.el-input__inner {
color: #1f2937 !important;
&::placeholder {
color: #6b7280 !important;
}
}
// 输入框包装器背景
.el-input__wrapper {
background-color: #f3f4f6 !important;
border: 1px solid rgba(37, 99, 235, 0.4) !important;
box-shadow: none !important;
&:hover {
border-color: rgba(37, 99, 235, 0.6) !important;
}
&.is-focus {
border-color: #2563eb !important;
box-shadow: 0 0 12px rgba(37, 99, 235, 0.3) !important;
}
}
// 文本域暗色化
.el-textarea__inner {
background-color: #f3f4f6 !important;
border: 1px solid rgba(37, 99, 235, 0.4) !important;
box-shadow: none !important;
color: #1f2937 !important;
&::placeholder {
color: #6b7280 !important;
}
&:hover {
border-color: rgba(37, 99, 235, 0.6) !important;
}
&.is-focus {
border-color: #2563eb !important;
box-shadow: 0 0 12px rgba(37, 99, 235, 0.3) !important;
}
}
// 表单标签深色
.el-form-item__label {
color: #1f2937 !important;
font-weight: 600 !important;
}
// 输入框禁用状态暗色化
.el-input.is-disabled .el-input__wrapper {
background-color: #f9fafb !important;
border-color: rgba(37, 99, 235, 0.25) !important;
.el-input__inner {
color: #6b7280 !important;
}
}
// 文本域禁用状态
.el-textarea.is-disabled .el-textarea__inner {
background-color: #f9fafb !important;
border-color: rgba(37, 99, 235, 0.25) !important;
color: #6b7280 !important;
}
// 表单禁用标签
.el-form-item.is-disabled .el-form-item__label {
color: #6b7280 !important;
}
</style>