849 lines
37 KiB
Vue
849 lines
37 KiB
Vue
<script setup lang="ts">
|
|
import { useI18n } from 'vue-i18n'
|
|
const { t } = useI18n()
|
|
import { computed, onMounted, reactive, ref } from 'vue'
|
|
import { Collection, CopyDocument, Plus, Promotion, Refresh, Search } from '@element-plus/icons-vue'
|
|
import http, { apiErrorMessage } from '../api/http'
|
|
import { useAuthStore } from '../stores/auth'
|
|
|
|
const auth = useAuthStore()
|
|
const loading = ref(false)
|
|
const detailLoading = ref(false)
|
|
const plans = ref<any[]>([])
|
|
const total = ref(0)
|
|
const cursors = ref<string[]>([])
|
|
const nextCursor = ref<string>()
|
|
const hasMore = ref(false)
|
|
const selected = ref<any | null>(null)
|
|
const colleges = ref<any[]>([])
|
|
const majors = ref<any[]>([])
|
|
const grades = ref<number[]>([])
|
|
const courses = ref<any[]>([])
|
|
const courseGroups = ref<any[]>([])
|
|
const planDialog = ref(false)
|
|
const moduleDialog = ref(false)
|
|
const courseDialog = ref(false)
|
|
const cloneDialog = ref(false)
|
|
const courseGroupDialog = ref(false)
|
|
const courseGroupImportDialog = ref(false)
|
|
const detailView = ref<'structure' | 'semester'>('structure')
|
|
const editingPlanId = ref('')
|
|
const editingPlanStatus = ref('')
|
|
const editingModuleId = ref('')
|
|
const editingCourseId = ref('')
|
|
const activeModuleId = ref('')
|
|
const activeCourseGroupId = ref('')
|
|
const query = reactive({
|
|
page: 1,
|
|
pageSize: 20,
|
|
keyword: '',
|
|
collegeId: undefined as string | undefined,
|
|
majorId: undefined as string | undefined,
|
|
effectiveGrade: undefined as number | undefined,
|
|
status: undefined as string | undefined,
|
|
})
|
|
const planForm = reactive<Record<string, any>>({})
|
|
const moduleForm = reactive<Record<string, any>>({})
|
|
const courseForm = reactive<Record<string, any>>({})
|
|
const cloneForm = reactive<Record<string, any>>({})
|
|
const courseGroupForm = reactive<Record<string, any>>({})
|
|
const courseGroupCourseForm = reactive<Record<string, any>>({})
|
|
const courseGroupImportForm = reactive<Record<string, any>>({})
|
|
|
|
const statusLabels = computed<Record<string, string>>(() => ({
|
|
Draft: t('curriculumScript.k0'),
|
|
Published: t('curriculumScript.k1'),
|
|
Archived: t('curriculumScript.k2'),
|
|
}))
|
|
const courseTypeLabels = computed<Record<string, string>>(() => ({
|
|
Required: t('curriculumScript.k3'),
|
|
Elective: t('curriculumScript.k4'),
|
|
}))
|
|
const isCollegeAdmin = computed(() => auth.user?.roles.includes('CollegeAdmin') ?? false)
|
|
const canManageCourseGroups = computed(() =>
|
|
auth.user?.roles.some((role) => role === 'SuperAdmin' || role === 'AcademicAdmin') ?? false,
|
|
)
|
|
const availableMajors = computed(() => majors.value)
|
|
const filteredMajors = computed(() =>
|
|
query.collegeId
|
|
? majors.value.filter((item) => item.collegeId === query.collegeId)
|
|
: majors.value,
|
|
)
|
|
const availableGrades = computed(() =>
|
|
[...new Set([
|
|
...grades.value,
|
|
...plans.value.map((item) => Number(item.effectiveGrade)),
|
|
])].sort((first, second) => second - first),
|
|
)
|
|
const maintenanceScope = computed(() =>
|
|
isCollegeAdmin.value
|
|
? colleges.value[0]?.name ?? t('curriculumScript.k5')
|
|
: t('curriculumScript.k6'),
|
|
)
|
|
const isDraft = computed(() => selected.value?.status === 'Draft')
|
|
const isPublished = computed(() => selected.value?.status === 'Published')
|
|
const canEdit = computed(() => isDraft.value || isPublished.value)
|
|
const isEditingPublished = computed(() => editingPlanStatus.value === 'Published')
|
|
const activeCourseGroup = computed(() =>
|
|
courseGroups.value.find((group) => group.id === activeCourseGroupId.value) ?? null,
|
|
)
|
|
const importingCourseGroup = computed(() =>
|
|
courseGroups.value.find((group) => group.id === courseGroupImportForm.courseGroupId) ?? null,
|
|
)
|
|
const configuredCredits = computed(() =>
|
|
selected.value?.modules.reduce(
|
|
(sum: number, module: any) => sum + Number(module.requiredCredits),
|
|
0,
|
|
) ?? 0,
|
|
)
|
|
const semesterGroups = computed(() => {
|
|
if (!selected.value) return []
|
|
|
|
const courses = selected.value.modules.flatMap((module: any) =>
|
|
module.courses.map((course: any) => ({
|
|
...course,
|
|
moduleCode: module.code,
|
|
moduleName: module.name,
|
|
})),
|
|
)
|
|
const semesterCount = Number(selected.value.schoolingYears) * 2
|
|
|
|
return Array.from({ length: semesterCount }, (_, index) => {
|
|
const semester = index + 1
|
|
const items = courses
|
|
.filter((course: any) => Number(course.recommendedSemester) === semester)
|
|
.sort((first: any, second: any) =>
|
|
first.moduleCode.localeCompare(second.moduleCode) ||
|
|
first.courseCode.localeCompare(second.courseCode),
|
|
)
|
|
return {
|
|
semester,
|
|
courses: items,
|
|
credits: items.reduce((sum: number, course: any) => sum + Number(course.credits), 0),
|
|
totalHours: items.reduce((sum: number, course: any) => sum + Number(course.totalHours), 0),
|
|
}
|
|
})
|
|
})
|
|
|
|
async function loadPlans(keepSelection = true) {
|
|
loading.value = true
|
|
try {
|
|
const { data } = await http.get('/curriculum-plans', {
|
|
params: {
|
|
...query,
|
|
page: undefined,
|
|
cursor: cursors.value.at(-1),
|
|
keyword: query.keyword || undefined,
|
|
},
|
|
})
|
|
plans.value = data.items
|
|
total.value = data.total
|
|
hasMore.value = data.hasMore
|
|
nextCursor.value = data.nextCursor
|
|
const targetId = keepSelection && selected.value
|
|
? selected.value.id
|
|
: plans.value[0]?.id
|
|
if (targetId && plans.value.some((item) => item.id === targetId)) {
|
|
await loadDetail(targetId)
|
|
} else {
|
|
selected.value = null
|
|
}
|
|
} catch (error) {
|
|
ElMessage.error(apiErrorMessage(error))
|
|
} finally {
|
|
loading.value = false
|
|
}
|
|
}
|
|
|
|
async function nextPage() {
|
|
if (!nextCursor.value || loading.value) return
|
|
cursors.value.push(nextCursor.value)
|
|
query.page++
|
|
await loadPlans(false)
|
|
}
|
|
|
|
async function previousPage() {
|
|
if (!cursors.value.length || loading.value) return
|
|
cursors.value.pop()
|
|
query.page--
|
|
await loadPlans(false)
|
|
}
|
|
|
|
function resetCursor() {
|
|
query.page = 1
|
|
cursors.value = []
|
|
nextCursor.value = undefined
|
|
}
|
|
|
|
async function loadDetail(id: string) {
|
|
detailLoading.value = true
|
|
try {
|
|
selected.value = (await http.get(`/curriculum-plans/${id}`)).data
|
|
} catch (error) {
|
|
ElMessage.error(apiErrorMessage(error))
|
|
} finally {
|
|
detailLoading.value = false
|
|
}
|
|
}
|
|
|
|
async function loadCourseGroups() {
|
|
try {
|
|
courseGroups.value = (await http.get('/course-groups')).data
|
|
} catch (error) {
|
|
ElMessage.error(apiErrorMessage(error))
|
|
}
|
|
}
|
|
|
|
function openCourseGroups() {
|
|
courseGroupDialog.value = true
|
|
openCourseGroup(activeCourseGroupId.value || undefined)
|
|
}
|
|
|
|
function openCourseGroup(id?: string) {
|
|
activeCourseGroupId.value = id ?? ''
|
|
const group = courseGroups.value.find((item) => item.id === id)
|
|
Object.assign(courseGroupForm, {
|
|
code: group?.code ?? '', name: group?.name ?? '', description: group?.description ?? '',
|
|
})
|
|
Object.assign(courseGroupCourseForm, { courseId: undefined, recommendedSemester: 1 })
|
|
}
|
|
|
|
async function saveCourseGroup() {
|
|
if (!courseGroupForm.code?.trim() || !courseGroupForm.name?.trim()) {
|
|
ElMessage.warning(t('curriculumScript.k7'))
|
|
return
|
|
}
|
|
try {
|
|
if (activeCourseGroupId.value) {
|
|
await http.put(`/course-groups/${activeCourseGroupId.value}`, courseGroupForm)
|
|
} else {
|
|
const { data } = await http.post('/course-groups', courseGroupForm)
|
|
activeCourseGroupId.value = data.id
|
|
}
|
|
await loadCourseGroups()
|
|
openCourseGroup(activeCourseGroupId.value)
|
|
ElMessage.success(t('curriculumScript.k8'))
|
|
} catch (error) { ElMessage.error(apiErrorMessage(error)) }
|
|
}
|
|
|
|
async function deleteCourseGroup() {
|
|
if (!activeCourseGroup.value) return
|
|
try {
|
|
await ElMessageBox.confirm(t('curriculumScript.deleteGroup', { name: activeCourseGroup.value.name }), t('curriculumScript.k9'), { type: 'warning' })
|
|
await http.delete(`/course-groups/${activeCourseGroupId.value}`)
|
|
await loadCourseGroups()
|
|
openCourseGroup()
|
|
} catch (error: any) {
|
|
if (error !== 'cancel' && error !== 'close') ElMessage.error(apiErrorMessage(error))
|
|
}
|
|
}
|
|
|
|
async function addCourseToGroup() {
|
|
if (!activeCourseGroupId.value || !courseGroupCourseForm.courseId) return
|
|
try {
|
|
await http.post(`/course-groups/${activeCourseGroupId.value}/courses`, courseGroupCourseForm)
|
|
await loadCourseGroups()
|
|
openCourseGroup(activeCourseGroupId.value)
|
|
} catch (error) { ElMessage.error(apiErrorMessage(error)) }
|
|
}
|
|
|
|
async function updateCourseGroupCourseSemester(course: any) {
|
|
try {
|
|
await http.put(
|
|
`/course-groups/${activeCourseGroupId.value}/courses/${course.courseId}`,
|
|
{ recommendedSemester: course.recommendedSemester },
|
|
)
|
|
ElMessage.success(t('curriculumScript.k10'))
|
|
} catch (error) {
|
|
await loadCourseGroups()
|
|
openCourseGroup(activeCourseGroupId.value)
|
|
ElMessage.error(apiErrorMessage(error))
|
|
}
|
|
}
|
|
|
|
async function removeCourseFromGroup(courseId: string) {
|
|
try {
|
|
await http.delete(`/course-groups/${activeCourseGroupId.value}/courses/${courseId}`)
|
|
await loadCourseGroups()
|
|
openCourseGroup(activeCourseGroupId.value)
|
|
} catch (error) { ElMessage.error(apiErrorMessage(error)) }
|
|
}
|
|
|
|
function openCourseGroupImport(moduleId: string) {
|
|
activeModuleId.value = moduleId
|
|
Object.assign(courseGroupImportForm, {
|
|
courseGroupId: courseGroups.value[0]?.id, type: 'Elective', notes: '',
|
|
})
|
|
courseGroupImportDialog.value = true
|
|
}
|
|
|
|
async function importCourseGroup() {
|
|
if (!courseGroupImportForm.courseGroupId) {
|
|
ElMessage.warning(t('curriculumScript.k11'))
|
|
return
|
|
}
|
|
if (!await confirmPublishedChange(t('curriculumScript.k12'))) return
|
|
try {
|
|
await http.post(`/curriculum-plans/${selected.value.id}/modules/${activeModuleId.value}/course-groups/${courseGroupImportForm.courseGroupId}`, courseGroupImportForm)
|
|
courseGroupImportDialog.value = false
|
|
await loadDetail(selected.value.id)
|
|
ElMessage.success(t('curriculumScript.k13'))
|
|
} catch (error) { ElMessage.error(apiErrorMessage(error)) }
|
|
}
|
|
|
|
function resetFilters() {
|
|
Object.assign(query, {
|
|
page: 1,
|
|
keyword: '',
|
|
collegeId: isCollegeAdmin.value ? auth.user?.collegeId : undefined,
|
|
majorId: undefined,
|
|
effectiveGrade: undefined,
|
|
status: undefined,
|
|
})
|
|
resetCursor()
|
|
loadPlans(false)
|
|
}
|
|
|
|
function changeCollege() {
|
|
if (query.majorId &&
|
|
!filteredMajors.value.some((item) => item.id === query.majorId)) {
|
|
query.majorId = undefined
|
|
}
|
|
}
|
|
|
|
function openPlan(row?: any) {
|
|
editingPlanId.value = row?.id ?? ''
|
|
editingPlanStatus.value = row?.status ?? ''
|
|
Object.keys(planForm).forEach((key) => delete planForm[key])
|
|
Object.assign(planForm, {
|
|
majorId: row?.majorId,
|
|
name: row?.name ?? '',
|
|
version: row?.version ?? `${new Date().getFullYear()}版`,
|
|
effectiveGrade: row?.effectiveGrade ?? new Date().getFullYear(),
|
|
totalCredits: row?.totalCredits ?? 160,
|
|
description: row?.description ?? '',
|
|
})
|
|
planDialog.value = true
|
|
}
|
|
|
|
async function confirmPublishedChange(action: string) {
|
|
if (!isPublished.value) return true
|
|
try {
|
|
await ElMessageBox.confirm(
|
|
t('curriculumScript.publishedChange', { action }),
|
|
t('curriculumScript.k14'),
|
|
{
|
|
type: 'warning',
|
|
confirmButtonText: t('curriculumScript.k15'),
|
|
cancelButtonText: t('curriculumScript.k16'),
|
|
},
|
|
)
|
|
return true
|
|
} catch {
|
|
return false
|
|
}
|
|
}
|
|
|
|
async function savePlan() {
|
|
if (!planForm.majorId || !planForm.name?.trim() || !planForm.version?.trim()) {
|
|
ElMessage.warning(t('curriculumScript.k17'))
|
|
return
|
|
}
|
|
if (editingPlanId.value && !await confirmPublishedChange(t('curriculumScript.k18'))) return
|
|
try {
|
|
if (editingPlanId.value) {
|
|
await http.put(`/curriculum-plans/${editingPlanId.value}`, planForm)
|
|
} else {
|
|
await http.post('/curriculum-plans', planForm)
|
|
}
|
|
ElMessage.success(editingPlanId.value ? t('curriculumScript.k19') : t('curriculumScript.k20'))
|
|
planDialog.value = false
|
|
await loadPlans(false)
|
|
} catch (error) {
|
|
ElMessage.error(apiErrorMessage(error))
|
|
}
|
|
}
|
|
|
|
function openClone() {
|
|
Object.assign(cloneForm, {
|
|
name: selected.value.name,
|
|
version: `${new Date().getFullYear()}版`,
|
|
effectiveGrade: Math.max(new Date().getFullYear(), selected.value.effectiveGrade + 1),
|
|
})
|
|
cloneDialog.value = true
|
|
}
|
|
|
|
async function clonePlan() {
|
|
try {
|
|
await http.post(`/curriculum-plans/${selected.value.id}/clone`, cloneForm)
|
|
ElMessage.success(t('curriculumScript.k21'))
|
|
cloneDialog.value = false
|
|
await loadPlans(false)
|
|
} catch (error) {
|
|
ElMessage.error(apiErrorMessage(error))
|
|
}
|
|
}
|
|
|
|
async function publishPlan() {
|
|
try {
|
|
await ElMessageBox.confirm(
|
|
t('curriculumScript.k22'),
|
|
t('curriculumScript.k23'),
|
|
{ type: 'warning', confirmButtonText: t('curriculumScript.k24'), cancelButtonText: t('curriculumScript.k16') },
|
|
)
|
|
await http.post(`/curriculum-plans/${selected.value.id}/publish`)
|
|
ElMessage.success(t('curriculumScript.publishedSuccess'))
|
|
await loadPlans()
|
|
} catch (error: any) {
|
|
if (error !== 'cancel' && error !== 'close') ElMessage.error(apiErrorMessage(error))
|
|
}
|
|
}
|
|
|
|
async function deletePlan() {
|
|
try {
|
|
await ElMessageBox.confirm(t('curriculumScript.k25'), t('curriculumScript.k26'), {
|
|
type: 'warning',
|
|
confirmButtonText: t('curriculumScript.k27'),
|
|
cancelButtonText: t('curriculumScript.k16'),
|
|
})
|
|
await http.delete(`/curriculum-plans/${selected.value.id}`)
|
|
ElMessage.success(t('curriculumScript.k28'))
|
|
await loadPlans(false)
|
|
} catch (error: any) {
|
|
if (error !== 'cancel' && error !== 'close') ElMessage.error(apiErrorMessage(error))
|
|
}
|
|
}
|
|
|
|
function openModule(module?: any) {
|
|
editingModuleId.value = module?.id ?? ''
|
|
Object.assign(moduleForm, {
|
|
code: module?.code ?? '',
|
|
name: module?.name ?? '',
|
|
requiredCredits: module?.requiredCredits ?? 0,
|
|
sortOrder: module?.sortOrder ?? (selected.value.modules.length + 1) * 10,
|
|
})
|
|
moduleDialog.value = true
|
|
}
|
|
|
|
async function saveModule() {
|
|
if (!moduleForm.code?.trim() || !moduleForm.name?.trim()) {
|
|
ElMessage.warning(t('curriculumScript.k29'))
|
|
return
|
|
}
|
|
if (!await confirmPublishedChange(t('curriculumScript.k30'))) return
|
|
try {
|
|
const base = `/curriculum-plans/${selected.value.id}/modules`
|
|
if (editingModuleId.value) await http.put(`${base}/${editingModuleId.value}`, moduleForm)
|
|
else await http.post(base, moduleForm)
|
|
moduleDialog.value = false
|
|
await loadDetail(selected.value.id)
|
|
} catch (error) {
|
|
ElMessage.error(apiErrorMessage(error))
|
|
}
|
|
}
|
|
|
|
async function deleteModule(module: any) {
|
|
try {
|
|
const impact = isPublished.value
|
|
? t('curriculumScript.k31')
|
|
: ''
|
|
await ElMessageBox.confirm(t('curriculumScript.deleteModule', { name: module.name, impact }), t('curriculumScript.k32'), {
|
|
type: 'warning',
|
|
})
|
|
await http.delete(`/curriculum-plans/${selected.value.id}/modules/${module.id}`)
|
|
await loadDetail(selected.value.id)
|
|
} catch (error: any) {
|
|
if (error !== 'cancel' && error !== 'close') ElMessage.error(apiErrorMessage(error))
|
|
}
|
|
}
|
|
|
|
function openCourse(moduleId: string, item?: any) {
|
|
activeModuleId.value = moduleId
|
|
editingCourseId.value = item?.id ?? ''
|
|
Object.assign(courseForm, {
|
|
courseId: item?.courseId,
|
|
recommendedSemester: item?.recommendedSemester ?? 1,
|
|
type: item?.type ?? 'Required',
|
|
notes: item?.notes ?? '',
|
|
})
|
|
courseDialog.value = true
|
|
}
|
|
|
|
async function saveCourse() {
|
|
if (!courseForm.courseId) {
|
|
ElMessage.warning(t('curriculumScript.k33'))
|
|
return
|
|
}
|
|
if (!await confirmPublishedChange(t('curriculumScript.k34'))) return
|
|
try {
|
|
const base = `/curriculum-plans/${selected.value.id}/modules/${activeModuleId.value}/courses`
|
|
if (editingCourseId.value) await http.put(`${base}/${editingCourseId.value}`, courseForm)
|
|
else await http.post(base, courseForm)
|
|
courseDialog.value = false
|
|
await loadDetail(selected.value.id)
|
|
} catch (error) {
|
|
ElMessage.error(apiErrorMessage(error))
|
|
}
|
|
}
|
|
|
|
async function deleteCourse(moduleId: string, item: any) {
|
|
try {
|
|
const impact = isPublished.value
|
|
? t('curriculumScript.k35')
|
|
: ''
|
|
await ElMessageBox.confirm(t('curriculumScript.removeCourse', { name: item.courseName, impact }), t('curriculumScript.k36'), {
|
|
type: 'warning',
|
|
})
|
|
await http.delete(
|
|
`/curriculum-plans/${selected.value.id}/modules/${moduleId}/courses/${item.id}`,
|
|
)
|
|
await loadDetail(selected.value.id)
|
|
} catch (error: any) {
|
|
if (error !== 'cancel' && error !== 'close') ElMessage.error(apiErrorMessage(error))
|
|
}
|
|
}
|
|
|
|
onMounted(async () => {
|
|
const [optionRes, courseRes] = await Promise.all([
|
|
http.get('/curriculum-plans/filter-options'),
|
|
http.get('/curriculum-plans/course-options'),
|
|
loadCourseGroups(),
|
|
])
|
|
colleges.value = optionRes.data.colleges
|
|
majors.value = optionRes.data.majors
|
|
grades.value = optionRes.data.grades
|
|
courses.value = courseRes.data
|
|
if (isCollegeAdmin.value && auth.user?.collegeId) {
|
|
query.collegeId = auth.user.collegeId
|
|
}
|
|
await loadPlans(false)
|
|
})
|
|
</script>
|
|
|
|
<template>
|
|
<div class="page-stack">
|
|
<section class="page-intro">
|
|
<div>
|
|
<span class="section-kicker">PROGRAMME OF STUDY</span>
|
|
<h2>{{ t('dashboard.admin.actions.curriculum.label') }}</h2>
|
|
<p>{{ t('curriculumTemplate.k0') }}</p>
|
|
</div>
|
|
<div class="page-intro-actions">
|
|
<el-button v-if="canManageCourseGroups" :icon="Collection" @click="openCourseGroups">{{ t('batchBusiness.k133') }}</el-button>
|
|
<el-button type="primary" :icon="Plus" @click="openPlan()">{{ t('workflowBatch.k3') }}</el-button>
|
|
</div>
|
|
</section>
|
|
|
|
<section class="maintenance-scope" :aria-label="t('batchBusiness.k115')">
|
|
<div>
|
|
<span>{{ t('curriculumTemplate.k1') }}</span>
|
|
<b>{{ isCollegeAdmin ? t('graduationClearance.roleOptions.college') : t('curriculumTemplate.k2') }}</b>
|
|
</div>
|
|
<div>
|
|
<span>{{ t('curriculumTemplate.k3') }}</span>
|
|
<b>{{ maintenanceScope }}</b>
|
|
</div>
|
|
<p>
|
|
{{ isCollegeAdmin
|
|
? t('curriculumTemplate.k4')
|
|
: t('curriculumTemplate.k5') }}
|
|
</p>
|
|
</section>
|
|
|
|
<section class="curriculum-filter">
|
|
<el-input v-model="query.keyword" :prefix-icon="Search" clearable :placeholder="t('batchBusiness.k116')" @keyup.enter="resetCursor(); loadPlans(false)" />
|
|
<el-select
|
|
v-model="query.effectiveGrade"
|
|
clearable
|
|
:placeholder="t('businessLabels.allGrades')"
|
|
>
|
|
<el-option v-for="grade in availableGrades" :key="grade" :label="t('curriculumTemplate.k38', { grade })" :value="grade" />
|
|
</el-select>
|
|
<el-select
|
|
v-model="query.collegeId"
|
|
clearable
|
|
:disabled="isCollegeAdmin"
|
|
:placeholder="t('businessLabels.allColleges')"
|
|
@change="changeCollege"
|
|
>
|
|
<el-option v-for="item in colleges" :key="item.id" :label="item.name" :value="item.id" />
|
|
</el-select>
|
|
<el-select v-model="query.majorId" clearable filterable :placeholder="t('businessLabels.allMajors')">
|
|
<el-option v-for="item in filteredMajors" :key="item.id" :label="item.name" :value="item.id" />
|
|
</el-select>
|
|
<el-select v-model="query.status" clearable :placeholder="t('businessLabels.allStatus')">
|
|
<el-option v-for="(label, value) in statusLabels" :key="value" :label="label" :value="value" />
|
|
</el-select>
|
|
<el-button type="primary" @click="resetCursor(); loadPlans(false)">{{ t('businessLabels.search') }}</el-button>
|
|
<el-button :icon="Refresh" @click="resetFilters">{{ t('businessLabels.reset') }}</el-button>
|
|
</section>
|
|
|
|
<div class="curriculum-workspace">
|
|
<aside v-loading="loading" class="plan-list">
|
|
<button
|
|
v-for="plan in plans"
|
|
:key="plan.id"
|
|
type="button"
|
|
:class="{ active: selected?.id === plan.id }"
|
|
@click="loadDetail(plan.id)"
|
|
>
|
|
<span>{{ t('curriculumTemplate.k39', { major: plan.majorName, grade: plan.effectiveGrade }) }}</span>
|
|
<b>{{ plan.name }}</b>
|
|
<small>{{ plan.version }} · {{ plan.courseCount }} {{ t('courses.coursesUnit') }}</small>
|
|
<i :class="plan.status.toLowerCase()">{{ statusLabels[plan.status] }}</i>
|
|
</button>
|
|
<el-empty v-if="!loading && plans.length === 0" :description="t('batchBusiness.k117')" :image-size="70" />
|
|
<div class="plan-pagination">
|
|
<span>{{ t('curriculumTemplate.k40', { count: total }) }}</span>
|
|
<div v-if="cursors.length || hasMore" class="cursor-pager"><el-button size="small" :disabled="!cursors.length || loading" @click="previousPage">{{ t('businessLabels.previous') }}</el-button><span>{{ t('curriculumTemplate.k41', { page: query.page }) }}</span><el-button size="small" type="primary" :disabled="!hasMore || loading" @click="nextPage">{{ t('businessLabels.next') }}</el-button></div>
|
|
</div>
|
|
</aside>
|
|
|
|
<main v-loading="detailLoading" class="plan-detail">
|
|
<el-empty v-if="!selected" :description="t('batchBusiness.k118')" />
|
|
<template v-else>
|
|
<header class="plan-detail-head">
|
|
<div>
|
|
<span>{{ selected.collegeName }} / {{ selected.majorName }}</span>
|
|
<h3>{{ selected.name }}</h3>
|
|
<p>{{ t('curriculumTemplate.k42', { version: selected.version, grade: selected.effectiveGrade, years: selected.schoolingYears }) }}</p>
|
|
</div>
|
|
<div class="plan-actions">
|
|
<el-button v-if="canEdit" @click="openPlan(selected)">{{ t('businessLabels.edit') }}</el-button>
|
|
<el-button :icon="CopyDocument" @click="openClone">{{ t('curriculumTemplate.k6') }}</el-button>
|
|
<el-button v-if="isDraft" type="success" :icon="Promotion" @click="publishPlan">{{ t('businessLabels.publish') }}</el-button>
|
|
<el-button v-if="isDraft" type="danger" plain @click="deletePlan">{{ t('businessLabels.delete') }}</el-button>
|
|
</div>
|
|
</header>
|
|
|
|
<el-alert
|
|
v-if="isPublished"
|
|
class="published-edit-notice"
|
|
type="warning"
|
|
show-icon
|
|
:closable="false"
|
|
:title="t('curriculumTemplate.k7')"
|
|
/>
|
|
|
|
<div class="plan-metrics">
|
|
<div><span>{{ t('curriculumTemplate.k8') }}</span><b>{{ statusLabels[selected.status] }}</b></div>
|
|
<div><span>{{ t('curriculumTemplate.k9') }}</span><b>{{ selected.totalCredits }}</b></div>
|
|
<div><span>{{ t('curriculumTemplate.k10') }}</span><b :class="{ warning: configuredCredits !== Number(selected.totalCredits) }">{{ configuredCredits }}</b></div>
|
|
<div><span>{{ t('curriculumTemplate.k11') }}</span><b>{{ selected.modules.reduce((sum: number, item: any) => sum + item.courses.length, 0) }}</b></div>
|
|
</div>
|
|
|
|
<div class="module-toolbar">
|
|
<div>
|
|
<b>{{ detailView === 'structure' ? t('curriculumTemplate.k12') : t('curriculumTemplate.k13') }}</b>
|
|
<span>{{ detailView === 'structure'
|
|
? t('curriculumTemplate.k14')
|
|
: t('curriculumTemplate.k15') }}</span>
|
|
</div>
|
|
<div class="curriculum-view-actions">
|
|
<el-radio-group v-model="detailView" size="small" :aria-label="t('batchBusiness.k119')">
|
|
<el-radio-button value="structure">{{ t('curriculumTemplate.k12') }}</el-radio-button>
|
|
<el-radio-button value="semester">{{ t('curriculumTemplate.k13') }}</el-radio-button>
|
|
</el-radio-group>
|
|
<el-button v-if="canEdit && detailView === 'structure'" :icon="Plus" @click="openModule()">{{ t('curriculumTemplate.k16') }}</el-button>
|
|
</div>
|
|
</div>
|
|
|
|
<template v-if="detailView === 'structure'">
|
|
<section v-for="module in selected.modules" :key="module.id" class="curriculum-module">
|
|
<header>
|
|
<div>
|
|
<span>{{ module.code }}</span>
|
|
<h4>{{ module.name }}</h4>
|
|
</div>
|
|
<p>
|
|
{{ t('curriculumTemplate.k43', { required: module.requiredCredits, assigned: module.assignedCredits }) }}
|
|
<template v-if="module.courses.some((course: any) => course.type === 'Elective')">
|
|
{{ t('curriculumTemplate.k44') }}
|
|
</template>
|
|
</p>
|
|
<div v-if="canEdit">
|
|
<el-button link type="primary" @click="openModule(module)">{{ t('businessLabels.edit') }}</el-button>
|
|
<el-button link type="danger" @click="deleteModule(module)">{{ t('businessLabels.delete') }}</el-button>
|
|
<el-button size="small" @click="openCourseGroupImport(module.id)">{{ t('curriculumTemplate.k17') }}</el-button>
|
|
<el-button size="small" :icon="Plus" @click="openCourse(module.id)">{{ t('curriculumTemplate.k18') }}</el-button>
|
|
</div>
|
|
</header>
|
|
<el-table :data="module.courses" class="curriculum-course-table">
|
|
<el-table-column prop="courseCode" :label="t('courses.code')" width="115" />
|
|
<el-table-column :label="t('businessLabels.courseName')" min-width="180">
|
|
<template #default="{ row }"><b>{{ row.courseName }}</b></template>
|
|
</el-table-column>
|
|
<el-table-column :label="t('batchBusiness.k9')" width="80">
|
|
<template #default="{ row }">{{ courseTypeLabels[row.type] }}</template>
|
|
</el-table-column>
|
|
<el-table-column :label="t('courses.category')" width="100">
|
|
<template #default="{ row }">{{ row.categoryName || t('courses.uncategorized') }}</template>
|
|
</el-table-column>
|
|
<el-table-column prop="credits" :label="t('businessLabels.credits')" width="70" />
|
|
<el-table-column prop="totalHours" :label="t('businessLabels.hours')" width="70" />
|
|
<el-table-column :label="t('studentCurriculum.recommendedTerm')" width="90">
|
|
<template #default="{ row }">{{ t('curriculumTemplate.k45', { semester: row.recommendedSemester }) }}</template>
|
|
</el-table-column>
|
|
<el-table-column v-if="canEdit" :label="t('businessLabels.actions')" width="120">
|
|
<template #default="{ row }">
|
|
<el-button link type="primary" @click="openCourse(module.id, row)">{{ t('businessLabels.edit') }}</el-button>
|
|
<el-button link type="danger" @click="deleteCourse(module.id, row)">{{ t('businessLabels.remove') }}</el-button>
|
|
</template>
|
|
</el-table-column>
|
|
<template #empty><el-empty :description="t('batchBusiness.k120')" :image-size="54" /></template>
|
|
</el-table>
|
|
</section>
|
|
<el-empty v-if="selected.modules.length === 0" :description="t('batchBusiness.k121')" />
|
|
</template>
|
|
|
|
<section v-else class="semester-view" :aria-label="t('batchBusiness.k122')">
|
|
<article v-for="group in semesterGroups" :key="group.semester" class="semester-card">
|
|
<header>
|
|
<div>
|
|
<span>SEMESTER {{ String(group.semester).padStart(2, '0') }}</span>
|
|
<h4>{{ t('curriculumTemplate.k45', { semester: group.semester }) }}</h4>
|
|
</div>
|
|
<b>{{ group.courses.length }} {{ t('studentCurriculum.courseUnit') }}</b>
|
|
</header>
|
|
<div class="semester-summary">
|
|
<span>{{ t('curriculumTemplate.k46', { credits: group.credits }) }}</span>
|
|
<span>{{ group.totalHours }} {{ t('businessLabels.hours') }}</span>
|
|
</div>
|
|
<ul v-if="group.courses.length" class="semester-courses">
|
|
<li v-for="course in group.courses" :key="course.id">
|
|
<div>
|
|
<span>{{ course.moduleName }}</span>
|
|
<b>{{ course.courseName }}</b>
|
|
<small>{{ course.courseCode }} · {{ courseTypeLabels[course.type] }}</small>
|
|
</div>
|
|
<strong>{{ course.credits }}<small>{{ t('businessLabels.credits') }}</small></strong>
|
|
</li>
|
|
</ul>
|
|
<p v-else class="semester-empty">{{ t('curriculumTemplate.k19') }}</p>
|
|
</article>
|
|
</section>
|
|
</template>
|
|
</main>
|
|
</div>
|
|
|
|
<el-dialog v-model="planDialog" :title="editingPlanId ? t('curriculumTemplate.k20') : t('curriculumTemplate.k21')" width="620px">
|
|
<el-alert
|
|
v-if="isEditingPublished"
|
|
type="warning"
|
|
show-icon
|
|
:closable="false"
|
|
:title="t('curriculumTemplate.k22')"
|
|
/>
|
|
<el-form label-position="top">
|
|
<el-form-item :label="t('batchBusiness.k123')" required>
|
|
<el-select v-model="planForm.majorId" filterable :disabled="isEditingPublished"><el-option v-for="item in availableMajors" :key="item.id" :label="item.name" :value="item.id" /></el-select>
|
|
</el-form-item>
|
|
<el-form-item :label="t('batchBusiness.k8')" required><el-input v-model="planForm.name" /></el-form-item>
|
|
<div class="form-grid">
|
|
<el-form-item :label="t('batchBusiness.k14')" required><el-input v-model="planForm.version" :disabled="isEditingPublished" /></el-form-item>
|
|
<el-form-item :label="t('batchBusiness.k124')" required><el-input-number v-model="planForm.effectiveGrade" :min="2000" :max="2200" :disabled="isEditingPublished" /></el-form-item>
|
|
</div>
|
|
<el-form-item :label="t('batchBusiness.k125')" required><el-input-number v-model="planForm.totalCredits" :min="0.1" :precision="1" :step="0.5" /></el-form-item>
|
|
<el-form-item :label="t('batchBusiness.k126')"><el-input v-model="planForm.description" type="textarea" :rows="3" /></el-form-item>
|
|
</el-form>
|
|
<template #footer><el-button @click="planDialog = false">{{ t('businessLabels.cancel') }}</el-button><el-button type="primary" @click="savePlan">{{ t('businessLabels.save') }}</el-button></template>
|
|
</el-dialog>
|
|
|
|
<el-dialog v-model="cloneDialog" :title="t('batchBusiness.k127')" width="520px">
|
|
<p class="form-help">{{ t('curriculumTemplate.k23') }}</p>
|
|
<el-form label-position="top">
|
|
<el-form-item :label="t('batchBusiness.k8')" required><el-input v-model="cloneForm.name" /></el-form-item>
|
|
<div class="form-grid">
|
|
<el-form-item :label="t('batchBusiness.k15')" required><el-input v-model="cloneForm.version" /></el-form-item>
|
|
<el-form-item :label="t('batchBusiness.k124')" required><el-input-number v-model="cloneForm.effectiveGrade" :min="2000" :max="2200" /></el-form-item>
|
|
</div>
|
|
</el-form>
|
|
<template #footer><el-button @click="cloneDialog = false">{{ t('businessLabels.cancel') }}</el-button><el-button type="primary" @click="clonePlan">{{ t('curriculumTemplate.k24') }}</el-button></template>
|
|
</el-dialog>
|
|
|
|
<el-dialog v-model="moduleDialog" :title="editingModuleId ? t('curriculumTemplate.k25') : t('curriculumTemplate.k26')" width="520px">
|
|
<el-form label-position="top">
|
|
<div class="form-grid">
|
|
<el-form-item :label="t('batchBusiness.k128')" required><el-input v-model="moduleForm.code" /></el-form-item>
|
|
<el-form-item :label="t('courses.sortOrder')"><el-input-number v-model="moduleForm.sortOrder" :min="0" /></el-form-item>
|
|
</div>
|
|
<el-form-item :label="t('batchBusiness.k129')" required><el-input v-model="moduleForm.name" /></el-form-item>
|
|
<el-form-item :label="t('batchBusiness.k130')">
|
|
<el-input-number v-model="moduleForm.requiredCredits" :min="0" :precision="1" :step="0.5" />
|
|
<span class="form-help">{{ t('curriculumTemplate.k27') }}</span>
|
|
</el-form-item>
|
|
</el-form>
|
|
<template #footer><el-button @click="moduleDialog = false">{{ t('businessLabels.cancel') }}</el-button><el-button type="primary" @click="saveModule">{{ t('businessLabels.save') }}</el-button></template>
|
|
</el-dialog>
|
|
|
|
<el-dialog v-model="courseDialog" :title="editingCourseId ? t('curriculumTemplate.k28') : t('curriculumTemplate.k29')" width="560px">
|
|
<el-form label-position="top">
|
|
<el-form-item :label="t('businessLabels.course')" required>
|
|
<el-select v-model="courseForm.courseId" filterable>
|
|
<el-option v-for="item in courses" :key="item.id" :label="`${item.code} · ${item.name}${item.categoryName ? ` · ${item.categoryName}` : ''}`" :value="item.id" />
|
|
</el-select>
|
|
</el-form-item>
|
|
<div class="form-grid">
|
|
<el-form-item :label="t('batchBusiness.k131')"><el-select v-model="courseForm.type"><el-option v-for="(label, value) in courseTypeLabels" :key="value" :label="label" :value="value" /></el-select></el-form-item>
|
|
<el-form-item :label="t('studentCurriculum.recommendedTerm')"><el-input-number v-model="courseForm.recommendedSemester" :min="1" :max="selected?.schoolingYears * 2" /></el-form-item>
|
|
</div>
|
|
<el-form-item :label="t('businessLabels.notes')"><el-input v-model="courseForm.notes" type="textarea" :rows="2" /></el-form-item>
|
|
<div class="course-rule-help">
|
|
<b>{{ t('studentCurriculum.types.Required') }}</b><span>{{ t('curriculumTemplate.k30') }}</span>
|
|
<b>{{ t('studentCurriculum.types.Elective') }}</b><span>{{ t('curriculumTemplate.k31') }}</span>
|
|
</div>
|
|
</el-form>
|
|
<template #footer><el-button @click="courseDialog = false">{{ t('businessLabels.cancel') }}</el-button><el-button type="primary" @click="saveCourse">{{ t('businessLabels.save') }}</el-button></template>
|
|
</el-dialog>
|
|
|
|
<el-dialog v-model="courseGroupImportDialog" :title="t('batchBusiness.k132')" width="560px">
|
|
<el-alert type="info" :closable="false" show-icon :title="t('curriculumTemplate.k32')" />
|
|
<el-form label-position="top">
|
|
<el-form-item :label="t('batchBusiness.k133')" required>
|
|
<el-select v-model="courseGroupImportForm.courseGroupId" filterable>
|
|
<el-option v-for="group in courseGroups" :key="group.id" :label="t('curriculumTemplate.k47', { code: group.code, name: group.name, count: group.courseCount })" :value="group.id" />
|
|
</el-select>
|
|
</el-form-item>
|
|
<p v-if="importingCourseGroup" class="form-help">{{ t('curriculumTemplate.k48', { courses: importingCourseGroup.courses.map((course: any) => course.courseName).join(t('academicPlanning.separator')) }) }}</p>
|
|
<el-form-item :label="t('batchBusiness.k131')"><el-select v-model="courseGroupImportForm.type"><el-option v-for="(label, value) in courseTypeLabels" :key="value" :label="label" :value="value" /></el-select></el-form-item>
|
|
<el-form-item :label="t('batchBusiness.k134')"><el-input v-model="courseGroupImportForm.notes" type="textarea" :rows="2" /></el-form-item>
|
|
</el-form>
|
|
<template #footer><el-button @click="courseGroupImportDialog = false">{{ t('businessLabels.cancel') }}</el-button><el-button type="primary" @click="importCourseGroup">{{ t('curriculumTemplate.k33') }}</el-button></template>
|
|
</el-dialog>
|
|
|
|
<el-dialog v-model="courseGroupDialog" :title="t('batchBusiness.k135')" width="920px">
|
|
<div class="course-group-manager">
|
|
<aside>
|
|
<el-button type="primary" :icon="Plus" @click="openCourseGroup()">{{ t('curriculumTemplate.k34') }}</el-button>
|
|
<button v-for="group in courseGroups" :key="group.id" type="button" :class="{ active: activeCourseGroupId === group.id }" @click="openCourseGroup(group.id)">
|
|
<span>{{ group.code }}</span><b>{{ group.name }}</b><small>{{ group.courseCount }} {{ t('courses.coursesUnit') }}</small>
|
|
</button>
|
|
</aside>
|
|
<main>
|
|
<el-form label-position="top">
|
|
<div class="form-grid">
|
|
<el-form-item :label="t('batchBusiness.k136')" required><el-input v-model="courseGroupForm.code" /></el-form-item>
|
|
<el-form-item :label="t('batchBusiness.k137')" required><el-input v-model="courseGroupForm.name" /></el-form-item>
|
|
</div>
|
|
<el-form-item :label="t('businessLabels.description')"><el-input v-model="courseGroupForm.description" type="textarea" :rows="2" /></el-form-item>
|
|
</el-form>
|
|
<div class="course-group-actions"><el-button type="primary" @click="saveCourseGroup">{{ t('curriculumTemplate.k35') }}</el-button><el-button v-if="activeCourseGroup" type="danger" plain @click="deleteCourseGroup">{{ t('businessLabels.delete') }}</el-button></div>
|
|
<div v-if="activeCourseGroup" class="course-group-add">
|
|
<b>{{ t('curriculumTemplate.k36') }}</b>
|
|
<el-select v-model="courseGroupCourseForm.courseId" filterable :placeholder="t('batchBusiness.k138')"><el-option v-for="course in courses" :key="course.id" :label="`${course.code} · ${course.name}`" :value="course.id" /></el-select>
|
|
<el-input-number v-model="courseGroupCourseForm.recommendedSemester" :min="1" :max="20" :placeholder="t('studentCurriculum.recommendedTerm')" :aria-label="t('batchBusiness.k139')" />
|
|
<el-button type="primary" @click="addCourseToGroup">{{ t('curriculumTemplate.k37') }}</el-button>
|
|
</div>
|
|
<el-table v-if="activeCourseGroup" :data="activeCourseGroup.courses">
|
|
<el-table-column prop="courseCode" :label="t('courses.code')" width="120" />
|
|
<el-table-column prop="courseName" :label="t('businessLabels.courseName')" />
|
|
<el-table-column prop="credits" :label="t('businessLabels.credits')" width="80" />
|
|
<el-table-column :label="t('studentCurriculum.recommendedTerm')" width="150"><template #default="{ row }"><el-input-number v-model="row.recommendedSemester" :min="1" :max="20" size="small" @change="updateCourseGroupCourseSemester(row)" /></template></el-table-column>
|
|
<el-table-column :label="t('businessLabels.actions')" width="80"><template #default="{ row }"><el-button link type="danger" @click="removeCourseFromGroup(row.courseId)">{{ t('businessLabels.remove') }}</el-button></template></el-table-column>
|
|
</el-table>
|
|
</main>
|
|
</div>
|
|
</el-dialog>
|
|
</div>
|
|
</template>
|