|
|
|
|
|
<template>
|
|
|
|
|
|
<div class="task">
|
|
|
|
|
|
<section class="task-toolbar">
|
|
|
|
|
|
<div class="class-picker">
|
|
|
|
|
|
<span>教学班</span>
|
|
|
|
|
|
<el-select v-model="classId" placeholder="请选择教学班" class="class-select" @change="loadPublication">
|
|
|
|
|
|
<el-option v-for="item in teachingClassList" :key="item.schoolClassId" :label="item.className" :value="item.schoolClassId" />
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<el-tag v-if="classId" :type="configured ? 'success' : 'warning'">
|
|
|
|
|
|
{{ configured ? '已保存发布配置' : '默认全部发布(未配置)' }}
|
|
|
|
|
|
</el-tag>
|
|
|
|
|
|
<span v-if="classId" class="task-tip">{{ configured ? '仅勾选的实训任务会出现在学生端。' : '现有实训任务默认勾选;“综合案例实训”默认不发布,需由教师主动勾选。' }}</span>
|
|
|
|
|
|
<el-button type="primary" :disabled="!canOperateSelectedClass || !classId" :loading="saving" @click="savePublication">
|
|
|
|
|
|
<el-icon>
|
|
|
|
|
|
<Check />
|
|
|
|
|
|
</el-icon>
|
|
|
|
|
|
保存发布配置
|
|
|
|
|
|
</el-button>
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
|
|
<el-alert v-if="classId && !canOperateSelectedClass" title="只能配置自己创建的教学班,当前班级仅可查看。" type="info" :closable="false" show-icon />
|
|
|
|
|
|
|
|
|
|
|
|
<el-table
|
|
|
|
|
|
ref="tableRef"
|
|
|
|
|
|
:data="tasks"
|
|
|
|
|
|
row-key="taskKey"
|
|
|
|
|
|
v-loading="loading"
|
|
|
|
|
|
class="task-table"
|
|
|
|
|
|
@selection-change="handleSelectionChange"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-table-column type="selection" width="58" :reserve-selection="true" :selectable="() => canOperateSelectedClass" />
|
|
|
|
|
|
<el-table-column prop="taskName" label="实训任务" min-width="280" header-align="left" align="left">
|
|
|
|
|
|
<template #default="{ row }">
|
|
|
|
|
|
<div class="name-cell">
|
|
|
|
|
|
<span class="task-badge">{{ (row.taskName || "?").charAt(0) }}</span>
|
|
|
|
|
|
<span class="name-text">{{ row.taskName }}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
<el-table-column prop="projectName" label="所属模块" min-width="180" align="center" header-align="center" />
|
|
|
|
|
|
<template #empty>
|
|
|
|
|
|
<div class="table-empty">
|
|
|
|
|
|
<el-icon class="empty-icon">
|
|
|
|
|
|
<FolderOpened />
|
|
|
|
|
|
</el-icon>
|
|
|
|
|
|
<p class="empty-title">暂无实训任务</p>
|
|
|
|
|
|
<p class="empty-tip">可通过顶部选择教学班加载实训任务列表</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-table>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
|
import { listClassTrainingTasks } from "@/api/trainingTask";
|
|
|
|
|
|
import * as indexApi from "@/api/teacher";
|
|
|
|
|
|
import useUserStore from "@/store/modules/user";
|
|
|
|
|
|
import { Check, FolderOpened } from "@element-plus/icons-vue";
|
|
|
|
|
|
|
|
|
|
|
|
const { proxy } = getCurrentInstance();
|
|
|
|
|
|
const userStore = useUserStore();
|
|
|
|
|
|
const classList = ref([]);
|
|
|
|
|
|
const tasks = ref([]);
|
|
|
|
|
|
const classId = ref("");
|
|
|
|
|
|
const selectedTaskKeys = ref([]);
|
|
|
|
|
|
const configured = ref(false);
|
|
|
|
|
|
const loading = ref(false);
|
|
|
|
|
|
const saving = ref(false);
|
|
|
|
|
|
const tableRef = ref(null);
|
|
|
|
|
|
const comprehensiveTaskKey = "comprehensive-case-training";
|
|
|
|
|
|
let activeLoadGeneration = 0;
|
|
|
|
|
|
let selectionSyncGeneration = -1;
|
|
|
|
|
|
|
|
|
|
|
|
const currentUserId = computed(() => userStore.userInfo.userId);
|
|
|
|
|
|
const teachingClassList = computed(() => classList.value.filter((item) => item.classType === "TEACHING" || !item.classType && item.createdBy));
|
|
|
|
|
|
const selectedClass = computed(() => teachingClassList.value.find((item) => item.schoolClassId === classId.value));
|
|
|
|
|
|
const canOperateSelectedClass = computed(() => selectedClass.value?.createdBy === currentUserId.value);
|
|
|
|
|
|
|
|
|
|
|
|
async function loadClasses() {
|
|
|
|
|
|
const res = await indexApi.getClassListBySchoolId({ schoolId: userStore.userInfo.schoolId });
|
|
|
|
|
|
classList.value = res.data || [];
|
|
|
|
|
|
classId.value = teachingClassList.value[0]?.schoolClassId || "";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function isActiveLoad(requestedClassId, requestGeneration) {
|
|
|
|
|
|
return classId.value === requestedClassId && requestGeneration === activeLoadGeneration;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function syncTableSelection(taskKeys, requestGeneration) {
|
|
|
|
|
|
selectionSyncGeneration = requestGeneration;
|
|
|
|
|
|
tableRef.value?.clearSelection();
|
|
|
|
|
|
proxy.$nextTick(() => {
|
|
|
|
|
|
if (requestGeneration !== activeLoadGeneration) return;
|
|
|
|
|
|
const selected = new Set(taskKeys);
|
|
|
|
|
|
tasks.value.forEach((task) => tableRef.value?.toggleRowSelection(task, selected.has(task.taskKey)));
|
|
|
|
|
|
proxy.$nextTick(() => {
|
|
|
|
|
|
if (requestGeneration === activeLoadGeneration) selectionSyncGeneration = -1;
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function sortTasksWithComprehensiveLast(taskList) {
|
|
|
|
|
|
return [...taskList].sort((left, right) => {
|
|
|
|
|
|
const leftIsComprehensive = left?.taskKey === comprehensiveTaskKey;
|
|
|
|
|
|
const rightIsComprehensive = right?.taskKey === comprehensiveTaskKey;
|
|
|
|
|
|
if (leftIsComprehensive === rightIsComprehensive) return 0;
|
|
|
|
|
|
return leftIsComprehensive ? 1 : -1;
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async function loadTasks(requestGeneration) {
|
|
|
|
|
|
if (!classId.value) {
|
|
|
|
|
|
tasks.value = [];
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
const requestedClassId = classId.value;
|
|
|
|
|
|
tasks.value = [];
|
|
|
|
|
|
const res = await listClassTrainingTasks(classId.value, { enabledOnly: false });
|
|
|
|
|
|
if (!isActiveLoad(requestedClassId, requestGeneration)) return false;
|
|
|
|
|
|
tasks.value = sortTasksWithComprehensiveLast(res.data || []);
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function applySelection(requestGeneration) {
|
|
|
|
|
|
syncTableSelection(selectedTaskKeys.value, requestGeneration);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async function loadPublication() {
|
|
|
|
|
|
const requestGeneration = ++activeLoadGeneration;
|
|
|
|
|
|
selectedTaskKeys.value = [];
|
|
|
|
|
|
configured.value = false;
|
|
|
|
|
|
syncTableSelection([], requestGeneration);
|
|
|
|
|
|
if (!classId.value) {
|
|
|
|
|
|
tasks.value = [];
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
const requestedClassId = classId.value;
|
|
|
|
|
|
loading.value = true;
|
|
|
|
|
|
try {
|
|
|
|
|
|
await loadTasks(requestGeneration);
|
|
|
|
|
|
if (!isActiveLoad(requestedClassId, requestGeneration)) return;
|
|
|
|
|
|
const res = await indexApi.getTaskPublication({ classId: requestedClassId });
|
|
|
|
|
|
if (!isActiveLoad(requestedClassId, requestGeneration)) return;
|
|
|
|
|
|
configured.value = res.data?.configured === true;
|
|
|
|
|
|
selectedTaskKeys.value = configured.value
|
|
|
|
|
|
? (res.data?.taskKeys || [])
|
|
|
|
|
|
: tasks.value
|
|
|
|
|
|
.filter((task) => task.taskKey !== comprehensiveTaskKey)
|
|
|
|
|
|
.map((task) => task.taskKey);
|
|
|
|
|
|
applySelection(requestGeneration);
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
if (requestGeneration === activeLoadGeneration) loading.value = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function handleSelectionChange(selection) {
|
|
|
|
|
|
if (selectionSyncGeneration === activeLoadGeneration) return;
|
|
|
|
|
|
selectedTaskKeys.value = selection.map((task) => task.taskKey);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async function savePublication() {
|
|
|
|
|
|
if (!canOperateSelectedClass.value || !classId.value) return;
|
|
|
|
|
|
saving.value = true;
|
|
|
|
|
|
try {
|
|
|
|
|
|
const taskAllocationList = selectedTaskKeys.value.map((taskKey, index) => ({ module: taskKey, disabledStatus: 0, sort: index + 1 }));
|
|
|
|
|
|
await indexApi.addTask({
|
|
|
|
|
|
taskAllocationList,
|
|
|
|
|
|
classId: classId.value,
|
|
|
|
|
|
schoolId: userStore.userInfo.schoolId,
|
|
|
|
|
|
userId: currentUserId.value,
|
|
|
|
|
|
});
|
|
|
|
|
|
configured.value = true;
|
|
|
|
|
|
proxy.$modal.msgSuccess("发布配置已保存");
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
saving.value = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
onMounted(async () => {
|
|
|
|
|
|
loading.value = true;
|
|
|
|
|
|
try {
|
|
|
|
|
|
await loadClasses();
|
|
|
|
|
|
await loadPublication();
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
loading.value = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
|
.task {
|
|
|
|
|
|
/* ===== 筛选 / 操作条(扁平,直接落在画布上;外观归 teacher-light.scss 全局接管)===== */
|
|
|
|
|
|
.task-toolbar {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
flex-wrap: wrap;
|
|
|
|
|
|
gap: var(--sp-3);
|
|
|
|
|
|
margin-bottom: var(--sp-4);
|
|
|
|
|
|
|
|
|
|
|
|
.class-picker {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: var(--sp-2);
|
|
|
|
|
|
color: var(--text-strong);
|
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.class-select {
|
|
|
|
|
|
width: var(--field-w);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.task-tip {
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
min-width: 280px;
|
|
|
|
|
|
color: var(--text-body);
|
|
|
|
|
|
font-size: var(--fs-body);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ===== 实训任务名称首字徽标(对齐班级/学生/院系管理基准)===== */
|
|
|
|
|
|
.name-cell {
|
|
|
|
|
|
display: inline-flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: var(--sp-2);
|
|
|
|
|
|
max-width: 100%;
|
|
|
|
|
|
vertical-align: middle;
|
|
|
|
|
|
|
|
|
|
|
|
.name-text {
|
|
|
|
|
|
min-width: 0;
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.task-badge {
|
|
|
|
|
|
flex: 0 0 auto;
|
|
|
|
|
|
width: 28px;
|
|
|
|
|
|
height: 28px;
|
|
|
|
|
|
display: inline-flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
background: var(--edu-primary-soft);
|
|
|
|
|
|
color: var(--edu-primary);
|
|
|
|
|
|
border-radius: var(--r-control);
|
|
|
|
|
|
font-size: var(--fs-body);
|
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.name-text {
|
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
|
color: var(--text-strong);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ===== 自定义空状态 ===== */
|
|
|
|
|
|
.table-empty {
|
|
|
|
|
|
padding: var(--sp-5) 0;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: var(--sp-1);
|
|
|
|
|
|
|
|
|
|
|
|
.empty-icon {
|
|
|
|
|
|
font-size: 28px;
|
|
|
|
|
|
color: var(--text-muted);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.empty-title {
|
|
|
|
|
|
margin: var(--sp-1) 0 0;
|
|
|
|
|
|
font-size: var(--fs-body);
|
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
|
color: var(--text-body);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.empty-tip {
|
|
|
|
|
|
margin: 0;
|
|
|
|
|
|
font-size: var(--fs-tag);
|
|
|
|
|
|
color: var(--text-muted);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ===== 数据表格(纯白 + 灰线)===== */
|
|
|
|
|
|
.task-table {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
background: #ffffff;
|
|
|
|
|
|
border: 1px solid var(--border-color);
|
|
|
|
|
|
border-radius: var(--r-card);
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
|
|
|
|
|
|
:deep(.el-table__header-wrapper th) {
|
|
|
|
|
|
background: #ffffff;
|
|
|
|
|
|
color: var(--text-strong);
|
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
|
font-size: var(--fs-body);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
:deep(.el-table__body tr:hover > td) {
|
|
|
|
|
|
background: #f9fafb !important;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
:deep(.el-table__cell) {
|
|
|
|
|
|
font-size: var(--fs-body);
|
|
|
|
|
|
color: var(--text-strong);
|
|
|
|
|
|
border-color: var(--border-color);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@media (max-width: 760px) {
|
|
|
|
|
|
.task .task-toolbar .class-picker,
|
|
|
|
|
|
.task .task-toolbar .class-select {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.task .task-toolbar :deep(.el-button) {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|