1788 lines
84 KiB
Vue
1788 lines
84 KiB
Vue
<script setup lang="ts">
|
||
import { useI18n } from 'vue-i18n'
|
||
const { t } = useI18n()
|
||
import { computed, onMounted, reactive, ref } from 'vue'
|
||
import { Calendar, Check, Plus, Refresh, User } from '@element-plus/icons-vue'
|
||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||
import http, { apiErrorMessage } from '../api/http'
|
||
import { useAuthStore } from '../stores/auth'
|
||
import {
|
||
academicTermLabel,
|
||
academicTermOptionClass,
|
||
defaultAcademicTermId,
|
||
} from '../utils/academicTerms'
|
||
|
||
const auth = useAuthStore()
|
||
const isStudent = computed(() => auth.user?.roles.includes('Student') ?? false)
|
||
const loading = ref(false)
|
||
const terms = ref<any[]>([])
|
||
const termId = ref('')
|
||
const projects = ref<any[]>([])
|
||
const total = ref(0)
|
||
const page = ref(1)
|
||
const pageSize = ref(20)
|
||
const selectedProjectIds = ref<string[]>([])
|
||
const options = reactive({
|
||
tasks: [] as any[],
|
||
colleges: [] as any[],
|
||
scheduleEntries: [] as any[],
|
||
classrooms: [] as any[],
|
||
teachers: [] as any[],
|
||
periods: [] as any[],
|
||
taskTotal: 0,
|
||
tasksTruncated: false,
|
||
scheduleEntryTotal: 0,
|
||
scheduleEntriesTruncated: false,
|
||
})
|
||
const modeFilter = ref('')
|
||
const statusFilter = ref('')
|
||
const offeringCollegeId = ref('')
|
||
const courseKeyword = ref('')
|
||
const classKeyword = ref('')
|
||
const teacherKeyword = ref('')
|
||
const taskKeyword = ref('')
|
||
|
||
const projectDialog = ref(false)
|
||
const editingProjectId = ref('')
|
||
const correctingPublishedProject = ref(false)
|
||
const projectForm = reactive({
|
||
teachingTaskIds: [] as string[],
|
||
scheduleEntryId: '',
|
||
code: '',
|
||
name: '',
|
||
projectNames: '',
|
||
nameMode: 'Sequence',
|
||
projectCount: 1,
|
||
arrangementMode: 'Centralized',
|
||
description: '',
|
||
requirements: '',
|
||
dates: [] as string[],
|
||
selectionTimes: [] as string[],
|
||
})
|
||
|
||
const batchRenameDialog = ref(false)
|
||
const batchRenameProjectIds = ref<string[]>([])
|
||
const batchRenameNames = ref('')
|
||
|
||
const sessionDialog = ref(false)
|
||
const selectedProject = ref<any>(null)
|
||
const sessionForm = reactive({
|
||
classroomId: '',
|
||
sessionDate: '',
|
||
startPeriod: undefined as number | undefined,
|
||
periodCount: 2,
|
||
capacity: 30,
|
||
notes: '',
|
||
instructorTeacherIds: [] as string[],
|
||
})
|
||
|
||
const batchSessionDialog = ref(false)
|
||
const batchSessionProjectIds = ref<string[]>([])
|
||
const batchSessionRows = ref<any[]>([])
|
||
|
||
const participantsDialog = ref(false)
|
||
const participantSession = ref<any>(null)
|
||
const participants = ref<any[]>([])
|
||
const participantsLoading = ref(false)
|
||
const proxyBookingDialog = ref(false)
|
||
const proxyBookingStudents = ref<any[]>([])
|
||
const proxyBookingLoading = ref(false)
|
||
const proxyBookingKeyword = ref('')
|
||
const proxyBookingStudentIds = ref<string[]>([])
|
||
const proxyBookingPage = ref(1)
|
||
const proxyBookingPageSize = 20
|
||
const proxyBookingTotal = ref(0)
|
||
|
||
const selectedTask = computed(() =>
|
||
options.tasks.find((task) => task.id === projectForm.teachingTaskIds[0]),
|
||
)
|
||
const selectedScheduleEntry = computed(() =>
|
||
options.scheduleEntries.find((entry) => entry.id === projectForm.scheduleEntryId),
|
||
)
|
||
const batchProjectOptions = computed(() =>
|
||
projects.value.filter((project) =>
|
||
project.status !== 'Closed' && project.arrangementMode === 'SelfScheduled'),
|
||
)
|
||
const taskGroups = computed(() => {
|
||
const groups = new Map<string, any>()
|
||
options.tasks.forEach((task) => {
|
||
const key = `${task.academicTermId}-${task.courseId}`
|
||
const group = groups.get(key) ?? {
|
||
key,
|
||
termName: task.termName,
|
||
courseCode: task.courseCode,
|
||
courseName: task.courseName,
|
||
tasks: [],
|
||
}
|
||
group.tasks.push(task)
|
||
groups.set(key, group)
|
||
})
|
||
return [...groups.values()]
|
||
})
|
||
const projectGroups = computed(() => {
|
||
const groups = new Map<string, any>()
|
||
projects.value.forEach((project) => {
|
||
const classKey = [...(project.classNames ?? [])].sort().join('|')
|
||
const key = `${project.academicTermId}-${project.courseCode}-${classKey}`
|
||
const group = groups.get(key) ?? {
|
||
key,
|
||
termName: project.termName,
|
||
courseCode: project.courseCode,
|
||
courseName: project.courseName,
|
||
classNames: project.classNames,
|
||
teacherNames: project.teacherNames,
|
||
taskNumbers: [],
|
||
projects: [],
|
||
}
|
||
if (!group.taskNumbers.includes(project.taskNumber)) group.taskNumbers.push(project.taskNumber)
|
||
group.projects.push(project)
|
||
groups.set(key, group)
|
||
})
|
||
return [...groups.values()]
|
||
})
|
||
const draftSelectedProjectIds = computed(() =>
|
||
selectedProjectIds.value.filter((id) =>
|
||
projects.value.some((project) => project.id === id && project.status === 'Draft')),
|
||
)
|
||
const batchRenameProjects = computed(() =>
|
||
projects.value.filter((project) => batchRenameProjectIds.value.includes(project.id)),
|
||
)
|
||
const allPageDraftSelected = computed(() => {
|
||
const ids = projects.value.filter((project) => project.status === 'Draft').map((project) => project.id)
|
||
return ids.length > 0 && ids.every((id) => selectedProjectIds.value.includes(id))
|
||
})
|
||
const activePeriods = computed(() =>
|
||
options.periods.filter((period) =>
|
||
!selectedProject.value
|
||
|| period.academicTermId === selectedProject.value.academicTermId,
|
||
),
|
||
)
|
||
const experimentClassrooms = computed(() => options.classrooms)
|
||
|
||
const modeMeta = computed<Record<string, { label: string; note: string }>>(() => ({
|
||
Centralized: {
|
||
label: t('experimentsScript.k0'),
|
||
note: t('experimentsScript.k1'),
|
||
},
|
||
SelfScheduled: {
|
||
label: t('experimentsScript.k2'),
|
||
note: t('experimentsScript.k3'),
|
||
},
|
||
}))
|
||
|
||
const statusLabels = computed<Record<string, string>>(() => ({
|
||
Draft: t('experimentsScript.k4'),
|
||
Published: t('experimentsScript.k5'),
|
||
Closed: t('experimentsScript.k6'),
|
||
}))
|
||
|
||
function resetProjectForm() {
|
||
editingProjectId.value = ''
|
||
correctingPublishedProject.value = false
|
||
Object.assign(projectForm, {
|
||
teachingTaskIds: [],
|
||
scheduleEntryId: '',
|
||
code: '',
|
||
name: '',
|
||
projectNames: '',
|
||
nameMode: 'Sequence',
|
||
projectCount: 1,
|
||
arrangementMode: 'Centralized',
|
||
description: '',
|
||
requirements: '',
|
||
dates: [],
|
||
selectionTimes: [],
|
||
})
|
||
}
|
||
|
||
function onTaskChange() {
|
||
const task = selectedTask.value
|
||
if (!task) return
|
||
projectForm.dates = [task.termStartDate, task.termEndDate]
|
||
}
|
||
|
||
function onScheduleEntryChange() {
|
||
const entry = selectedScheduleEntry.value
|
||
if (!entry) return
|
||
projectForm.teachingTaskIds = [entry.teachingTaskId]
|
||
onTaskChange()
|
||
}
|
||
|
||
function formatScheduleEntry(entry: any) {
|
||
const classes = entry.classNames?.join('、') || t('experimentsScript.k7')
|
||
return t('experimentsScript.entry', { code: entry.courseCode, course: entry.courseName, task: entry.taskNumber, classes, day: entry.dayOfWeek, start: entry.startPeriod, end: entry.startPeriod + entry.periodCount - 1, campus: entry.campusName, building: entry.buildingName, room: entry.classroomName })
|
||
}
|
||
|
||
function openCreateProject() {
|
||
resetProjectForm()
|
||
projectDialog.value = true
|
||
}
|
||
|
||
function openEditProject(project: any) {
|
||
editingProjectId.value = project.id
|
||
correctingPublishedProject.value = false
|
||
Object.assign(projectForm, {
|
||
teachingTaskIds: [project.teachingTaskId],
|
||
scheduleEntryId: project.scheduleEntryId ?? '',
|
||
code: project.code,
|
||
name: project.name,
|
||
projectNames: '',
|
||
nameMode: 'Sequence',
|
||
arrangementMode: project.arrangementMode,
|
||
description: project.description ?? '',
|
||
requirements: project.requirements ?? '',
|
||
dates: [project.startDate, project.endDate],
|
||
selectionTimes: project.selectionStartsAt && project.selectionEndsAt
|
||
? [project.selectionStartsAt, project.selectionEndsAt] : [],
|
||
})
|
||
projectDialog.value = true
|
||
}
|
||
|
||
function openCorrectPublishedProject(project: any) {
|
||
openEditProject(project)
|
||
correctingPublishedProject.value = true
|
||
}
|
||
|
||
function projectNameLines(value: string) {
|
||
return value.split(/\r?\n/).map((name) => name.trim()).filter(Boolean)
|
||
}
|
||
|
||
async function saveProject() {
|
||
const names = projectNameLines(projectForm.projectNames)
|
||
const hasValidName = correctingPublishedProject.value || editingProjectId.value
|
||
? !!projectForm.name.trim()
|
||
: projectForm.nameMode === 'InputNames'
|
||
? names.length > 0
|
||
: !!projectForm.name.trim()
|
||
if ((!correctingPublishedProject.value && !projectForm.teachingTaskIds.length) ||
|
||
(editingProjectId.value && projectForm.arrangementMode === 'Centralized' && !projectForm.scheduleEntryId) ||
|
||
!projectForm.code.trim()
|
||
|| !hasValidName || projectForm.dates.length !== 2
|
||
|| (projectForm.arrangementMode === 'SelfScheduled' && projectForm.selectionTimes.length !== 2)) {
|
||
ElMessage.warning(projectForm.arrangementMode === 'Centralized' && editingProjectId.value
|
||
? t('experimentsScript.k8')
|
||
: t('experimentsScript.k9'))
|
||
return
|
||
}
|
||
const payload = {
|
||
teachingTaskId: projectForm.teachingTaskIds[0],
|
||
scheduleEntryId: projectForm.scheduleEntryId || null,
|
||
code: projectForm.code,
|
||
name: projectForm.nameMode === 'InputNames' && !editingProjectId.value ? names[0] : projectForm.name,
|
||
projectCount: projectForm.arrangementMode === 'SelfScheduled'
|
||
? (projectForm.nameMode === 'InputNames' ? names.length : projectForm.projectCount)
|
||
: 1,
|
||
arrangementMode: projectForm.arrangementMode,
|
||
description: projectForm.description || null,
|
||
requirements: projectForm.requirements || null,
|
||
startDate: projectForm.dates[0],
|
||
endDate: projectForm.dates[1],
|
||
selectionStartsAt: projectForm.arrangementMode === 'SelfScheduled'
|
||
? projectForm.selectionTimes[0] || null : null,
|
||
selectionEndsAt: projectForm.arrangementMode === 'SelfScheduled'
|
||
? projectForm.selectionTimes[1] || null : null,
|
||
}
|
||
try {
|
||
if (correctingPublishedProject.value) {
|
||
await http.put(`/experiments/${editingProjectId.value}/published-details`, {
|
||
name: projectForm.name,
|
||
description: projectForm.description || null,
|
||
requirements: projectForm.requirements || null,
|
||
})
|
||
ElMessage.success(t('experimentsScript.k10'))
|
||
} else if (editingProjectId.value) {
|
||
await http.put(`/experiments/${editingProjectId.value}`, payload)
|
||
ElMessage.success(t('experimentsScript.k11'))
|
||
} else {
|
||
await http.post('/experiments/batch', {
|
||
...payload,
|
||
teachingTaskId: undefined,
|
||
teachingTaskIds: projectForm.teachingTaskIds,
|
||
names: projectForm.nameMode === 'InputNames' ? names : undefined,
|
||
generateSequentialNames: projectForm.nameMode === 'Sequence',
|
||
})
|
||
ElMessage.success(projectForm.arrangementMode === 'Centralized'
|
||
? t('experimentsScript.createdCentral', { count: projectForm.teachingTaskIds.length })
|
||
: t('experimentsScript.createdOpen', { tasks: projectForm.teachingTaskIds.length, projects: projectForm.teachingTaskIds.length * payload.projectCount }))
|
||
}
|
||
projectDialog.value = false
|
||
await load()
|
||
} catch (error) {
|
||
ElMessage.error(apiErrorMessage(error))
|
||
}
|
||
}
|
||
|
||
function openBatchSession() {
|
||
batchSessionProjectIds.value = []
|
||
batchSessionRows.value = []
|
||
batchSessionDialog.value = true
|
||
}
|
||
|
||
function syncBatchSessionRows() {
|
||
const existing = new Map<string, any[]>()
|
||
batchSessionRows.value.forEach((row) => {
|
||
const rows = existing.get(row.projectId) ?? []
|
||
rows.push(row)
|
||
existing.set(row.projectId, rows)
|
||
})
|
||
batchSessionRows.value = batchSessionProjectIds.value.flatMap((projectId) => {
|
||
const current = existing.get(projectId)
|
||
if (current?.length) return current
|
||
return [newBatchSessionRow(projectId)]
|
||
})
|
||
}
|
||
|
||
function newBatchSessionRow(projectId: string, source?: any) {
|
||
const project = projects.value.find((item) => item.id === projectId)
|
||
const firstPeriod = options.periods.find((item) =>
|
||
item.academicTermId === project?.academicTermId,
|
||
)
|
||
return {
|
||
rowKey: crypto.randomUUID(),
|
||
projectId,
|
||
classroomId: source?.classroomId ?? '',
|
||
sessionDate: source?.sessionDate ?? project?.startDate ?? '',
|
||
startPeriod: source?.startPeriod ?? firstPeriod?.periodNumber,
|
||
periodCount: source?.periodCount ?? 2,
|
||
capacity: source?.capacity ?? 30,
|
||
notes: '',
|
||
instructorTeacherIds: source?.instructorTeacherIds ? [...source.instructorTeacherIds] : [],
|
||
}
|
||
}
|
||
|
||
function addBatchSessionRow(projectId: string, source: any) {
|
||
batchSessionRows.value.push(newBatchSessionRow(projectId, source))
|
||
}
|
||
|
||
function removeBatchSessionRow(row: any) {
|
||
const sameProjectRows = batchSessionRows.value.filter((item) => item.projectId === row.projectId)
|
||
if (sameProjectRows.length === 1) {
|
||
batchSessionProjectIds.value = batchSessionProjectIds.value.filter((id) => id !== row.projectId)
|
||
}
|
||
batchSessionRows.value = batchSessionRows.value.filter((item) => item.rowKey !== row.rowKey)
|
||
}
|
||
|
||
function applyFirstBatchTime() {
|
||
const first = batchSessionRows.value[0]
|
||
if (!first) return
|
||
batchSessionRows.value.slice(1).forEach((row) => {
|
||
row.sessionDate = first.sessionDate
|
||
row.startPeriod = first.startPeriod
|
||
row.periodCount = first.periodCount
|
||
})
|
||
ElMessage.success(t('experimentsScript.k12'))
|
||
}
|
||
|
||
function batchProject(projectId: string) {
|
||
return projects.value.find((project) => project.id === projectId)
|
||
}
|
||
|
||
function periodsForProject(projectId: string) {
|
||
const project = batchProject(projectId)
|
||
return options.periods.filter((period) =>
|
||
period.academicTermId === project?.academicTermId,
|
||
)
|
||
}
|
||
|
||
async function saveBatchSessions() {
|
||
if (!batchSessionRows.value.length) {
|
||
ElMessage.warning(t('experimentsScript.k13'))
|
||
return
|
||
}
|
||
if (batchSessionRows.value.some((row) =>
|
||
!row.classroomId || !row.sessionDate || !row.startPeriod || !row.periodCount || !row.instructorTeacherIds?.length,
|
||
)) {
|
||
ElMessage.warning(t('experimentsScript.k14'))
|
||
return
|
||
}
|
||
try {
|
||
await http.post('/experiments/sessions/batch', {
|
||
items: batchSessionRows.value,
|
||
})
|
||
batchSessionDialog.value = false
|
||
ElMessage.success(t('experimentsScript.scheduled', { count: batchSessionRows.value.length }))
|
||
await load()
|
||
} catch (error) {
|
||
ElMessage.error(apiErrorMessage(error))
|
||
}
|
||
}
|
||
|
||
function openSession(project: any) {
|
||
selectedProject.value = project
|
||
const firstPeriod = options.periods.find((item) =>
|
||
item.academicTermId === project.academicTermId,
|
||
)
|
||
Object.assign(sessionForm, {
|
||
classroomId: '',
|
||
sessionDate: project.startDate,
|
||
startPeriod: firstPeriod?.periodNumber,
|
||
periodCount: 2,
|
||
capacity: 30,
|
||
notes: '',
|
||
instructorTeacherIds: [],
|
||
})
|
||
sessionDialog.value = true
|
||
}
|
||
|
||
async function saveSession() {
|
||
if (!selectedProject.value || !sessionForm.classroomId
|
||
|| !sessionForm.sessionDate || !sessionForm.startPeriod || !sessionForm.instructorTeacherIds.length) {
|
||
ElMessage.warning(t('experimentsScript.k15'))
|
||
return
|
||
}
|
||
try {
|
||
await http.post(`/experiments/${selectedProject.value.id}/sessions`, sessionForm)
|
||
sessionDialog.value = false
|
||
ElMessage.success(t('experimentsScript.k16'))
|
||
await load()
|
||
} catch (error) {
|
||
ElMessage.error(apiErrorMessage(error))
|
||
}
|
||
}
|
||
|
||
async function publishProject(project: any) {
|
||
try {
|
||
await ElMessageBox.confirm(
|
||
project.arrangementMode === 'Centralized'
|
||
? t('experimentsScript.k17')
|
||
: t('experimentsScript.k18'),
|
||
t('experimentsScript.publishTitle', { name: project.name }),
|
||
{ confirmButtonText: t('experimentsScript.k19'), cancelButtonText: t('experimentsScript.k20'), type: 'warning' },
|
||
)
|
||
await http.post(`/experiments/${project.id}/publish`)
|
||
ElMessage.success(t('experimentsScript.k21'))
|
||
await load()
|
||
} catch (error: any) {
|
||
if (error === 'cancel' || error === 'close') return
|
||
ElMessage.error(apiErrorMessage(error))
|
||
}
|
||
}
|
||
|
||
async function closeProject(project: any) {
|
||
try {
|
||
await ElMessageBox.confirm(
|
||
t('experimentsScript.k22'),
|
||
t('experimentsScript.closeTitle', { name: project.name }),
|
||
{ confirmButtonText: t('experimentsScript.k23'), cancelButtonText: t('experimentsScript.k24'), type: 'warning' },
|
||
)
|
||
await http.post(`/experiments/${project.id}/close`)
|
||
ElMessage.success(t('experimentsScript.k25'))
|
||
await load()
|
||
} catch (error: any) {
|
||
if (error === 'cancel' || error === 'close') return
|
||
ElMessage.error(apiErrorMessage(error))
|
||
}
|
||
}
|
||
|
||
async function deleteProject(project: any) {
|
||
try {
|
||
await ElMessageBox.confirm(
|
||
t('experimentsScript.k26'),
|
||
t('experimentsScript.deleteTitle', { name: project.name }),
|
||
{ confirmButtonText: t('experimentsScript.k27'), cancelButtonText: t('experimentsScript.k24'), type: 'error' },
|
||
)
|
||
await http.delete(`/experiments/${project.id}`)
|
||
ElMessage.success(t('experimentsScript.k28'))
|
||
await load()
|
||
} catch (error: any) {
|
||
if (error === 'cancel' || error === 'close') return
|
||
ElMessage.error(apiErrorMessage(error))
|
||
}
|
||
}
|
||
|
||
function instructorsForProject(projectId: string) {
|
||
return options.teachers.filter((teacher) => teacher.teachingTaskId === projectId
|
||
|| teacher.teachingTaskId === batchProject(projectId)?.teachingTaskId)
|
||
}
|
||
|
||
function instructorsForSelectedProject() {
|
||
return selectedProject.value ? instructorsForProject(selectedProject.value.id) : []
|
||
}
|
||
|
||
function openBatchRename() {
|
||
batchRenameProjectIds.value = projects.value
|
||
.filter((project) => draftSelectedProjectIds.value.includes(project.id))
|
||
.map((project) => project.id)
|
||
batchRenameNames.value = batchRenameProjects.value.map((project) => project.name).join('\n')
|
||
batchRenameDialog.value = true
|
||
}
|
||
|
||
async function saveBatchRename() {
|
||
const names = projectNameLines(batchRenameNames.value)
|
||
if (names.length !== batchRenameProjectIds.value.length) {
|
||
ElMessage.warning(t('experimentsScript.renameHelp', { count: batchRenameProjectIds.value.length }))
|
||
return
|
||
}
|
||
try {
|
||
await http.put('/experiments/batch/names', { projectIds: batchRenameProjectIds.value, names })
|
||
ElMessage.success(t('experimentsScript.k29'))
|
||
batchRenameDialog.value = false
|
||
await load()
|
||
} catch (error) {
|
||
ElMessage.error(apiErrorMessage(error))
|
||
}
|
||
}
|
||
|
||
function togglePageDraftSelection(value: unknown) {
|
||
const ids = projects.value.filter((project) => project.status === 'Draft').map((project) => project.id)
|
||
selectedProjectIds.value = Boolean(value)
|
||
? [...new Set([...selectedProjectIds.value, ...ids])]
|
||
: selectedProjectIds.value.filter((id) => !ids.includes(id))
|
||
}
|
||
|
||
function toggleProjectSelection(projectId: string, value: unknown) {
|
||
selectedProjectIds.value = Boolean(value)
|
||
? [...new Set([...selectedProjectIds.value, projectId])]
|
||
: selectedProjectIds.value.filter((id) => id !== projectId)
|
||
}
|
||
|
||
async function publishSelectedProjects() {
|
||
const ids = draftSelectedProjectIds.value
|
||
if (!ids.length) return
|
||
try {
|
||
await ElMessageBox.confirm(
|
||
t('experimentsScript.publishBatch', { count: ids.length }),
|
||
t('experimentsScript.k30'),
|
||
{ confirmButtonText: t('experimentsScript.k19'), cancelButtonText: t('experimentsScript.k24'), type: 'warning' },
|
||
)
|
||
const { data } = await http.post('/experiments/batch/publish', { projectIds: ids })
|
||
ElMessage.success(t('experimentsScript.publishJobs', { count: ids.length }))
|
||
selectedProjectIds.value = []
|
||
void pollPublishJob(data.jobId)
|
||
} catch (error: any) {
|
||
if (error === 'cancel' || error === 'close') return
|
||
ElMessage.error(apiErrorMessage(error))
|
||
}
|
||
}
|
||
|
||
async function pollPublishJob(jobId: string) {
|
||
try {
|
||
const { data } = await http.get(`/experiments/batch/publish-jobs/${jobId}`)
|
||
if (data.status === 'Succeeded') {
|
||
ElMessage.success(t('experimentsScript.k31'))
|
||
await load()
|
||
return
|
||
}
|
||
if (data.status === 'Failed') {
|
||
ElMessage.error(data.errorMessage || t('experimentsScript.k32'))
|
||
await load()
|
||
return
|
||
}
|
||
window.setTimeout(() => { void pollPublishJob(jobId) }, 1200)
|
||
} catch (error) {
|
||
ElMessage.error(apiErrorMessage(error))
|
||
}
|
||
}
|
||
|
||
async function deleteSelectedProjects() {
|
||
const ids = draftSelectedProjectIds.value
|
||
if (!ids.length) return
|
||
try {
|
||
await ElMessageBox.confirm(
|
||
t('experimentsScript.deleteBatch', { count: ids.length }),
|
||
t('experimentsScript.k33'),
|
||
{ confirmButtonText: t('experimentsScript.k27'), cancelButtonText: t('experimentsScript.k24'), type: 'error' },
|
||
)
|
||
await http.delete('/experiments/batch', { data: { projectIds: ids } })
|
||
ElMessage.success(t('experimentsScript.deleted', { count: ids.length }))
|
||
selectedProjectIds.value = []
|
||
await load()
|
||
} catch (error: any) {
|
||
if (error === 'cancel' || error === 'close') return
|
||
ElMessage.error(apiErrorMessage(error))
|
||
}
|
||
}
|
||
|
||
async function cancelSession(project: any, session: any) {
|
||
try {
|
||
await ElMessageBox.confirm(
|
||
project.status === 'Draft'
|
||
? t('experimentsScript.k34')
|
||
: t('experimentsScript.k35'),
|
||
t('experimentsScript.sessionTitle', { action: project.status === 'Draft' ? t('experimentsScript.k27') : t('experimentsScript.k24'), time: formatSessionTime(session) }),
|
||
{ confirmButtonText: t('experimentsScript.k36'), cancelButtonText: t('experimentsScript.k37'), type: 'warning' },
|
||
)
|
||
await http.delete(`/experiments/sessions/${session.id}`)
|
||
ElMessage.success(project.status === 'Draft' ? t('experimentsScript.k38') : t('experimentsScript.k39'))
|
||
await load()
|
||
} catch (error: any) {
|
||
if (error === 'cancel' || error === 'close') return
|
||
ElMessage.error(apiErrorMessage(error))
|
||
}
|
||
}
|
||
|
||
async function showParticipants(project: any, session: any) {
|
||
participantSession.value = { ...session, project }
|
||
participantsDialog.value = true
|
||
participantsLoading.value = true
|
||
try {
|
||
participants.value = (
|
||
await http.get(`/experiments/sessions/${session.id}/participants`)
|
||
).data
|
||
} catch (error) {
|
||
participants.value = []
|
||
ElMessage.error(apiErrorMessage(error))
|
||
} finally {
|
||
participantsLoading.value = false
|
||
}
|
||
}
|
||
|
||
async function loadProxyBookingStudents(page = proxyBookingPage.value) {
|
||
if (!participantSession.value) return
|
||
proxyBookingPage.value = page
|
||
proxyBookingStudentIds.value = []
|
||
proxyBookingLoading.value = true
|
||
try {
|
||
const { data } = await http.get(
|
||
`/experiments/sessions/${participantSession.value.id}/eligible-students`,
|
||
{ params: { keyword: proxyBookingKeyword.value || undefined, page, pageSize: proxyBookingPageSize } },
|
||
)
|
||
proxyBookingStudents.value = data.items
|
||
proxyBookingTotal.value = data.total
|
||
} catch (error) {
|
||
proxyBookingStudents.value = []
|
||
ElMessage.error(apiErrorMessage(error))
|
||
} finally {
|
||
proxyBookingLoading.value = false
|
||
}
|
||
}
|
||
|
||
async function openProxyBooking() {
|
||
proxyBookingStudentIds.value = []
|
||
proxyBookingKeyword.value = ''
|
||
proxyBookingPage.value = 1
|
||
proxyBookingDialog.value = true
|
||
await loadProxyBookingStudents()
|
||
}
|
||
|
||
async function saveProxyBooking() {
|
||
if (!participantSession.value || !proxyBookingStudentIds.value.length) {
|
||
ElMessage.warning(t('experimentsScript.k40'))
|
||
return
|
||
}
|
||
try {
|
||
const { data } = await http.post(`/experiments/sessions/${participantSession.value.id}/proxy-bookings/batch`, {
|
||
studentIds: proxyBookingStudentIds.value,
|
||
})
|
||
ElMessage.success(t('experimentsScript.proxy', { count: data.bookedCount }))
|
||
proxyBookingDialog.value = false
|
||
await showParticipants(participantSession.value.project, participantSession.value)
|
||
} catch (error) {
|
||
ElMessage.error(apiErrorMessage(error))
|
||
}
|
||
}
|
||
|
||
async function book(project: any, session: any) {
|
||
try {
|
||
await ElMessageBox.confirm(
|
||
`${formatSessionTime(session)} · ${session.campusName} ${session.buildingName} ${session.classroomName}`,
|
||
t('experimentsScript.bookTitle', { name: project.name }),
|
||
{ confirmButtonText: t('experimentsScript.k41'), cancelButtonText: t('experimentsScript.k42'), type: 'info' },
|
||
)
|
||
await http.post(`/experiments/sessions/${session.id}/book`)
|
||
ElMessage.success(t('experimentsScript.k43'))
|
||
await load()
|
||
} catch (error: any) {
|
||
if (error === 'cancel' || error === 'close') return
|
||
ElMessage.error(apiErrorMessage(error))
|
||
}
|
||
}
|
||
|
||
async function cancelBooking(project: any) {
|
||
if (!project.myBooking) return
|
||
try {
|
||
await ElMessageBox.confirm(
|
||
t('experimentsScript.k44'),
|
||
t('experimentsScript.cancelTitle', { name: project.name }),
|
||
{ confirmButtonText: t('experimentsScript.k45'), cancelButtonText: t('experimentsScript.k46'), type: 'warning' },
|
||
)
|
||
await http.delete(`/experiments/bookings/${project.myBooking.id}`)
|
||
ElMessage.success(t('experimentsScript.k47'))
|
||
await load()
|
||
} catch (error: any) {
|
||
if (error === 'cancel' || error === 'close') return
|
||
ElMessage.error(apiErrorMessage(error))
|
||
}
|
||
}
|
||
|
||
function formatSessionTime(session: any) {
|
||
return t('experimentsScript.sessionTime', { date: session.sessionDate, start: session.startPeriod, end: session.startPeriod + session.periodCount - 1 })
|
||
}
|
||
|
||
function selectedSession(project: any) {
|
||
return project.sessions.find((session: any) =>
|
||
session.id === project.myBooking?.experimentSessionId,
|
||
)
|
||
}
|
||
|
||
function sessionTagType(session: any) {
|
||
const remaining = session.capacity - session.reservedCount
|
||
if (remaining <= 0) return 'danger'
|
||
if (remaining <= Math.max(2, Math.floor(session.capacity * 0.2))) return 'warning'
|
||
return 'success'
|
||
}
|
||
|
||
async function loadOptions() {
|
||
if (isStudent.value) return
|
||
try {
|
||
const { data } = await http.get('/experiments/options', {
|
||
params: {
|
||
academicTermId: termId.value || undefined,
|
||
offeringCollegeId: offeringCollegeId.value || undefined,
|
||
courseKeyword: courseKeyword.value.trim() || undefined,
|
||
},
|
||
})
|
||
options.tasks = data.tasks
|
||
options.taskTotal = data.taskTotal
|
||
options.tasksTruncated = data.tasksTruncated
|
||
options.colleges = data.colleges
|
||
options.scheduleEntries = data.scheduleEntries
|
||
options.scheduleEntryTotal = data.scheduleEntryTotal
|
||
options.scheduleEntriesTruncated = data.scheduleEntriesTruncated
|
||
options.classrooms = data.classrooms
|
||
options.teachers = data.teachers
|
||
options.periods = data.periods
|
||
} catch (error) {
|
||
options.tasks = []
|
||
options.colleges = []
|
||
options.classrooms = []
|
||
options.teachers = []
|
||
options.periods = []
|
||
ElMessage.error(apiErrorMessage(error))
|
||
}
|
||
}
|
||
|
||
async function load() {
|
||
loading.value = true
|
||
try {
|
||
if (isStudent.value) {
|
||
projects.value = (await http.get('/experiments/student', {
|
||
params: { academicTermId: termId.value || undefined },
|
||
})).data
|
||
total.value = projects.value.length
|
||
} else {
|
||
const { data } = await http.get('/experiments/management', {
|
||
params: {
|
||
academicTermId: termId.value || undefined,
|
||
arrangementMode: modeFilter.value || undefined,
|
||
status: statusFilter.value || undefined,
|
||
offeringCollegeId: offeringCollegeId.value || undefined,
|
||
courseKeyword: courseKeyword.value.trim() || undefined,
|
||
classKeyword: classKeyword.value.trim() || undefined,
|
||
teacherKeyword: teacherKeyword.value.trim() || undefined,
|
||
taskKeyword: taskKeyword.value.trim() || undefined,
|
||
page: page.value,
|
||
pageSize: pageSize.value,
|
||
},
|
||
})
|
||
projects.value = data.items
|
||
total.value = data.total
|
||
}
|
||
} catch (error) {
|
||
projects.value = []
|
||
total.value = 0
|
||
ElMessage.error(apiErrorMessage(error))
|
||
} finally {
|
||
loading.value = false
|
||
}
|
||
}
|
||
|
||
async function changeTerm() {
|
||
page.value = 1
|
||
selectedProjectIds.value = []
|
||
await loadOptions()
|
||
await load()
|
||
}
|
||
|
||
async function searchTaskOptions() {
|
||
page.value = 1
|
||
selectedProjectIds.value = []
|
||
await loadOptions()
|
||
await load()
|
||
}
|
||
|
||
async function changePage(nextPage: number) {
|
||
page.value = nextPage
|
||
selectedProjectIds.value = []
|
||
await load()
|
||
}
|
||
|
||
async function changePageSize(size: number) {
|
||
pageSize.value = size
|
||
await changePage(1)
|
||
}
|
||
|
||
onMounted(async () => {
|
||
try {
|
||
terms.value = (await http.get('/base-data/terms')).data
|
||
termId.value = defaultAcademicTermId(terms.value) ?? ''
|
||
} catch (error) {
|
||
ElMessage.error(apiErrorMessage(error))
|
||
}
|
||
await loadOptions()
|
||
await load()
|
||
})
|
||
</script>
|
||
|
||
<template>
|
||
<div class="page-stack experiment-page">
|
||
<section class="page-intro experiment-intro">
|
||
<div>
|
||
<span class="section-kicker">LABORATORY OPERATIONS</span>
|
||
<h2>{{ isStudent ? t('experimentsDynamic.myLabs') : t('experimentsDynamic.manage') }}</h2>
|
||
<p v-if="isStudent">{{ t('experimentsTemplate.k0') }}</p>
|
||
<p v-else>{{ t('experimentsTemplate.k1') }}</p>
|
||
</div>
|
||
<div class="intro-actions">
|
||
<el-button v-if="!isStudent" :icon="Calendar" @click="openBatchSession">
|
||
{{ t('experimentsTemplate.k2') }}
|
||
</el-button>
|
||
<el-button v-if="!isStudent" type="primary" :icon="Plus" @click="openCreateProject">
|
||
{{ t('experimentsTemplate.k3') }}
|
||
</el-button>
|
||
<el-button :icon="Refresh" @click="load">{{ t('businessLabels.refresh') }}</el-button>
|
||
</div>
|
||
</section>
|
||
|
||
<section v-if="!isStudent" class="lab-rail" aria-:label="t('experimentsTemplate.k4')">
|
||
<article class="rail-lane centralized">
|
||
<span class="rail-code">{{ t('experimentsTemplate.k5') }}</span>
|
||
<b>{{ t('experimentsTemplate.k6') }}</b>
|
||
<p>{{ t('experimentsTemplate.k7') }}</p>
|
||
</article>
|
||
<div class="rail-switch" aria-hidden="true"><i /><i /></div>
|
||
<article class="rail-lane flexible">
|
||
<span class="rail-code">{{ t('experimentsTemplate.k8') }}</span>
|
||
<b>{{ t('experimentsTemplate.k9') }}</b>
|
||
<p>{{ t('experimentsTemplate.k10') }}</p>
|
||
</article>
|
||
</section>
|
||
|
||
<section class="experiment-toolbar">
|
||
<el-select v-model="termId" clearable :placeholder="t('businessLabels.allTerms')" @change="changeTerm">
|
||
<el-option
|
||
v-for="term in terms"
|
||
:key="term.id"
|
||
:label="academicTermLabel(term)"
|
||
:value="term.id"
|
||
:class="academicTermOptionClass(term)"
|
||
/>
|
||
</el-select>
|
||
<template v-if="!isStudent">
|
||
<el-select v-model="offeringCollegeId" clearable filterable :placeholder="t('courses.college')" @change="searchTaskOptions">
|
||
<el-option v-for="college in options.colleges" :key="college.collegeId" :label="college.collegeName" :value="college.collegeId" />
|
||
</el-select>
|
||
<el-input v-model="courseKeyword" clearable :placeholder="t('experimentsTemplate.k11')" @keyup.enter="searchTaskOptions" @clear="searchTaskOptions" />
|
||
<el-input v-model="classKeyword" clearable :placeholder="t('batchBusiness.k3')" @keyup.enter="searchTaskOptions" @clear="searchTaskOptions" />
|
||
<el-input v-model="teacherKeyword" clearable :placeholder="t('batchBusiness.k2')" @keyup.enter="searchTaskOptions" @clear="searchTaskOptions" />
|
||
<el-input v-model="taskKeyword" clearable :placeholder="t('experimentsTemplate.k12')" @keyup.enter="searchTaskOptions" @clear="searchTaskOptions" />
|
||
<el-select v-model="modeFilter" clearable :placeholder="t('experimentsTemplate.k13')" @change="load">
|
||
<el-option :label="t('experimentsTemplate.k14')" value="Centralized" />
|
||
<el-option :label="t('experimentsTemplate.k15')" value="SelfScheduled" />
|
||
</el-select>
|
||
<el-select v-model="statusFilter" clearable :placeholder="t('businessLabels.allStatus')" @change="load">
|
||
<el-option :label="t('businessLabels.draft')" value="Draft" />
|
||
<el-option :label="t('evaluationBatch.k14')" value="Published" />
|
||
<el-option :label="t('graduationClearance.closed')" value="Closed" />
|
||
</el-select>
|
||
</template>
|
||
<span class="result-note">{{ isStudent ? t('experimentsDynamic.studentCount', { courses: projectGroups.length, projects: total }) : t('experimentsDynamic.classCount', { count: total }) }}</span>
|
||
</section>
|
||
|
||
<section v-if="!isStudent" class="experiment-batch-bar">
|
||
<el-checkbox :model-value="allPageDraftSelected" :indeterminate="!!draftSelectedProjectIds.length && !allPageDraftSelected" @change="togglePageDraftSelection">
|
||
{{ t('experimentsTemplate.k16') }}
|
||
</el-checkbox>
|
||
<span>{{ t('experimentsDynamic.selectedDrafts', { count: draftSelectedProjectIds.length }) }}</span>
|
||
<el-button size="small" :disabled="!draftSelectedProjectIds.length" @click="openBatchRename">{{ t('experimentsTemplate.k17') }}</el-button>
|
||
<el-button size="small" type="primary" :disabled="!draftSelectedProjectIds.length" @click="publishSelectedProjects">{{ t('experimentsTemplate.k18') }}</el-button>
|
||
<el-button size="small" type="danger" plain :disabled="!draftSelectedProjectIds.length" @click="deleteSelectedProjects">{{ t('experimentsTemplate.k19') }}</el-button>
|
||
</section>
|
||
|
||
<section v-loading="loading" class="project-list">
|
||
<section v-for="group in projectGroups" :key="group.key" class="project-group">
|
||
<header class="project-group-head">
|
||
<div>
|
||
<span>{{ group.termName }}</span>
|
||
<h3>{{ group.courseCode }} · {{ group.courseName }}</h3>
|
||
</div>
|
||
<div class="project-group-task">
|
||
<b>{{ group.taskNumbers.join('、') }}</b>
|
||
<span>{{ group.classNames?.join('、') || t('experimentsDynamic.students') }}</span>
|
||
</div>
|
||
</header>
|
||
<div class="project-group-projects">
|
||
<el-table v-if="!isStudent" :data="group.projects" class="project-table" size="small">
|
||
<el-table-column width="46" align="center">
|
||
<template #default="{ row }">
|
||
<el-checkbox
|
||
v-if="row.status === 'Draft'"
|
||
:model-value="selectedProjectIds.includes(row.id)"
|
||
@change="toggleProjectSelection(row.id, $event)"
|
||
aria-:label="t('experimentsTemplate.k20')"
|
||
/>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column :label="t('batchBusiness.k38')" min-width="220">
|
||
<template #default="{ row }">
|
||
<div class="table-project-name">
|
||
<b>{{ row.code }} · {{ row.name }}</b>
|
||
<small v-if="row.description">{{ row.description }}</small>
|
||
</div>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column :label="t('experimentsTemplate.k21')" min-width="280">
|
||
<template #default="{ row }">
|
||
<div v-if="row.arrangementMode === 'Centralized' && row.scheduleEntry" class="table-schedule">
|
||
<b>{{ t('experimentsDynamic.schedule', { week: row.scheduleEntry.projectWeek ?? `${row.scheduleEntry.startWeek}–${row.scheduleEntry.endWeek}`, day: row.scheduleEntry.dayOfWeek, start: row.scheduleEntry.startPeriod, end: row.scheduleEntry.startPeriod + row.scheduleEntry.periodCount - 1 }) }}</b>
|
||
<small>{{ row.scheduleEntry.campusName }} · {{ row.scheduleEntry.buildingName }} {{ row.scheduleEntry.classroomName }}</small>
|
||
</div>
|
||
<div v-else-if="row.sessions.length" class="table-schedule">
|
||
<b>{{ t('experimentsDynamic.openSessions', { count: row.sessions.length }) }}</b>
|
||
<small>{{ row.sessions.map((session: any) => formatSessionTime(session)).join(';') }}</small>
|
||
<el-popover placement="bottom" :width="520" trigger="click">
|
||
<template #reference><el-button size="small" text :icon="User">{{ t('experimentsTemplate.k22') }}</el-button></template>
|
||
<div class="student-session-menu">
|
||
<div v-for="session in row.sessions" :key="session.id" class="student-session-option">
|
||
<div><b>{{ formatSessionTime(session) }}</b><span>{{ t('experimentsDynamic.instructor', { campus: session.campusName, building: session.buildingName, room: session.classroomName, teachers: session.instructorNames?.join('、') || t('experimentsDynamic.unassigned') }) }}</span></div>
|
||
<el-button v-if="session.canManage" size="small" text @click="showParticipants(row, session)">{{ t('experimentsTemplate.k23') }}</el-button>
|
||
<el-button v-if="session.canManage && session.status !== 'Cancelled'" size="small" text type="danger" :disabled="row.teachingTaskStatus !== 'Published'" @click="cancelSession(row, session)">{{ row.status === 'Draft' ? t('baseData.delete') : t('classroomReservation.cancel') }}</el-button>
|
||
</div>
|
||
</div>
|
||
</el-popover>
|
||
</div>
|
||
<span v-else class="table-muted">{{ t('experimentsTemplate.k24') }}</span>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column :label="t('experimentsTemplate.k25')" width="100" align="center">
|
||
<template #default="{ row }"><el-tag :type="row.arrangementMode === 'Centralized' ? 'primary' : 'success'" effect="plain">{{ modeMeta[row.arrangementMode].label }}</el-tag></template>
|
||
</el-table-column>
|
||
<el-table-column :label="t('businessLabels.status')" width="88" align="center">
|
||
<template #default="{ row }"><el-tag :type="row.status === 'Published' ? 'success' : row.status === 'Closed' ? 'info' : 'warning'">{{ statusLabels[row.status] }}</el-tag></template>
|
||
</el-table-column>
|
||
<el-table-column :label="t('businessLabels.actions')" width="244" fixed="right" align="right">
|
||
<template #default="{ row }">
|
||
<template v-if="row.status === 'Draft'">
|
||
<el-button size="small" text :disabled="row.teachingTaskStatus !== 'Published'" @click="openEditProject(row)">{{ t('businessLabels.edit') }}</el-button>
|
||
<el-button size="small" text type="danger" :disabled="row.teachingTaskStatus !== 'Published'" @click="deleteProject(row)">{{ t('businessLabels.delete') }}</el-button>
|
||
<el-button
|
||
size="small"
|
||
type="primary"
|
||
:disabled="row.teachingTaskStatus !== 'Published' || (row.arrangementMode === 'Centralized' ? !row.scheduleEntry : !row.sessions.some((item: any) => item.status !== 'Cancelled'))"
|
||
@click="publishProject(row)"
|
||
>{{ t('businessLabels.publish') }}</el-button>
|
||
</template>
|
||
<template v-else-if="row.status === 'Published'">
|
||
<el-button size="small" text :disabled="row.teachingTaskStatus !== 'Published'" @click="openCorrectPublishedProject(row)">{{ t('experimentsTemplate.k26') }}</el-button>
|
||
<el-button size="small" text :disabled="row.teachingTaskStatus !== 'Published'" @click="closeProject(row)">{{ t('experimentsTemplate.k27') }}</el-button>
|
||
</template>
|
||
<el-button
|
||
v-if="row.status !== 'Closed' && row.arrangementMode === 'SelfScheduled'"
|
||
size="small"
|
||
text
|
||
type="primary"
|
||
@click="openSession(row)"
|
||
>{{ t('experimentsTemplate.k28') }}</el-button>
|
||
</template>
|
||
</el-table-column>
|
||
</el-table>
|
||
<el-table v-else :data="group.projects" class="project-table student-project-table desktop-project-table" size="small">
|
||
<el-table-column type="expand" width="44">
|
||
<template #default="{ row }">
|
||
<div class="student-project-detail">
|
||
<p v-if="row.description"><b>{{ t('campusRegistration.projectDescription') }}</b>{{ row.description }}</p>
|
||
<p v-if="row.requirements"><b>{{ t('experimentsTemplate.k29') }}</b>{{ row.requirements }}</p>
|
||
<p><b>{{ t('experimentsTemplate.k30') }}</b>{{ row.startDate }} — {{ row.endDate }}</p>
|
||
<p><b>{{ t('batchBusiness.k2') }}</b>{{ row.teacherNames.join('、') || t('experimentsDynamic.pending') }}</p>
|
||
</div>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column :label="t('batchBusiness.k38')" min-width="210">
|
||
<template #default="{ row }">
|
||
<div class="table-project-name">
|
||
<b>{{ row.code }} · {{ row.name }}</b>
|
||
<small>{{ row.description || modeMeta[row.arrangementMode].note }}</small>
|
||
</div>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column :label="t('attendanceBatch.k123')" min-width="300">
|
||
<template #default="{ row }">
|
||
<div v-if="row.arrangementMode === 'Centralized' && row.scheduleEntry" class="table-schedule">
|
||
<b>{{ t('experimentsDynamic.schedule', { week: row.scheduleEntry.projectWeek ?? `${row.scheduleEntry.startWeek}–${row.scheduleEntry.endWeek}`, day: row.scheduleEntry.dayOfWeek, start: row.scheduleEntry.startPeriod, end: row.scheduleEntry.startPeriod + row.scheduleEntry.periodCount - 1 }) }}</b>
|
||
<small>{{ row.scheduleEntry.campusName }} · {{ row.scheduleEntry.buildingName }} {{ row.scheduleEntry.classroomName }}</small>
|
||
</div>
|
||
<div v-else-if="row.myBooking && selectedSession(row)" class="table-schedule is-booked">
|
||
<b>{{ formatSessionTime(selectedSession(row)) }}</b>
|
||
<small>{{ selectedSession(row).campusName }} · {{ selectedSession(row).buildingName }} {{ selectedSession(row).classroomName }}</small>
|
||
</div>
|
||
<div v-else-if="row.sessions.length" class="table-schedule">
|
||
<b>{{ t('experimentsDynamic.availableSessions', { count: row.sessions.length }) }}</b>
|
||
<small>{{ t('experimentsTemplate.k31') }}</small>
|
||
</div>
|
||
<span v-else class="table-muted">{{ t('experimentsTemplate.k32') }}</span>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column :label="t('experimentsTemplate.k25')" width="100" align="center">
|
||
<template #default="{ row }"><el-tag :type="row.arrangementMode === 'Centralized' ? 'primary' : 'success'" effect="plain" size="small">{{ modeMeta[row.arrangementMode].label }}</el-tag></template>
|
||
</el-table-column>
|
||
<el-table-column :label="t('businessLabels.status')" width="88" align="center">
|
||
<template #default="{ row }"><el-tag :type="row.status === 'Published' ? 'success' : 'info'" size="small">{{ statusLabels[row.status] }}</el-tag></template>
|
||
</el-table-column>
|
||
<el-table-column :label="t('experimentsTemplate.k33')" width="190" fixed="right" align="right">
|
||
<template #default="{ row }">
|
||
<template v-if="row.arrangementMode === 'SelfScheduled'">
|
||
<el-popover placement="bottom-end" :width="540" trigger="click">
|
||
<template #reference>
|
||
<el-button size="small" :type="row.myBooking ? 'success' : 'primary'" plain>
|
||
{{ row.myBooking ? t('experimentsDynamic.viewSession') : t('experimentsDynamic.selectSession') }}
|
||
</el-button>
|
||
</template>
|
||
<div class="student-session-menu">
|
||
<header><b>{{ row.code }} · {{ row.name }}</b><span>{{ t('experimentsTemplate.k34') }}</span></header>
|
||
<div v-for="session in row.sessions" :key="session.id" class="student-session-option" :class="{ 'is-selected': row.myBooking?.experimentSessionId === session.id }">
|
||
<div>
|
||
<b>{{ formatSessionTime(session) }}</b>
|
||
<span>{{ t('experimentsDynamic.instructor', { campus: session.campusName, building: session.buildingName, room: session.classroomName, teachers: session.instructorNames?.join('、') || t('experimentsDynamic.unassigned') }) }}</span>
|
||
</div>
|
||
<el-tag :type="sessionTagType(session)" size="small" effect="plain">{{ t('experimentsDynamic.remaining', { remaining: session.remainingCount, capacity: session.capacity }) }}</el-tag>
|
||
<el-button v-if="row.myBooking?.experimentSessionId === session.id" size="small" type="success" :icon="Check" disabled>{{ t('venueDisplay.reserved') }}</el-button>
|
||
<el-button v-else size="small" type="primary" plain :disabled="row.status !== 'Published' || row.teachingTaskStatus !== 'Published' || !!row.myBooking || session.remainingCount <= 0" @click="book(row, session)">{{ t('experimentsTemplate.k35') }}</el-button>
|
||
</div>
|
||
<el-empty v-if="!row.sessions.length" :image-size="42" :description="t('experimentsTemplate.k36')" />
|
||
</div>
|
||
</el-popover>
|
||
<el-button v-if="row.myBooking && row.status === 'Published' && row.teachingTaskStatus === 'Published'" size="small" text type="danger" @click="cancelBooking(row)">{{ t('businessLabels.cancel') }}</el-button>
|
||
</template>
|
||
<span v-else class="table-muted">{{ t('experimentsTemplate.k37') }}</span>
|
||
</template>
|
||
</el-table-column>
|
||
</el-table>
|
||
<div v-if="isStudent" class="mobile-project-cards">
|
||
<article v-for="row in group.projects" :key="row.id" class="mobile-project-card">
|
||
<header>
|
||
<div>
|
||
<span>{{ row.code }}</span>
|
||
<h4>{{ row.name }}</h4>
|
||
</div>
|
||
<el-tag :type="row.arrangementMode === 'Centralized' ? 'primary' : 'success'" size="small" effect="plain">
|
||
{{ modeMeta[row.arrangementMode].label }}
|
||
</el-tag>
|
||
</header>
|
||
<p>{{ row.description || modeMeta[row.arrangementMode].note }}</p>
|
||
<div class="mobile-project-arrangement">
|
||
<template v-if="row.arrangementMode === 'Centralized' && row.scheduleEntry">
|
||
<b>{{ t('experimentsTemplate.k38') }}</b>
|
||
<span>{{ t('experimentsDynamic.schedule', { week: row.scheduleEntry.projectWeek ?? `${row.scheduleEntry.startWeek}–${row.scheduleEntry.endWeek}`, day: row.scheduleEntry.dayOfWeek, start: row.scheduleEntry.startPeriod, end: row.scheduleEntry.startPeriod + row.scheduleEntry.periodCount - 1 }) }}</span>
|
||
<small>{{ row.scheduleEntry.campusName }} · {{ row.scheduleEntry.buildingName }} {{ row.scheduleEntry.classroomName }}</small>
|
||
</template>
|
||
<template v-else-if="row.arrangementMode === 'SelfScheduled'">
|
||
<b>{{ row.myBooking ? t('experimentsDynamic.bookedSession') : t('experimentsDynamic.selectLabSession') }}</b>
|
||
<div v-if="row.sessions.length" class="mobile-session-list">
|
||
<article v-for="session in row.sessions" :key="session.id" :class="{ 'is-selected': row.myBooking?.experimentSessionId === session.id }">
|
||
<div>
|
||
<strong>{{ formatSessionTime(session) }}</strong>
|
||
<small>{{ session.campusName }} · {{ session.buildingName }} {{ session.classroomName }}</small>
|
||
</div>
|
||
<el-tag :type="sessionTagType(session)" size="small" effect="plain">{{ t('experimentsDynamic.remaining', { remaining: session.remainingCount, capacity: session.capacity }) }}</el-tag>
|
||
<el-button v-if="row.myBooking?.experimentSessionId === session.id" size="small" type="success" disabled>{{ t('venueDisplay.reserved') }}</el-button>
|
||
<el-button v-else size="small" type="primary" plain :disabled="row.status !== 'Published' || row.teachingTaskStatus !== 'Published' || !!row.myBooking || session.remainingCount <= 0" @click="book(row, session)">{{ t('experimentsTemplate.k35') }}</el-button>
|
||
</article>
|
||
</div>
|
||
<span v-else class="table-muted">{{ t('experimentsTemplate.k36') }}</span>
|
||
<el-button v-if="row.myBooking && row.status === 'Published' && row.teachingTaskStatus === 'Published'" class="mobile-cancel-booking" size="small" text type="danger" @click="cancelBooking(row)">{{ t('classroomReservation.cancelReservation') }}</el-button>
|
||
</template>
|
||
</div>
|
||
</article>
|
||
</div>
|
||
</div>
|
||
</section>
|
||
|
||
<el-empty
|
||
v-if="!loading && !projects.length"
|
||
:description="isStudent ? t('experimentsDynamic.noPublished') : t('experimentsDynamic.noMatches')"
|
||
>
|
||
<el-button v-if="!isStudent" type="primary" @click="openCreateProject">
|
||
{{ t('experimentsTemplate.k39') }}
|
||
</el-button>
|
||
</el-empty>
|
||
</section>
|
||
|
||
<el-pagination
|
||
v-if="!isStudent && total > pageSize"
|
||
class="experiment-pagination"
|
||
background
|
||
layout="total, sizes, prev, pager, next"
|
||
:current-page="page"
|
||
:page-size="pageSize"
|
||
:page-sizes="[10, 20, 50, 100]"
|
||
:total="total"
|
||
@current-change="changePage"
|
||
@size-change="changePageSize"
|
||
/>
|
||
|
||
<el-dialog
|
||
v-model="projectDialog"
|
||
:title="correctingPublishedProject ? t('experimentsDynamic.correctProject') : editingProjectId ? t('experimentsDynamic.editProject') : t('experimentsDynamic.bulkTasks')"
|
||
width="720px"
|
||
top="5vh"
|
||
>
|
||
<el-form label-position="top" class="experiment-form">
|
||
<el-alert
|
||
v-if="correctingPublishedProject"
|
||
:title="t('experimentsTemplate.k40')"
|
||
type="info"
|
||
:closable="false"
|
||
/>
|
||
<div class="form-section">
|
||
<header><span>PROJECT</span><b>{{ t('experimentsTemplate.k41') }}</b></header>
|
||
<el-alert v-if="options.tasksTruncated || options.scheduleEntriesTruncated" type="warning" :closable="false" show-icon :title="t('experimentsTemplate.k42')" />
|
||
<el-form-item v-if="editingProjectId && projectForm.arrangementMode === 'Centralized'" :label="t('experimentsTemplate.k43')" required>
|
||
<el-select v-model="projectForm.scheduleEntryId" filterable :disabled="!!editingProjectId" :placeholder="t('experimentsTemplate.k44')" @change="onScheduleEntryChange">
|
||
<el-option
|
||
v-for="entry in options.scheduleEntries"
|
||
:key="entry.id"
|
||
:label="formatScheduleEntry(entry)"
|
||
:value="entry.id"
|
||
/>
|
||
</el-select>
|
||
<small class="form-help">{{ t('experimentsTemplate.k45') }}</small>
|
||
</el-form-item>
|
||
<el-form-item v-else :label="editingProjectId ? t('experimentsDynamic.task') : t('experimentsDynamic.classes')" required>
|
||
<el-select
|
||
v-if="editingProjectId"
|
||
v-model="projectForm.teachingTaskIds"
|
||
filterable
|
||
disabled
|
||
:placeholder="t('experimentsTemplate.k46')"
|
||
@change="onTaskChange"
|
||
>
|
||
<el-option
|
||
v-for="task in options.tasks"
|
||
:key="task.id"
|
||
:label="`${task.courseCode} · ${task.courseName} · ${task.taskNumber}`"
|
||
:value="task.id"
|
||
/>
|
||
</el-select>
|
||
<el-checkbox-group
|
||
v-else
|
||
v-model="projectForm.teachingTaskIds"
|
||
class="grouped-task-picker"
|
||
@change="onTaskChange"
|
||
>
|
||
<div class="task-option-filters">
|
||
<el-select v-model="offeringCollegeId" clearable filterable :placeholder="t('courses.college')" @change="searchTaskOptions">
|
||
<el-option v-for="college in options.colleges" :key="college.collegeId" :label="college.collegeName" :value="college.collegeId" />
|
||
</el-select>
|
||
<el-input v-model="courseKeyword" clearable :placeholder="t('experimentsTemplate.k47')" @keyup.enter="searchTaskOptions" />
|
||
<el-button @click="searchTaskOptions">{{ t('businessLabels.search') }}</el-button>
|
||
</div>
|
||
<section v-for="group in taskGroups" :key="group.key" class="task-picker-course">
|
||
<header>
|
||
<span>{{ group.termName }}</span>
|
||
<b>{{ group.courseCode }} · {{ group.courseName }}</b>
|
||
</header>
|
||
<div>
|
||
<el-checkbox
|
||
v-for="task in group.tasks"
|
||
:key="task.id"
|
||
:value="task.id"
|
||
:disabled="projectForm.arrangementMode === 'SelfScheduled'
|
||
&& !!selectedTask && (task.academicTermId !== selectedTask.academicTermId
|
||
|| task.courseId !== selectedTask.courseId)"
|
||
>
|
||
<b>{{ task.taskNumber }}</b>
|
||
<span>{{ task.classNames.join('、') || task.name }}</span>
|
||
</el-checkbox>
|
||
</div>
|
||
</section>
|
||
<el-empty v-if="!taskGroups.length" :image-size="46" :description="t('experimentsTemplate.k48')" />
|
||
</el-checkbox-group>
|
||
<small v-if="!editingProjectId" class="form-help">
|
||
<template v-if="projectForm.arrangementMode === 'Centralized'">{{ t('experimentsDynamic.selectedClasses', { count: projectForm.teachingTaskIds.length }) }}</template>
|
||
<template v-else>{{ t('experimentsTemplate.k49') }}</template>
|
||
</small>
|
||
</el-form-item>
|
||
<div class="form-grid two">
|
||
<el-form-item :label="t('campusRegistration.projectCode')" required>
|
||
<el-input v-model="projectForm.code" :disabled="correctingPublishedProject" maxlength="40" :placeholder="t('experimentsTemplate.k50')" />
|
||
</el-form-item>
|
||
<el-form-item v-if="editingProjectId" :label="t('batchBusiness.k10')" required>
|
||
<el-input v-model="projectForm.name" maxlength="120" :placeholder="t('experimentsTemplate.k51')" />
|
||
</el-form-item>
|
||
</div>
|
||
<template v-if="!editingProjectId">
|
||
<el-form-item :label="t('experimentsTemplate.k52')" required>
|
||
<el-radio-group v-model="projectForm.nameMode">
|
||
<el-radio-button value="Sequence">{{ t('experimentsTemplate.k53') }}</el-radio-button>
|
||
<el-radio-button value="InputNames">{{ t('experimentsTemplate.k54') }}</el-radio-button>
|
||
</el-radio-group>
|
||
</el-form-item>
|
||
<el-form-item v-if="projectForm.nameMode === 'Sequence'" :label="t('experimentsTemplate.k55')" required>
|
||
<el-input v-model="projectForm.name" maxlength="116" :placeholder="t('experimentsTemplate.k56')" />
|
||
</el-form-item>
|
||
<el-form-item v-if="projectForm.arrangementMode === 'SelfScheduled' && projectForm.nameMode === 'Sequence'" :label="t('experimentsTemplate.k57')" required>
|
||
<el-input-number v-model="projectForm.projectCount" :min="1" :max="100" />
|
||
<small class="form-help">{{ t('experimentsDynamic.projectCount', { count: projectForm.projectCount }) }}</small>
|
||
</el-form-item>
|
||
<el-form-item v-else :label="t('experimentsTemplate.k58')" required>
|
||
<el-input
|
||
v-model="projectForm.projectNames"
|
||
type="textarea"
|
||
:rows="6"
|
||
maxlength="120000"
|
||
:placeholder="t('experimentsTemplate.k59')"
|
||
/>
|
||
<small class="form-help">{{ t('experimentsDynamic.nameCount', { count: projectNameLines(projectForm.projectNames).length }) }}</small>
|
||
</el-form-item>
|
||
</template>
|
||
</div>
|
||
|
||
<div class="form-section">
|
||
<header><span>ROUTE</span><b>{{ t('experimentsTemplate.k60') }}</b></header>
|
||
<el-radio-group v-model="projectForm.arrangementMode" class="mode-choice" :disabled="!!editingProjectId || correctingPublishedProject">
|
||
<el-radio-button value="Centralized">
|
||
<b>{{ t('experimentsTemplate.k14') }}</b><small>{{ t('experimentsTemplate.k61') }}</small>
|
||
</el-radio-button>
|
||
<el-radio-button value="SelfScheduled">
|
||
<b>{{ t('experimentsTemplate.k15') }}</b><small>{{ t('experimentsTemplate.k62') }}</small>
|
||
</el-radio-button>
|
||
</el-radio-group>
|
||
<el-form-item :label="t('experimentsTemplate.k63')" required>
|
||
<el-date-picker
|
||
v-model="projectForm.dates"
|
||
:disabled="correctingPublishedProject"
|
||
type="daterange"
|
||
value-format="YYYY-MM-DD"
|
||
:range-separator="t('experimentsTemplate.k64')"
|
||
:start-placeholder="t('businessLabels.startDate')"
|
||
:end-placeholder="t('businessLabels.endDate')"
|
||
/>
|
||
</el-form-item>
|
||
<el-form-item v-if="projectForm.arrangementMode === 'SelfScheduled'" :label="t('experimentsTemplate.k65')" required>
|
||
<el-date-picker
|
||
v-model="projectForm.selectionTimes"
|
||
type="datetimerange"
|
||
value-format="YYYY-MM-DDTHH:mm:ss"
|
||
:range-separator="t('experimentsTemplate.k64')"
|
||
start-:placeholder="t('experimentsTemplate.k66')"
|
||
end-:placeholder="t('experimentsTemplate.k67')"
|
||
/>
|
||
<small class="form-help">{{ t('experimentsTemplate.k68') }}</small>
|
||
</el-form-item>
|
||
</div>
|
||
|
||
<div class="form-section">
|
||
<header><span>BRIEF</span><b>{{ t('experimentsTemplate.k69') }}</b></header>
|
||
<el-form-item :label="t('experimentsTemplate.k70')">
|
||
<el-input
|
||
v-model="projectForm.description"
|
||
type="textarea"
|
||
:rows="3"
|
||
maxlength="1000"
|
||
show-word-limit
|
||
:placeholder="t('experimentsTemplate.k71')"
|
||
/>
|
||
</el-form-item>
|
||
<el-form-item :label="t('experimentsTemplate.k72')">
|
||
<el-input
|
||
v-model="projectForm.requirements"
|
||
type="textarea"
|
||
:rows="2"
|
||
maxlength="1000"
|
||
show-word-limit
|
||
:placeholder="t('experimentsTemplate.k73')"
|
||
/>
|
||
</el-form-item>
|
||
</div>
|
||
</el-form>
|
||
<template #footer>
|
||
<el-button @click="projectDialog = false">{{ t('businessLabels.cancel') }}</el-button>
|
||
<el-button type="primary" @click="saveProject">
|
||
{{ correctingPublishedProject
|
||
? t('experimentsDynamic.saveCorrection')
|
||
: editingProjectId
|
||
? t('experimentsDynamic.saveProject')
|
||
: projectForm.teachingTaskIds.length
|
||
? t('experimentsDynamic.createProjects', { count: projectForm.teachingTaskIds.length })
|
||
: t('experimentsDynamic.createProject') }}
|
||
</el-button>
|
||
</template>
|
||
</el-dialog>
|
||
|
||
<el-dialog v-model="batchRenameDialog" :title="t('experimentsTemplate.k74')" width="680px">
|
||
<el-alert
|
||
:title="t('experimentsDynamic.renameHelp', { count: batchRenameProjects.length })"
|
||
type="info"
|
||
:closable="false"
|
||
show-icon
|
||
/>
|
||
<ol class="batch-rename-preview">
|
||
<li v-for="project in batchRenameProjects" :key="project.id">{{ project.code }} · {{ project.name }}</li>
|
||
</ol>
|
||
<el-input v-model="batchRenameNames" type="textarea" :rows="Math.min(12, Math.max(5, batchRenameProjects.length))" maxlength="12000" :placeholder="t('experimentsTemplate.k75')" />
|
||
<template #footer>
|
||
<el-button @click="batchRenameDialog = false">{{ t('businessLabels.cancel') }}</el-button>
|
||
<el-button type="primary" @click="saveBatchRename">{{ t('experimentsTemplate.k76') }}</el-button>
|
||
</template>
|
||
</el-dialog>
|
||
|
||
<el-dialog
|
||
v-model="sessionDialog"
|
||
:title="t('experimentsDynamic.sessionTitle', { name: selectedProject?.name ?? '' })"
|
||
width="650px"
|
||
>
|
||
<el-form label-position="top" class="experiment-form">
|
||
<el-alert
|
||
:title="selectedProject?.arrangementMode === 'Centralized'
|
||
? t('experimentsDynamic.centralConflict')
|
||
: t('experimentsDynamic.openConflict')"
|
||
type="info"
|
||
:closable="false"
|
||
show-icon
|
||
/>
|
||
<div class="form-grid two">
|
||
<el-form-item :label="t('experimentsTemplate.k77')" required>
|
||
<el-date-picker
|
||
v-model="sessionForm.sessionDate"
|
||
type="date"
|
||
value-format="YYYY-MM-DD"
|
||
:placeholder="t('batchBusiness.k5')"
|
||
/>
|
||
</el-form-item>
|
||
<el-form-item :label="t('batchBusiness.k6')" required>
|
||
<el-select v-model="sessionForm.startPeriod" :placeholder="t('adjustmentBatch.k61')">
|
||
<el-option
|
||
v-for="period in activePeriods"
|
||
:key="period.periodNumber"
|
||
:label="period.startsAt
|
||
? `${period.name} · ${period.startsAt}–${period.endsAt}`
|
||
: period.name"
|
||
:value="period.periodNumber"
|
||
/>
|
||
</el-select>
|
||
</el-form-item>
|
||
<el-form-item :label="t('freeClassrooms.periodCount')" required>
|
||
<el-input-number v-model="sessionForm.periodCount" :min="1" :max="12" />
|
||
</el-form-item>
|
||
<el-form-item :label="t('experimentsTemplate.k78')" required>
|
||
<el-input-number v-model="sessionForm.capacity" :min="1" :max="10000" />
|
||
</el-form-item>
|
||
</div>
|
||
<el-form-item :label="t('experimentsTemplate.k79')" required>
|
||
<el-select v-model="sessionForm.classroomId" filterable :placeholder="t('experimentsTemplate.k80')">
|
||
<el-option
|
||
v-for="room in experimentClassrooms"
|
||
:key="room.id"
|
||
:label="t('experimentsDynamic.room', { campus: room.campusName, building: room.buildingName, name: room.name, capacity: room.capacity })"
|
||
:value="room.id"
|
||
/>
|
||
</el-select>
|
||
</el-form-item>
|
||
<el-form-item :label="t('experimentsTemplate.k81')" required>
|
||
<el-select v-model="sessionForm.instructorTeacherIds" multiple filterable :placeholder="t('experimentsTemplate.k82')">
|
||
<el-option
|
||
v-for="teacher in instructorsForSelectedProject()"
|
||
:key="teacher.teacherId"
|
||
:label="`${teacher.teacherNumber} · ${teacher.teacherName}`"
|
||
:value="teacher.teacherId"
|
||
/>
|
||
</el-select>
|
||
</el-form-item>
|
||
<el-form-item :label="t('experimentsTemplate.k83')">
|
||
<el-input
|
||
v-model="sessionForm.notes"
|
||
maxlength="500"
|
||
:placeholder="t('experimentsTemplate.k84')"
|
||
/>
|
||
</el-form-item>
|
||
</el-form>
|
||
<template #footer>
|
||
<el-button @click="sessionDialog = false">{{ t('businessLabels.cancel') }}</el-button>
|
||
<el-button type="primary" @click="saveSession">{{ t('experimentsTemplate.k85') }}</el-button>
|
||
</template>
|
||
</el-dialog>
|
||
|
||
<el-dialog
|
||
v-model="batchSessionDialog"
|
||
:title="t('experimentsTemplate.k86')"
|
||
width="min(1180px, 94vw)"
|
||
top="4vh"
|
||
>
|
||
<el-alert
|
||
:title="t('experimentsTemplate.k87')"
|
||
type="info"
|
||
:closable="false"
|
||
show-icon
|
||
/>
|
||
<el-form label-position="top" class="batch-session-form">
|
||
<el-form-item :label="t('experimentsTemplate.k20')" required>
|
||
<el-select
|
||
v-model="batchSessionProjectIds"
|
||
multiple
|
||
filterable
|
||
collapse-tags
|
||
collapse-tags-tooltip
|
||
:placeholder="t('experimentsTemplate.k88')"
|
||
@change="syncBatchSessionRows"
|
||
>
|
||
<el-option
|
||
v-for="project in batchProjectOptions"
|
||
:key="project.id"
|
||
:label="`${project.courseCode} · ${project.name} · ${project.taskNumber}`"
|
||
:value="project.id"
|
||
/>
|
||
</el-select>
|
||
</el-form-item>
|
||
<div v-if="batchSessionRows.length" class="batch-session-tools">
|
||
<span>{{ t('experimentsDynamic.candidate', { count: batchSessionRows.length }) }}</span>
|
||
<el-button size="small" @click="applyFirstBatchTime">{{ t('experimentsTemplate.k89') }}</el-button>
|
||
</div>
|
||
<div class="batch-session-table">
|
||
<article v-for="(row, index) in batchSessionRows" :key="row.rowKey" class="batch-session-row">
|
||
<div class="batch-project-cell">
|
||
<span>{{ index + 1 }}</span>
|
||
<div>
|
||
<b>{{ batchProject(row.projectId)?.name }}</b>
|
||
<small>{{ batchProject(row.projectId)?.taskNumber }} · {{ batchProject(row.projectId)?.classNames.join('、') || t('experimentsDynamic.students') }}</small>
|
||
</div>
|
||
</div>
|
||
<el-date-picker
|
||
v-model="row.sessionDate"
|
||
type="date"
|
||
value-format="YYYY-MM-DD"
|
||
:placeholder="t('experimentsTemplate.k77')"
|
||
/>
|
||
<el-select v-model="row.startPeriod" :placeholder="t('batchBusiness.k6')">
|
||
<el-option
|
||
v-for="period in periodsForProject(row.projectId)"
|
||
:key="period.periodNumber"
|
||
:label="period.name"
|
||
:value="period.periodNumber"
|
||
/>
|
||
</el-select>
|
||
<el-input-number v-model="row.periodCount" :min="1" :max="12" controls-position="right" />
|
||
<el-select v-model="row.classroomId" filterable :placeholder="t('experimentsTemplate.k79')">
|
||
<el-option
|
||
v-for="room in experimentClassrooms"
|
||
:key="room.id"
|
||
:label="t('experimentsDynamic.room', { campus: room.campusName, building: room.buildingName, name: room.name, capacity: room.capacity })"
|
||
:value="room.id"
|
||
/>
|
||
</el-select>
|
||
<el-select v-model="row.instructorTeacherIds" multiple filterable collapse-tags :placeholder="t('experimentsTemplate.k90')">
|
||
<el-option
|
||
v-for="teacher in instructorsForProject(row.projectId)"
|
||
:key="teacher.teacherId"
|
||
:label="teacher.teacherName"
|
||
:value="teacher.teacherId"
|
||
/>
|
||
</el-select>
|
||
<el-input-number v-model="row.capacity" :min="1" :max="10000" controls-position="right" />
|
||
<span class="batch-session-actions">
|
||
<el-button size="small" text type="primary" @click="addBatchSessionRow(row.projectId, row)">{{ t('experimentsTemplate.k91') }}</el-button>
|
||
<el-button size="small" text type="danger" @click="removeBatchSessionRow(row)">{{ t('businessLabels.remove') }}</el-button>
|
||
</span>
|
||
</article>
|
||
</div>
|
||
<el-empty v-if="!batchSessionRows.length" :image-size="60" :description="t('experimentsTemplate.k92')" />
|
||
</el-form>
|
||
<template #footer>
|
||
<el-button @click="batchSessionDialog = false">{{ t('businessLabels.cancel') }}</el-button>
|
||
<el-button type="primary" :disabled="!batchSessionRows.length" @click="saveBatchSessions">
|
||
{{ t('experimentsTemplate.k93') }}
|
||
</el-button>
|
||
</template>
|
||
</el-dialog>
|
||
|
||
<el-dialog
|
||
v-model="participantsDialog"
|
||
:title="t('experimentsDynamic.participants', { label: participantSession?.project?.arrangementMode === 'Centralized' ? t('experimentsDynamic.expected') : t('experimentsDynamic.bookings'), time: participantSession ? formatSessionTime(participantSession) : '' })"
|
||
width="680px"
|
||
>
|
||
<el-table v-loading="participantsLoading" :data="participants" max-height="480">
|
||
<el-table-column prop="studentNumber" :label="t('businessLabels.studentNumber')" min-width="130" />
|
||
<el-table-column prop="name" :label="t('businessLabels.name')" min-width="100" />
|
||
<el-table-column prop="className" :label="t('businessLabels.administrativeClass')" min-width="160" />
|
||
<el-table-column :label="t('experimentsTemplate.k94')" width="110">
|
||
<template #default="{ row }">
|
||
<el-tag
|
||
:type="row.participationType === 'Centralized' ? 'primary' : 'success'"
|
||
size="small"
|
||
effect="plain"
|
||
>
|
||
{{ row.participationType === 'Centralized' ? t('experimentsDynamic.scheduled') : t('experimentsDynamic.studentBooking') }}
|
||
</el-tag>
|
||
</template>
|
||
</el-table-column>
|
||
</el-table>
|
||
<el-empty v-if="!participantsLoading && !participants.length" :description="t('experimentsTemplate.k96')" />
|
||
<template #footer>
|
||
<el-button
|
||
v-if="participantSession?.project?.arrangementMode === 'SelfScheduled'"
|
||
type="primary"
|
||
@click="openProxyBooking"
|
||
>{{ t('experimentsTemplate.k97') }}</el-button>
|
||
<el-button @click="participantsDialog = false">{{ t('businessLabels.close') }}</el-button>
|
||
</template>
|
||
</el-dialog>
|
||
|
||
<el-dialog v-model="proxyBookingDialog" :title="t('experimentsTemplate.k98')" width="620px">
|
||
<el-alert
|
||
:title="t('experimentsTemplate.k99')"
|
||
type="info"
|
||
:closable="false"
|
||
show-icon
|
||
/>
|
||
<div class="proxy-booking-search">
|
||
<el-input v-model="proxyBookingKeyword" clearable :placeholder="t('batchBusiness.k11')" @keyup.enter="loadProxyBookingStudents(1)" />
|
||
<el-button @click="loadProxyBookingStudents(1)">{{ t('businessLabels.search') }}</el-button>
|
||
</div>
|
||
<el-table
|
||
v-loading="proxyBookingLoading"
|
||
:data="proxyBookingStudents"
|
||
max-height="400"
|
||
@selection-change="(rows) => proxyBookingStudentIds = rows.map((row) => row.studentId)"
|
||
>
|
||
<el-table-column type="selection" width="54" />
|
||
<el-table-column prop="studentNumber" :label="t('businessLabels.studentNumber')" min-width="130" />
|
||
<el-table-column prop="name" :label="t('businessLabels.name')" min-width="100" />
|
||
<el-table-column prop="className" :label="t('businessLabels.administrativeClass')" min-width="180" />
|
||
</el-table>
|
||
<el-pagination v-if="proxyBookingTotal > proxyBookingPageSize" background :current-page="proxyBookingPage" :page-size="proxyBookingPageSize" :total="proxyBookingTotal" layout="total, prev, pager, next" @current-change="loadProxyBookingStudents" />
|
||
<el-empty v-if="!proxyBookingLoading && !proxyBookingStudents.length" :description="t('experimentsTemplate.k100')" />
|
||
<template #footer>
|
||
<el-button @click="proxyBookingDialog = false">{{ t('businessLabels.cancel') }}</el-button>
|
||
<el-button type="primary" :disabled="!proxyBookingStudentIds.length" @click="saveProxyBooking">
|
||
{{ t('experimentsDynamic.confirmProxy', { count: proxyBookingStudentIds.length }) }}
|
||
</el-button>
|
||
</template>
|
||
</el-dialog>
|
||
</div>
|
||
</template>
|
||
|
||
<style scoped>
|
||
.experiment-page { --lab-blue: #245d82; --lab-teal: #168276; --lab-ink: #173041; }
|
||
.experiment-intro { align-items: flex-start; }
|
||
.intro-actions { display: flex; gap: 8px; align-items: center; }
|
||
.lab-rail {
|
||
display: grid;
|
||
grid-template-columns: minmax(0, 1fr) 78px minmax(0, 1fr);
|
||
gap: 0;
|
||
margin-bottom: 16px;
|
||
border: 1px solid #ccdce5;
|
||
background: #f7fafc;
|
||
}
|
||
.rail-lane { position: relative; padding: 17px 20px 18px 24px; overflow: hidden; }
|
||
.rail-lane::before {
|
||
content: "";
|
||
position: absolute;
|
||
inset: 0 auto 0 0;
|
||
width: 5px;
|
||
background: var(--lab-blue);
|
||
}
|
||
.rail-lane.flexible::before { background: var(--lab-teal); }
|
||
.rail-lane b { display: block; margin: 4px 0; color: var(--lab-ink); font-size: 15px; }
|
||
.rail-lane p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.65; }
|
||
.rail-code { color: #607987; font: 700 10px/1.2 Consolas, monospace; letter-spacing: .08em; }
|
||
.rail-switch {
|
||
position: relative;
|
||
display: grid;
|
||
place-content: center;
|
||
gap: 8px;
|
||
background: linear-gradient(90deg, transparent 49%, #b9cbd5 49%, #b9cbd5 51%, transparent 51%);
|
||
}
|
||
.rail-switch i { width: 30px; height: 7px; border: 2px solid #7794a5; border-radius: 999px; background: #fff; }
|
||
.experiment-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
|
||
.experiment-toolbar .el-select { width: 210px; }
|
||
.experiment-toolbar .el-input { width: 172px; }
|
||
.result-note { margin-left: auto; color: var(--muted); font-size: 12px; }
|
||
.experiment-batch-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; min-height: 46px; margin: -6px 0 16px; padding: 8px 12px; border: 1px solid #cddce3; background: #f7fafb; }
|
||
.experiment-batch-bar > span { margin-right: auto; color: #5c7481; font-size: 12px; }
|
||
.batch-rename-preview { max-height: 180px; margin: 14px 0; overflow: auto; padding: 10px 12px 10px 32px; border: 1px solid #dce5e9; background: #f8fbfc; color: #526b78; font-size: 12px; line-height: 1.8; }
|
||
.experiment-pagination { justify-content: flex-end; margin-top: 4px; }
|
||
.project-list { display: grid; gap: 14px; min-height: 160px; }
|
||
.project-group { overflow: hidden; border: 1px solid #cddce3; background: #f6fafb; }
|
||
.project-group-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 13px 17px; border-left: 5px solid var(--lab-blue); background: #edf4f6; }
|
||
.project-group-head > div:first-child { display: grid; gap: 3px; }
|
||
.project-group-head h3 { margin: 0; color: var(--lab-ink); font-size: 15px; }
|
||
.project-group-head > div:first-child span { color: #68808d; font: 700 10px/1 Consolas, monospace; letter-spacing: .06em; }
|
||
.project-group-task { display: grid; justify-items: end; gap: 3px; color: #5c7481; font-size: 11px; text-align: right; }
|
||
.project-group-task b { color: #365364; font-size: 12px; }
|
||
.project-group-projects { display: grid; gap: 0; padding: 0; }
|
||
.project-table { --el-table-border-color: #dce5ea; --el-table-header-bg-color: #f7fafb; --el-table-row-hover-bg-color: #f6fafb; width: 100%; }
|
||
.project-table :deep(th.el-table__cell) { padding: 8px 0; color: #617986; font-size: 11px; font-weight: 650; }
|
||
.project-table :deep(td.el-table__cell) { padding: 9px 0; vertical-align: top; }
|
||
.student-project-table :deep(td.el-table__cell) { vertical-align: middle; }
|
||
.table-project-name, .table-schedule { display: grid; gap: 4px; min-width: 0; }
|
||
.table-project-name b { color: var(--lab-ink); font-size: 13px; }
|
||
.table-project-name small, .table-schedule small { overflow: hidden; color: #667f8d; font-size: 11px; line-height: 1.45; text-overflow: ellipsis; white-space: nowrap; }
|
||
.table-schedule b { color: #365364; font-size: 12px; font-weight: 600; }
|
||
.table-schedule.is-booked b { color: var(--lab-teal); }
|
||
.table-muted { color: #8b9aa4; font-size: 12px; }
|
||
.student-project-detail { display: grid; grid-template-columns: repeat(2, minmax(220px, 1fr)); gap: 7px 20px; padding: 11px 18px 13px; background: #f7fafb; }
|
||
.student-project-detail p { margin: 0; display: grid; grid-template-columns: 70px 1fr; gap: 8px; color: #5f7682; font-size: 11px; line-height: 1.55; }
|
||
.student-project-detail b { color: #304d5d; }
|
||
.student-session-menu { display: grid; gap: 7px; }
|
||
.student-session-menu > header { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 8px; border-bottom: 1px solid #dfe7ea; }
|
||
.student-session-menu > header b { color: var(--lab-ink); font-size: 12px; }
|
||
.student-session-menu > header span { color: #71858e; font-size: 10px; }
|
||
.student-session-option { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 9px; padding: 8px 9px; border: 1px solid #e0e7ea; background: #fff; }
|
||
.student-session-option.is-selected { border-color: #79afa5; box-shadow: inset 3px 0 0 var(--lab-teal); background: #f3faf8; }
|
||
.student-session-option > div { display: grid; gap: 2px; min-width: 0; }
|
||
.student-session-option > div b { color: #304d5d; font-size: 11px; }
|
||
.student-session-option > div span { overflow: hidden; color: #6a808b; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
|
||
.project-card {
|
||
overflow: hidden;
|
||
border: 0;
|
||
border-top: 1px solid #dce5ea;
|
||
border-left: 4px solid var(--lab-blue);
|
||
background: #fff;
|
||
box-shadow: none;
|
||
}
|
||
.project-card.is-flexible { border-top-color: var(--lab-teal); }
|
||
.project-card.is-closed { opacity: .82; }
|
||
.project-head { display: flex; justify-content: space-between; gap: 16px; padding: 18px 20px 10px; }
|
||
.project-code { color: #667f8d; font: 700 10px/1.2 Consolas, monospace; letter-spacing: .06em; text-transform: uppercase; }
|
||
.project-identity h3 { margin: 5px 0 4px; color: var(--lab-ink); font-size: 18px; }
|
||
.project-identity p { margin: 0; color: var(--muted); font-size: 12px; }
|
||
.project-tags { display: flex; gap: 6px; align-items: flex-start; flex-shrink: 0; }
|
||
.project-context { display: flex; flex-wrap: wrap; gap: 7px 22px; padding: 0 20px 12px; color: #5c7481; font-size: 12px; }
|
||
.project-context span { display: inline-flex; gap: 7px; }
|
||
.project-context b { color: #304b5a; font-weight: 600; }
|
||
.project-description { margin: 0; padding: 10px 20px; border-top: 1px solid #edf1f3; color: #415b69; font-size: 13px; line-height: 1.7; }
|
||
.requirement-strip {
|
||
display: grid;
|
||
grid-template-columns: 74px 1fr;
|
||
gap: 10px;
|
||
margin: 0 20px 14px;
|
||
padding: 10px 12px;
|
||
border-left: 3px solid #e3a13c;
|
||
background: #fff9ef;
|
||
color: #6d5b3e;
|
||
font-size: 12px;
|
||
line-height: 1.6;
|
||
}
|
||
.session-board { margin: 0 20px 16px; border: 1px solid #dfe8ec; background: #f8fafb; }
|
||
.session-board-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 13px; border-bottom: 1px solid #dfe8ec; }
|
||
.session-board-head div { display: grid; gap: 2px; }
|
||
.session-board-head span { color: #617986; font: 700 10px/1.2 Consolas, monospace; letter-spacing: .06em; text-transform: uppercase; }
|
||
.session-board-head b { color: #304d5d; font-size: 11px; font-weight: 500; }
|
||
.session-grid { display: grid; gap: 8px; padding: 10px; }
|
||
.session-ticket {
|
||
display: grid;
|
||
grid-template-columns: 58px minmax(0, 1fr) auto;
|
||
gap: 12px;
|
||
align-items: center;
|
||
min-height: 74px;
|
||
border: 1px solid #dce5e9;
|
||
background: #fff;
|
||
transition: border-color .18s ease, box-shadow .18s ease;
|
||
}
|
||
.session-ticket:hover { border-color: #9fb7c4; box-shadow: 0 5px 14px rgb(40 76 96 / 7%); }
|
||
.session-ticket.is-selected { border-color: var(--lab-teal); box-shadow: inset 4px 0 0 var(--lab-teal); }
|
||
.session-ticket.is-cancelled { opacity: .58; }
|
||
.ticket-date { display: grid; place-content: center; align-self: stretch; border-right: 1px dashed #cddbe2; background: #f0f5f7; text-align: center; }
|
||
.ticket-date strong { color: var(--lab-ink); font: 700 22px/1 Consolas, monospace; }
|
||
.ticket-date span { margin-top: 4px; color: #657d89; font-size: 10px; }
|
||
.ticket-body { display: grid; gap: 3px; min-width: 0; }
|
||
.ticket-body b { color: #243f4f; font-size: 13px; }
|
||
.ticket-body span { color: #5c7481; font-size: 12px; }
|
||
.ticket-body small { overflow: hidden; color: #81929b; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
|
||
.ticket-action { display: flex; align-items: center; justify-content: flex-end; gap: 5px; padding-right: 10px; }
|
||
.project-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid #e5ecef; background: #fbfcfd; }
|
||
.student-booking-summary {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
gap: 12px;
|
||
padding: 12px 20px;
|
||
border-top: 1px solid #cce3de;
|
||
background: #f0faf7;
|
||
}
|
||
.student-booking-summary > div { display: flex; align-items: center; gap: 10px; color: var(--lab-teal); }
|
||
.student-booking-summary svg { width: 22px; }
|
||
.student-booking-summary span { display: grid; gap: 2px; color: #365f5b; font-size: 12px; }
|
||
.student-booking-summary b { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; }
|
||
.experiment-form { display: grid; gap: 13px; }
|
||
.grouped-task-picker { display: grid; gap: 10px; max-height: 310px; overflow: auto; padding: 10px; border: 1px solid #d8e3e8; background: #fff; }
|
||
.task-option-filters { display: grid; grid-template-columns: minmax(150px, 1fr) minmax(180px, 1.2fr) auto; gap: 8px; }
|
||
.task-picker-course { overflow: hidden; border: 1px solid #e0e8eb; }
|
||
.task-picker-course header { display: flex; align-items: baseline; gap: 8px; padding: 8px 10px; background: #f3f7f8; }
|
||
.task-picker-course header span { color: #738994; font: 700 10px/1 Consolas, monospace; }
|
||
.task-picker-course header b { color: #314f60; font-size: 12px; }
|
||
.task-picker-course > div { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 2px 12px; padding: 8px 10px; }
|
||
.task-picker-course :deep(.el-checkbox) { height: auto; margin-right: 0; white-space: normal; }
|
||
.task-picker-course :deep(.el-checkbox__label) { display: inline-flex; gap: 6px; min-width: 0; color: #536b78; font-size: 12px; }
|
||
.task-picker-course :deep(.el-checkbox__label b) { flex: 0 0 auto; color: #284757; }
|
||
.form-help { display: block; margin-top: 7px; color: var(--muted); line-height: 1.5; }
|
||
.form-section { padding: 14px 15px 1px; border: 1px solid var(--line); background: #fbfcfd; }
|
||
.form-section > header { display: flex; align-items: baseline; gap: 9px; margin-bottom: 13px; }
|
||
.form-section > header span { color: var(--lab-teal); font: 700 10px/1 Consolas, monospace; letter-spacing: .08em; }
|
||
.form-section > header b { color: var(--lab-ink); font-size: 14px; }
|
||
.mode-choice { display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 16px; }
|
||
.mode-choice :deep(.el-radio-button__inner) { display: grid; gap: 5px; width: 100%; padding: 13px; }
|
||
.mode-choice b { font-size: 13px; }
|
||
.mode-choice small { font-size: 10px; font-weight: 400; }
|
||
.batch-session-form { display: grid; gap: 12px; margin-top: 16px; }
|
||
.batch-session-tools { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12px; }
|
||
.batch-session-table { display: grid; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
|
||
.batch-session-row {
|
||
display: grid;
|
||
grid-template-columns: minmax(210px, 1.2fr) 145px 110px 100px minmax(200px, 1.1fr) minmax(150px, .8fr) 100px auto;
|
||
gap: 8px;
|
||
align-items: center;
|
||
min-width: 1000px;
|
||
padding: 10px;
|
||
border: 1px solid #dce5e9;
|
||
background: #f9fbfc;
|
||
}
|
||
.batch-session-actions { display: flex; align-items: center; gap: 2px; white-space: nowrap; }
|
||
.batch-project-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
|
||
.batch-project-cell > span { display: grid; width: 25px; height: 25px; place-items: center; border-radius: 50%; background: #e5f0f5; color: var(--lab-blue); font: 700 11px/1 Consolas, monospace; }
|
||
.batch-project-cell > div { display: grid; gap: 3px; min-width: 0; }
|
||
.batch-project-cell b, .batch-project-cell small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||
.batch-project-cell b { color: var(--lab-ink); font-size: 12px; }
|
||
.batch-project-cell small { color: var(--muted); font-size: 10px; }
|
||
.mobile-project-cards { display: none; }
|
||
@media (prefers-reduced-motion: reduce) {
|
||
.session-ticket { transition: none; }
|
||
}
|
||
@media (max-width: 760px) {
|
||
.lab-rail { grid-template-columns: 1fr; }
|
||
.rail-switch { display: none; }
|
||
.rail-lane { border-bottom: 1px solid #d5e1e7; }
|
||
.experiment-toolbar .el-select { width: 100%; }
|
||
.result-note { width: 100%; margin-left: 0; }
|
||
.project-head { align-items: flex-start; padding: 15px 14px 9px; }
|
||
.project-context, .project-description { padding-inline: 14px; }
|
||
.requirement-strip, .session-board { margin-inline: 14px; }
|
||
.session-ticket { grid-template-columns: 54px minmax(0, 1fr); }
|
||
.ticket-action { grid-column: 1 / -1; justify-content: flex-start; padding: 0 10px 10px; }
|
||
.project-actions, .student-booking-summary { padding-inline: 14px; }
|
||
.student-project-detail { grid-template-columns: 1fr; }
|
||
.mode-choice { grid-template-columns: 1fr; }
|
||
.intro-actions { flex-wrap: wrap; justify-content: flex-end; }
|
||
.desktop-project-table { display: none; }
|
||
.mobile-project-cards { display: grid; gap: 1px; background: #dce5ea; }
|
||
.mobile-project-card { padding: 15px 14px; background: #fff; }
|
||
.mobile-project-card > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
|
||
.mobile-project-card > header > div { min-width: 0; }
|
||
.mobile-project-card > header span { color: #68808d; font: 700 10px/1.2 Consolas, monospace; letter-spacing: .06em; }
|
||
.mobile-project-card h4 { margin: 4px 0 0; color: var(--lab-ink); font-size: 15px; line-height: 1.45; }
|
||
.mobile-project-card > p { margin: 9px 0 0; color: #667f8d; font-size: 12px; line-height: 1.6; }
|
||
.mobile-project-arrangement { display: grid; gap: 5px; margin-top: 13px; padding: 11px 12px; border-left: 3px solid #a6bbc6; background: #f6fafb; }
|
||
.mobile-project-arrangement > b { color: #365364; font-size: 12px; }
|
||
.mobile-project-arrangement > span { color: #405d6c; font-size: 12px; line-height: 1.5; }
|
||
.mobile-project-arrangement > small { color: #718792; font-size: 11px; line-height: 1.45; }
|
||
.mobile-session-list { display: grid; gap: 7px; margin-top: 3px; }
|
||
.mobile-session-list > article { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; padding: 9px; border: 1px solid #dce6e9; background: #fff; }
|
||
.mobile-session-list > article.is-selected { border-color: #69a99d; box-shadow: inset 3px 0 0 var(--lab-teal); }
|
||
.mobile-session-list > article > div { display: grid; gap: 3px; min-width: 0; }
|
||
.mobile-session-list strong { color: #304d5d; font-size: 12px; }
|
||
.mobile-session-list small { overflow: hidden; color: #718792; font-size: 10px; line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; }
|
||
.mobile-session-list .el-button { grid-column: 2; grid-row: 1 / span 2; align-self: center; min-height: 34px; }
|
||
.mobile-session-list .el-tag { grid-column: 1; width: fit-content; }
|
||
.mobile-cancel-booking { justify-self: start; margin-top: 2px; }
|
||
}
|
||
</style>
|