|
|
|
|
|
<template>
|
|
|
|
|
|
<main ref="previewRoot" class="student-task-readonly-preview" @click.capture="guardPreviewInteraction" @keydown.capture="guardPreviewInteraction">
|
|
|
|
|
|
<component v-if="previewComponent" :is="previewComponent" v-bind="previewProps" />
|
|
|
|
|
|
<el-empty v-else :description="emptyDescription" :image-size="112" />
|
|
|
|
|
|
</main>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
|
import { getTrainingReviewPreviewContext } from "@/utils/trainingReviewPreview";
|
|
|
|
|
|
import { studentTaskPreviewComponentByKey, studentTaskPreviewPropsByKey } from "./studentTaskPreviewMap";
|
|
|
|
|
|
|
|
|
|
|
|
const route = useRoute();
|
|
|
|
|
|
const previewComponent = shallowRef(null);
|
|
|
|
|
|
const previewProps = ref({});
|
|
|
|
|
|
const emptyDescription = ref("正在加载学生任务页面");
|
|
|
|
|
|
const previewRoot = ref();
|
|
|
|
|
|
const PREVIEW_HEIGHT_MESSAGE = "teacher-task-review-preview-height";
|
|
|
|
|
|
let resizeObserver;
|
|
|
|
|
|
let mutationObserver;
|
|
|
|
|
|
let animationFrame;
|
|
|
|
|
|
|
|
|
|
|
|
async function loadPreview() {
|
|
|
|
|
|
previewComponent.value = null;
|
|
|
|
|
|
const taskKey = String(route.query.taskKey || "");
|
|
|
|
|
|
const preview = getTrainingReviewPreviewContext();
|
|
|
|
|
|
const loader = studentTaskPreviewComponentByKey[taskKey];
|
|
|
|
|
|
if (!preview || preview.taskKey !== taskKey) {
|
|
|
|
|
|
emptyDescription.value = "学生作答预览已失效,请返回任务评阅重新选择学生";
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!loader) {
|
|
|
|
|
|
emptyDescription.value = "该实训任务暂不支持页面预览";
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
|
|
|
previewComponent.value = (await loader()).default;
|
|
|
|
|
|
previewProps.value = studentTaskPreviewPropsByKey[taskKey]?.(taskKey) || {};
|
|
|
|
|
|
await nextTick();
|
|
|
|
|
|
schedulePreviewHeight();
|
|
|
|
|
|
} catch (_) {
|
|
|
|
|
|
emptyDescription.value = "学生任务页面加载失败,请刷新后重试";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
watch(() => [route.query.taskKey, route.query.reviewPreviewKey], loadPreview, { immediate: true });
|
|
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
|
resizeObserver = new ResizeObserver(schedulePreviewHeight);
|
|
|
|
|
|
if (previewRoot.value) resizeObserver.observe(previewRoot.value);
|
|
|
|
|
|
mutationObserver = new MutationObserver(schedulePreviewHeight);
|
|
|
|
|
|
if (previewRoot.value) mutationObserver.observe(previewRoot.value, { childList: true, subtree: true });
|
|
|
|
|
|
schedulePreviewHeight();
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
onBeforeUnmount(() => {
|
|
|
|
|
|
resizeObserver?.disconnect();
|
|
|
|
|
|
mutationObserver?.disconnect();
|
|
|
|
|
|
if (animationFrame) cancelAnimationFrame(animationFrame);
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
function schedulePreviewHeight() {
|
|
|
|
|
|
if (animationFrame) cancelAnimationFrame(animationFrame);
|
|
|
|
|
|
animationFrame = requestAnimationFrame(reportPreviewHeight);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function reportPreviewHeight() {
|
|
|
|
|
|
animationFrame = 0;
|
|
|
|
|
|
const height = Math.ceil(Math.max(
|
|
|
|
|
|
previewRoot.value?.scrollHeight || 0,
|
|
|
|
|
|
document.body?.scrollHeight || 0,
|
|
|
|
|
|
document.documentElement?.scrollHeight || 0,
|
|
|
|
|
|
window.innerHeight || 0,
|
|
|
|
|
|
));
|
|
|
|
|
|
window.parent?.postMessage({
|
|
|
|
|
|
type: PREVIEW_HEIGHT_MESSAGE,
|
|
|
|
|
|
previewKey: String(route.query.reviewPreviewKey || ""),
|
|
|
|
|
|
height,
|
|
|
|
|
|
}, window.location.origin);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function guardPreviewInteraction(event) {
|
|
|
|
|
|
const target = event.target instanceof Element ? event.target : null;
|
|
|
|
|
|
if (!target) return;
|
|
|
|
|
|
if (target.closest("input, textarea, select, [contenteditable='true'], .el-input, .el-textarea, .el-select, .el-checkbox, .el-radio, .el-switch")) {
|
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
|
event.stopImmediatePropagation();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
const action = target.closest("button, a, [role='button'], [role='tab'], .el-step");
|
|
|
|
|
|
if (action && !isStepNavigation(action)) {
|
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
|
event.stopImmediatePropagation();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function isStepNavigation(element) {
|
|
|
|
|
|
if (element.matches("[role='tab'], .el-step")) return true;
|
|
|
|
|
|
const label = String(element.getAttribute("aria-label") || "");
|
|
|
|
|
|
const text = `${label} ${String(element.textContent || "")}`.replace(/\s+/g, " ").trim();
|
|
|
|
|
|
return /(上一步|下一步|第\s*\d+\s*步|切换.*步骤|步骤.*切换)/.test(text);
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
|
/*
|
|
|
|
|
|
* 教师端任务评阅右侧预览:
|
|
|
|
|
|
* 学生页面已通过 dynamic component 嵌入,保留学生端样式;
|
|
|
|
|
|
* 仅保留步骤导航与步骤内容,隐藏标题区、任务简介、AI 助手与所有顶部/底部操作按钮(仅查看)。
|
|
|
|
|
|
*/
|
|
|
|
|
|
.student-task-readonly-preview {
|
|
|
|
|
|
background: #ffffff;
|
|
|
|
|
|
font-family: var(--student-font-base, "PingFang SC", "Source Han Sans SC", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ===== 1. 隐藏 AI 助手、AI 评测、独立的 TrainingTaskBrief 组件(保持原行为) ===== */
|
|
|
|
|
|
.student-task-readonly-preview :deep(.training-ai-sidebar),
|
|
|
|
|
|
.student-task-readonly-preview :deep(.training-ai-evaluation),
|
|
|
|
|
|
.student-task-readonly-preview :deep(.training-task-brief) { display: none !important; }
|
|
|
|
|
|
|
|
|
|
|
|
/* ===== 2. 隐藏学生页顶部 chrome(标题、任务简介、展开/收起按钮、顶部工具栏等) ===== */
|
|
|
|
|
|
.student-task-readonly-preview :deep(.task-header),
|
|
|
|
|
|
.student-task-readonly-preview :deep(.task-head-main),
|
|
|
|
|
|
.student-task-readonly-preview :deep(.task-brief),
|
|
|
|
|
|
.student-task-readonly-preview :deep(.task-brief-toggle),
|
|
|
|
|
|
.student-task-readonly-preview :deep(.task-brief-more),
|
|
|
|
|
|
.student-task-readonly-preview :deep(.workbench-head),
|
|
|
|
|
|
.student-task-readonly-preview :deep(.workbench-head--actions-only),
|
|
|
|
|
|
.student-task-readonly-preview :deep(.workbench-actions),
|
|
|
|
|
|
.student-task-readonly-preview :deep(.training-task-toolbar),
|
|
|
|
|
|
.student-task-readonly-preview :deep(.training-legacy-actions),
|
|
|
|
|
|
.student-task-readonly-preview :deep(.new-product-survey-toolbar),
|
|
|
|
|
|
.student-task-readonly-preview :deep(.comprehensive-training-toolbar),
|
|
|
|
|
|
.student-task-readonly-preview :deep(.release-channel-toolbar),
|
|
|
|
|
|
.student-task-readonly-preview :deep(.purchase-workbench) > .workbench-head,
|
|
|
|
|
|
.student-task-readonly-preview :deep(.process-workbench) > .workbench-head,
|
|
|
|
|
|
.student-task-readonly-preview :deep(.factors-workbench) > .workbench-head,
|
|
|
|
|
|
.student-task-readonly-preview :deep(.channel-toolbar),
|
|
|
|
|
|
.student-task-readonly-preview :deep(.supplier-toolbar),
|
|
|
|
|
|
.student-task-readonly-preview :deep(.promotion-toolbar),
|
|
|
|
|
|
.student-task-readonly-preview :deep(.hardware-workbench-head),
|
|
|
|
|
|
.student-task-readonly-preview :deep(.legacy-toolbar),
|
|
|
|
|
|
.student-task-readonly-preview :deep(.material-actions) { display: none !important; }
|
|
|
|
|
|
|
|
|
|
|
|
/* ===== 2.1 旧版实训页:隐藏 TrainingIntro 组件的标题/简介,仅保留其步骤导航 ===== */
|
|
|
|
|
|
.student-task-readonly-preview :deep(.training-intro__head),
|
|
|
|
|
|
.student-task-readonly-preview :deep(.training-intro__body) { display: none !important; }
|
|
|
|
|
|
.student-task-readonly-preview :deep(.training-intro) {
|
|
|
|
|
|
margin-bottom: 12px !important;
|
|
|
|
|
|
padding: 0 !important;
|
|
|
|
|
|
border: 0 !important;
|
|
|
|
|
|
border-radius: 0 !important;
|
|
|
|
|
|
background: transparent !important;
|
|
|
|
|
|
box-shadow: none !important;
|
|
|
|
|
|
overflow: visible !important;
|
|
|
|
|
|
}
|
|
|
|
|
|
.student-task-readonly-preview :deep(.training-intro__steps.step-indicator) { margin: 4px 0 18px !important; }
|
|
|
|
|
|
|
|
|
|
|
|
/* ===== 2.2 旧版实训页:top_item 是 section 切换 tab,保留作为步骤导航 ===== */
|
|
|
|
|
|
.student-task-readonly-preview :deep(.top_item) {
|
|
|
|
|
|
margin: 0 0 14px !important;
|
|
|
|
|
|
padding: 0 !important;
|
|
|
|
|
|
border: 0 !important;
|
|
|
|
|
|
background: transparent !important;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ===== 3. 让学生页面把 AI 侧栏所在的网格列收回,让预览通栏展示 ===== */
|
|
|
|
|
|
.student-task-readonly-preview :deep(.student-training-shell) { grid-template-columns: minmax(0, 1fr) !important; }
|
|
|
|
|
|
|
|
|
|
|
|
/* ===== 4. 紧贴 app-main 内边距,复用学生端整体留白 ===== */
|
|
|
|
|
|
.student-task-readonly-preview :deep(.student-training-shell) > main { padding: 14px 16px 24px !important; }
|
|
|
|
|
|
|
|
|
|
|
|
/* ===== 5. 步骤导航横排、并与学生端胶囊样式一致 ===== */
|
|
|
|
|
|
.student-task-readonly-preview :deep(.step-indicator),
|
|
|
|
|
|
.student-task-readonly-preview :deep(.comprehensive-step-nav),
|
|
|
|
|
|
.student-task-readonly-preview :deep(.comprehensive-step-strip),
|
|
|
|
|
|
.student-task-readonly-preview :deep(.step-tabs),
|
|
|
|
|
|
.student-task-readonly-preview :deep(.flow-steps),
|
|
|
|
|
|
.student-task-readonly-preview :deep(.flow-rail),
|
|
|
|
|
|
.student-task-readonly-preview :deep(.training-intro__steps) {
|
|
|
|
|
|
display: flex !important;
|
|
|
|
|
|
flex-direction: row !important;
|
|
|
|
|
|
flex-wrap: nowrap !important;
|
|
|
|
|
|
align-items: stretch !important;
|
|
|
|
|
|
justify-content: flex-start !important;
|
|
|
|
|
|
gap: 0 !important;
|
|
|
|
|
|
width: 100% !important;
|
|
|
|
|
|
max-width: 100% !important;
|
|
|
|
|
|
margin: 4px 0 18px !important;
|
|
|
|
|
|
padding: 0 !important;
|
|
|
|
|
|
border: none !important;
|
|
|
|
|
|
border-radius: 0 !important;
|
|
|
|
|
|
background: transparent !important;
|
|
|
|
|
|
box-shadow: none !important;
|
|
|
|
|
|
overflow-x: auto !important;
|
|
|
|
|
|
overflow-y: hidden !important;
|
|
|
|
|
|
scrollbar-width: thin !important;
|
|
|
|
|
|
-webkit-overflow-scrolling: touch !important;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 步骤胶囊:固定宽度并排,不让任何一条占满整行 */
|
|
|
|
|
|
.student-task-readonly-preview :deep(.step-indicator) .step-tab,
|
|
|
|
|
|
.student-task-readonly-preview :deep(.comprehensive-step-strip) .step-tab,
|
|
|
|
|
|
.student-task-readonly-preview :deep(.step-tabs) .step-tab,
|
|
|
|
|
|
.student-task-readonly-preview :deep(.step-tabs) .step-pill,
|
|
|
|
|
|
.student-task-readonly-preview :deep(.step-indicator) .flow-pill,
|
|
|
|
|
|
.student-task-readonly-preview :deep(.flow-steps) .step-pill,
|
|
|
|
|
|
.student-task-readonly-preview :deep(.flow-rail) .flow-step,
|
|
|
|
|
|
.student-task-readonly-preview :deep(.training-intro__steps) .step-tab {
|
|
|
|
|
|
flex: 0 0 auto !important;
|
|
|
|
|
|
flex-grow: 0 !important;
|
|
|
|
|
|
flex-shrink: 0 !important;
|
|
|
|
|
|
flex-basis: auto !important;
|
|
|
|
|
|
width: auto !important;
|
|
|
|
|
|
min-width: 132px !important;
|
|
|
|
|
|
max-width: 220px !important;
|
|
|
|
|
|
margin: 0 !important;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.student-task-readonly-preview :deep(.comprehensive-step-strip) {
|
|
|
|
|
|
width: max-content !important;
|
|
|
|
|
|
min-width: 100% !important;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.student-task-readonly-preview :deep(.step-connector),
|
|
|
|
|
|
.student-task-readonly-preview :deep(.step-arrow),
|
|
|
|
|
|
.student-task-readonly-preview :deep(.flow-arrow) {
|
|
|
|
|
|
flex: 0 0 22px !important;
|
|
|
|
|
|
width: 22px !important;
|
|
|
|
|
|
min-width: 22px !important;
|
|
|
|
|
|
display: inline-block !important;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ===== 6. 步骤内容卡片:保留学生端白卡 + 灰边样式 ===== */
|
|
|
|
|
|
.student-task-readonly-preview :deep(.step-card),
|
|
|
|
|
|
.student-task-readonly-preview :deep(.process-step-card),
|
|
|
|
|
|
.student-task-readonly-preview :deep(.factor-step-card),
|
|
|
|
|
|
.student-task-readonly-preview :deep(.step-content > .step-card),
|
|
|
|
|
|
.student-task-readonly-preview :deep(.training-step-area) {
|
|
|
|
|
|
border: 1px solid #e5e7eb !important;
|
|
|
|
|
|
border-radius: 12px !important;
|
|
|
|
|
|
background: #ffffff !important;
|
|
|
|
|
|
box-shadow: none !important;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ===== 7. 关闭底部"提交/导出/清空"等动作按钮区(仅查看,不需要学生端的提交动作) ===== */
|
|
|
|
|
|
.student-task-readonly-preview :deep(.task-actions),
|
|
|
|
|
|
.student-task-readonly-preview :deep(.task-actions-row),
|
|
|
|
|
|
.student-task-readonly-preview :deep(.taskfooter),
|
|
|
|
|
|
.student-task-readonly-preview :deep(.step-footer),
|
|
|
|
|
|
.student-task-readonly-preview :deep(.step-actions),
|
|
|
|
|
|
.student-task-readonly-preview :deep(.footer-actions) {
|
|
|
|
|
|
pointer-events: none !important;
|
|
|
|
|
|
opacity: 0.55 !important;
|
|
|
|
|
|
filter: grayscale(0.4) !important;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ===== 8. 禁用所有表单交互,确保仅查看 ===== */
|
|
|
|
|
|
.student-task-readonly-preview :deep(input),
|
|
|
|
|
|
.student-task-readonly-preview :deep(textarea),
|
|
|
|
|
|
.student-task-readonly-preview :deep(select),
|
|
|
|
|
|
.student-task-readonly-preview :deep(.el-input__inner),
|
|
|
|
|
|
.student-task-readonly-preview :deep(.el-textarea__inner),
|
|
|
|
|
|
.student-task-readonly-preview :deep(.el-select) { pointer-events: none !important; }
|
|
|
|
|
|
|
|
|
|
|
|
/* ===== 9. 隐藏通用浮层与弹窗,避免误触 ===== */
|
|
|
|
|
|
.student-task-readonly-preview :deep(.gdialog),
|
|
|
|
|
|
.student-task-readonly-preview :deep(.popModal),
|
|
|
|
|
|
.student-task-readonly-preview :deep(.el-popper),
|
|
|
|
|
|
.student-task-readonly-preview :deep(.el-overlay) { display: none !important; }
|
|
|
|
|
|
</style>
|