实验排课再次修正
This commit is contained in:
@@ -60,6 +60,15 @@ const experimentVenueNatures = [
|
||||
{ value: 16, label: '语音室' }, { value: 32, label: '体育场地' },
|
||||
{ value: 64, label: '艺术场地' },
|
||||
]
|
||||
const venueNatureValue = (value: unknown) => {
|
||||
if (typeof value === 'number') return value
|
||||
if (typeof value !== 'string') return 0
|
||||
const names: Record<string, number> = {
|
||||
GeneralClassroom: 1, Laboratory: 2, TrainingRoom: 4, ComputerLab: 8,
|
||||
LanguageLab: 16, SportsVenue: 32, ArtsVenue: 64,
|
||||
}
|
||||
return value.split(',').reduce((sum, name) => sum | (names[name.trim()] ?? 0), 0)
|
||||
}
|
||||
const periods = computed(() => {
|
||||
const configured = timeSlots.value
|
||||
.filter((item) => item.isEnabled)
|
||||
@@ -133,12 +142,16 @@ const selectedTaskConstraint = computed(() =>
|
||||
)
|
||||
const entryClassrooms = computed(() =>
|
||||
classrooms.value.filter((room) =>
|
||||
(!selectedTaskConstraint.value?.requiredCampusId
|
||||
(entryForm.kind === 'Experiment' || !selectedTaskConstraint.value?.requiredCampusId
|
||||
|| room.campusId === selectedTaskConstraint.value.requiredCampusId) &&
|
||||
(!selectedTaskConstraint.value?.requiredBuildingId
|
||||
(entryForm.kind === 'Experiment' || !selectedTaskConstraint.value?.requiredBuildingId
|
||||
|| room.buildingId === selectedTaskConstraint.value.requiredBuildingId) &&
|
||||
(!selectedTaskConstraint.value?.allowedClassroomIds?.length
|
||||
(entryForm.kind === 'Experiment' || !selectedTaskConstraint.value?.allowedClassroomIds?.length
|
||||
|| selectedTaskConstraint.value.allowedClassroomIds.includes(room.id)) &&
|
||||
(entryForm.kind !== 'Experiment' || !selectedTaskConstraint.value?.experimentRequiredCampusId
|
||||
|| room.campusId === selectedTaskConstraint.value.experimentRequiredCampusId) &&
|
||||
(entryForm.kind !== 'Experiment' || !selectedTaskConstraint.value?.experimentRequiredBuildingId
|
||||
|| room.buildingId === selectedTaskConstraint.value.experimentRequiredBuildingId) &&
|
||||
(entryForm.kind !== 'Experiment' ||
|
||||
!selectedTaskConstraint.value?.allowedExperimentClassroomIds?.length ||
|
||||
selectedTaskConstraint.value.allowedExperimentClassroomIds.includes(room.id)),
|
||||
@@ -194,10 +207,19 @@ const filteredClassrooms = computed(() =>
|
||||
(!constraintForm.requiredBuildingId || item.buildingId === constraintForm.requiredBuildingId),
|
||||
),
|
||||
)
|
||||
const filteredExperimentBuildings = computed(() =>
|
||||
constraintForm.experimentRequiredCampusId
|
||||
? buildings.value.filter((item) => item.campusId === constraintForm.experimentRequiredCampusId)
|
||||
: buildings.value,
|
||||
)
|
||||
const filteredExperimentClassrooms = computed(() =>
|
||||
filteredClassrooms.value.filter((item) =>
|
||||
classrooms.value.filter((item) =>
|
||||
(!constraintForm.experimentRequiredCampusId ||
|
||||
item.campusId === constraintForm.experimentRequiredCampusId) &&
|
||||
(!constraintForm.experimentRequiredBuildingId ||
|
||||
item.buildingId === constraintForm.experimentRequiredBuildingId) &&
|
||||
(!(constraintForm.allowedExperimentVenueNatures ?? []).length ||
|
||||
(Number(item.teachingVenueNature) & (constraintForm.allowedExperimentVenueNatures ?? [])
|
||||
(venueNatureValue(item.teachingVenueNature) & (constraintForm.allowedExperimentVenueNatures ?? [])
|
||||
.reduce((value: number, nature: number) => value | nature, 0)) !== 0),
|
||||
),
|
||||
)
|
||||
@@ -217,7 +239,7 @@ const batchFilteredClassrooms = computed(() =>
|
||||
const batchFilteredExperimentClassrooms = computed(() =>
|
||||
batchFilteredClassrooms.value.filter((item) =>
|
||||
(!(constraintBatchForm.allowedExperimentVenueNatures ?? []).length ||
|
||||
(Number(item.teachingVenueNature) &
|
||||
(venueNatureValue(item.teachingVenueNature) &
|
||||
(constraintBatchForm.allowedExperimentVenueNatures ?? [])
|
||||
.reduce((value: number, nature: number) => value | nature, 0)) !== 0),
|
||||
),
|
||||
@@ -315,6 +337,8 @@ function openConstraint(item: any) {
|
||||
requiresClassroom: item.requiresClassroom,
|
||||
requiredCampusId: item.requiredCampusId,
|
||||
requiredBuildingId: item.requiredBuildingId,
|
||||
experimentRequiredCampusId: item.experimentRequiredCampusId,
|
||||
experimentRequiredBuildingId: item.experimentRequiredBuildingId,
|
||||
allowedClassroomIds: [...item.allowedClassroomIds],
|
||||
allowedExperimentClassroomIds: [...item.allowedExperimentClassroomIds],
|
||||
allowedExperimentVenueNatures: experimentVenueNatures
|
||||
@@ -336,6 +360,8 @@ async function saveConstraint() {
|
||||
requiresClassroom: constraintForm.requiresClassroom,
|
||||
requiredCampusId: constraintForm.requiredCampusId || null,
|
||||
requiredBuildingId: constraintForm.requiredBuildingId || null,
|
||||
experimentRequiredCampusId: constraintForm.experimentRequiredCampusId || null,
|
||||
experimentRequiredBuildingId: constraintForm.experimentRequiredBuildingId || null,
|
||||
allowedClassroomIds: constraintForm.allowedClassroomIds ?? [],
|
||||
allowedExperimentClassroomIds: constraintForm.allowedExperimentClassroomIds ?? [],
|
||||
allowedExperimentVenueNatures: (constraintForm.allowedExperimentVenueNatures ?? [])
|
||||
@@ -743,9 +769,11 @@ function changeEntryTask() {
|
||||
}
|
||||
const room = classrooms.value.find((item) => item.id === entryForm.classroomId)
|
||||
if (room && (
|
||||
(task.requiredCampusId && room.campusId !== task.requiredCampusId) ||
|
||||
(task.requiredBuildingId && room.buildingId !== task.requiredBuildingId) ||
|
||||
(task.allowedClassroomIds?.length && !task.allowedClassroomIds.includes(room.id)) ||
|
||||
(entryForm.kind !== 'Experiment' && task.requiredCampusId && room.campusId !== task.requiredCampusId) ||
|
||||
(entryForm.kind !== 'Experiment' && task.requiredBuildingId && room.buildingId !== task.requiredBuildingId) ||
|
||||
(entryForm.kind !== 'Experiment' && task.allowedClassroomIds?.length && !task.allowedClassroomIds.includes(room.id)) ||
|
||||
(entryForm.kind === 'Experiment' && task.experimentRequiredCampusId && room.campusId !== task.experimentRequiredCampusId) ||
|
||||
(entryForm.kind === 'Experiment' && task.experimentRequiredBuildingId && room.buildingId !== task.experimentRequiredBuildingId) ||
|
||||
(entryForm.kind === 'Experiment' && task.allowedExperimentClassroomIds?.length &&
|
||||
!task.allowedExperimentClassroomIds.includes(room.id))
|
||||
)) {
|
||||
@@ -1272,6 +1300,18 @@ onBeforeUnmount(() => {
|
||||
<small class="field-hint">仅约束实验课;不勾选时可使用全部实验教学场地。</small>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="constraintForm.coursePracticeHours" label="实验课指定可用场地">
|
||||
<div class="form-grid">
|
||||
<el-form-item label="实验课限定校区">
|
||||
<el-select v-model="constraintForm.experimentRequiredCampusId" clearable @change="constraintForm.experimentRequiredBuildingId = undefined; constraintForm.allowedExperimentClassroomIds = []">
|
||||
<el-option v-for="item in campuses" :key="item.id" :label="item.name" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="实验课限定教学楼">
|
||||
<el-select v-model="constraintForm.experimentRequiredBuildingId" clearable @change="constraintForm.allowedExperimentClassroomIds = []">
|
||||
<el-option v-for="item in filteredExperimentBuildings" :key="item.id" :label="item.name" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<el-select v-model="constraintForm.allowedExperimentClassroomIds" multiple filterable collapse-tags>
|
||||
<el-option
|
||||
v-for="item in filteredExperimentClassrooms"
|
||||
|
||||
Reference in New Issue
Block a user