已发布方案可修改名称、总学分、说明、课程模块及课程配置。
适用专业、入学年级、版本号保持锁定;前端禁用,后端也会返回 409 拒绝篡改。 归档方案仍只读。 修改已发布方案前增加即时生效警示和二次确认。
This commit is contained in:
@@ -276,6 +276,7 @@ button { cursor: pointer; }
|
||||
.plan-detail-head p { margin: 0; color: var(--muted); font-size: 11px; }
|
||||
.plan-actions { display: flex; flex-wrap: wrap; align-content: flex-start; justify-content: flex-end; gap: 7px; }
|
||||
.plan-actions .el-button + .el-button { margin-left: 0; }
|
||||
.published-edit-notice { margin-top: 16px; border-radius: 0; }
|
||||
.plan-metrics { margin: 18px 0; display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); }
|
||||
.plan-metrics > div { padding: 15px 17px; border-right: 1px solid var(--line); }
|
||||
.plan-metrics > div:last-child { border-right: none; }
|
||||
|
||||
@@ -19,6 +19,7 @@ const moduleDialog = ref(false)
|
||||
const courseDialog = ref(false)
|
||||
const cloneDialog = ref(false)
|
||||
const editingPlanId = ref('')
|
||||
const editingPlanStatus = ref('')
|
||||
const editingModuleId = ref('')
|
||||
const editingCourseId = ref('')
|
||||
const activeModuleId = ref('')
|
||||
@@ -64,6 +65,9 @@ const maintenanceScope = computed(() =>
|
||||
: '全校各学院',
|
||||
)
|
||||
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 configuredCredits = computed(() =>
|
||||
selected.value?.modules.reduce(
|
||||
(sum: number, module: any) => sum + Number(module.requiredCredits),
|
||||
@@ -129,6 +133,7 @@ function changeCollege() {
|
||||
|
||||
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,
|
||||
@@ -141,11 +146,30 @@ function openPlan(row?: any) {
|
||||
planDialog.value = true
|
||||
}
|
||||
|
||||
async function confirmPublishedChange(action: string) {
|
||||
if (!isPublished.value) return true
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`${action}保存后会立即影响学生端培养方案展示及毕业审核依据。确定继续吗?`,
|
||||
'修改已发布方案',
|
||||
{
|
||||
type: 'warning',
|
||||
confirmButtonText: '确认修改',
|
||||
cancelButtonText: '取消',
|
||||
},
|
||||
)
|
||||
return true
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async function savePlan() {
|
||||
if (!planForm.majorId || !planForm.name?.trim() || !planForm.version?.trim()) {
|
||||
ElMessage.warning('请填写专业、方案名称和版本号。')
|
||||
return
|
||||
}
|
||||
if (editingPlanId.value && !await confirmPublishedChange('方案信息')) return
|
||||
try {
|
||||
if (editingPlanId.value) {
|
||||
await http.put(`/curriculum-plans/${editingPlanId.value}`, planForm)
|
||||
@@ -183,7 +207,7 @@ async function clonePlan() {
|
||||
async function publishPlan() {
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
'发布后该版本将锁定,并自动归档同专业、同年级的旧发布版本。确定发布吗?',
|
||||
'发布后该版本将成为学生端展示和毕业审核依据,并自动归档同专业、同年级的旧发布版本。已发布方案仍可调整课程内容,但适用专业、年级和版本号不可更改。确定发布吗?',
|
||||
'发布培养方案',
|
||||
{ type: 'warning', confirmButtonText: '确认发布', cancelButtonText: '取消' },
|
||||
)
|
||||
@@ -226,6 +250,7 @@ async function saveModule() {
|
||||
ElMessage.warning('请填写模块编码和名称。')
|
||||
return
|
||||
}
|
||||
if (!await confirmPublishedChange('课程模块')) return
|
||||
try {
|
||||
const base = `/curriculum-plans/${selected.value.id}/modules`
|
||||
if (editingModuleId.value) await http.put(`${base}/${editingModuleId.value}`, moduleForm)
|
||||
@@ -239,7 +264,10 @@ async function saveModule() {
|
||||
|
||||
async function deleteModule(module: any) {
|
||||
try {
|
||||
await ElMessageBox.confirm(`删除“${module.name}”及其中课程?`, '删除课程模块', {
|
||||
const impact = isPublished.value
|
||||
? '删除后会立即影响学生端展示及毕业审核。'
|
||||
: ''
|
||||
await ElMessageBox.confirm(`删除“${module.name}”及其中课程?${impact}`, '删除课程模块', {
|
||||
type: 'warning',
|
||||
})
|
||||
await http.delete(`/curriculum-plans/${selected.value.id}/modules/${module.id}`)
|
||||
@@ -266,6 +294,7 @@ async function saveCourse() {
|
||||
ElMessage.warning('请选择课程。')
|
||||
return
|
||||
}
|
||||
if (!await confirmPublishedChange('方案课程')) return
|
||||
try {
|
||||
const base = `/curriculum-plans/${selected.value.id}/modules/${activeModuleId.value}/courses`
|
||||
if (editingCourseId.value) await http.put(`${base}/${editingCourseId.value}`, courseForm)
|
||||
@@ -279,7 +308,10 @@ async function saveCourse() {
|
||||
|
||||
async function deleteCourse(moduleId: string, item: any) {
|
||||
try {
|
||||
await ElMessageBox.confirm(`从方案中移除“${item.courseName}”?`, '移除课程', {
|
||||
const impact = isPublished.value
|
||||
? '移除后会立即影响学生端展示及毕业审核。'
|
||||
: ''
|
||||
await ElMessageBox.confirm(`从方案中移除“${item.courseName}”?${impact}`, '移除课程', {
|
||||
type: 'warning',
|
||||
})
|
||||
await http.delete(
|
||||
@@ -313,7 +345,7 @@ onMounted(async () => {
|
||||
<div>
|
||||
<span class="section-kicker">PROGRAMME OF STUDY</span>
|
||||
<h2>培养方案</h2>
|
||||
<p>由学院按专业和入学年级维护课程结构,发布后锁定,避免影响历史年级。</p>
|
||||
<p>由学院按专业和入学年级维护课程结构;已发布方案可受控调整,修改结果即时生效。</p>
|
||||
</div>
|
||||
<el-button type="primary" :icon="Plus" @click="openPlan()">新建方案</el-button>
|
||||
</section>
|
||||
@@ -329,8 +361,8 @@ onMounted(async () => {
|
||||
</div>
|
||||
<p>
|
||||
{{ isCollegeAdmin
|
||||
? '可新建、编制并发布本学院各专业培养方案'
|
||||
: '可跨学院查看、维护并统筹培养方案版本' }}
|
||||
? '可新建、编制、发布并维护本学院各专业培养方案'
|
||||
: '可跨学院查看、发布并统筹维护培养方案版本' }}
|
||||
</p>
|
||||
</section>
|
||||
|
||||
@@ -393,13 +425,22 @@ onMounted(async () => {
|
||||
<p>{{ selected.version }} · 适用 {{ selected.effectiveGrade }} 级 · {{ selected.schoolingYears }} 年制</p>
|
||||
</div>
|
||||
<div class="plan-actions">
|
||||
<el-button v-if="isDraft" @click="openPlan(selected)">编辑</el-button>
|
||||
<el-button v-if="canEdit" @click="openPlan(selected)">编辑</el-button>
|
||||
<el-button :icon="CopyDocument" @click="openClone">复制版本</el-button>
|
||||
<el-button v-if="isDraft" type="success" :icon="Promotion" @click="publishPlan">发布</el-button>
|
||||
<el-button v-if="isDraft" type="danger" plain @click="deletePlan">删除</el-button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<el-alert
|
||||
v-if="isPublished"
|
||||
class="published-edit-notice"
|
||||
type="warning"
|
||||
show-icon
|
||||
:closable="false"
|
||||
title="当前方案已发布,修改保存后会立即影响学生端展示及毕业审核依据;适用专业、入学年级和版本号不可更改。"
|
||||
/>
|
||||
|
||||
<div class="plan-metrics">
|
||||
<div><span>方案状态</span><b>{{ statusLabels[selected.status] }}</b></div>
|
||||
<div><span>总学分要求</span><b>{{ selected.totalCredits }}</b></div>
|
||||
@@ -412,7 +453,7 @@ onMounted(async () => {
|
||||
<b>课程结构</b>
|
||||
<span>指定必修须逐门通过;英语、体育等多选课程用“组内选修”,修满模块最低学分即可</span>
|
||||
</div>
|
||||
<el-button v-if="isDraft" :icon="Plus" @click="openModule()">新增模块</el-button>
|
||||
<el-button v-if="canEdit" :icon="Plus" @click="openModule()">新增模块</el-button>
|
||||
</div>
|
||||
|
||||
<section v-for="module in selected.modules" :key="module.id" class="curriculum-module">
|
||||
@@ -427,7 +468,7 @@ onMounted(async () => {
|
||||
· 课程组选项
|
||||
</template>
|
||||
</p>
|
||||
<div v-if="isDraft">
|
||||
<div v-if="canEdit">
|
||||
<el-button link type="primary" @click="openModule(module)">编辑</el-button>
|
||||
<el-button link type="danger" @click="deleteModule(module)">删除</el-button>
|
||||
<el-button size="small" :icon="Plus" @click="openCourse(module.id)">添加课程</el-button>
|
||||
@@ -449,7 +490,7 @@ onMounted(async () => {
|
||||
<el-table-column label="建议学期" width="90">
|
||||
<template #default="{ row }">第 {{ row.recommendedSemester }} 学期</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="isDraft" label="操作" width="120">
|
||||
<el-table-column v-if="canEdit" label="操作" width="120">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" @click="openCourse(module.id, row)">编辑</el-button>
|
||||
<el-button link type="danger" @click="deleteCourse(module.id, row)">移除</el-button>
|
||||
@@ -464,14 +505,21 @@ onMounted(async () => {
|
||||
</div>
|
||||
|
||||
<el-dialog v-model="planDialog" :title="editingPlanId ? '编辑培养方案' : '新建培养方案'" width="620px">
|
||||
<el-alert
|
||||
v-if="isEditingPublished"
|
||||
type="warning"
|
||||
show-icon
|
||||
:closable="false"
|
||||
title="已发布方案的修改会立即生效。适用专业、入学年级和版本号已锁定,如需调整请复制为新版本。"
|
||||
/>
|
||||
<el-form label-position="top">
|
||||
<el-form-item label="适用专业" required>
|
||||
<el-select v-model="planForm.majorId" filterable><el-option v-for="item in availableMajors" :key="item.id" :label="item.name" :value="item.id" /></el-select>
|
||||
<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="方案名称" required><el-input v-model="planForm.name" /></el-form-item>
|
||||
<div class="form-grid">
|
||||
<el-form-item label="版本号" required><el-input v-model="planForm.version" /></el-form-item>
|
||||
<el-form-item label="适用入学年级" required><el-input-number v-model="planForm.effectiveGrade" :min="2000" :max="2200" /></el-form-item>
|
||||
<el-form-item label="版本号" required><el-input v-model="planForm.version" :disabled="isEditingPublished" /></el-form-item>
|
||||
<el-form-item label="适用入学年级" required><el-input-number v-model="planForm.effectiveGrade" :min="2000" :max="2200" :disabled="isEditingPublished" /></el-form-item>
|
||||
</div>
|
||||
<el-form-item label="毕业总学分要求" required><el-input-number v-model="planForm.totalCredits" :min="0.1" :precision="1" :step="0.5" /></el-form-item>
|
||||
<el-form-item label="方案说明"><el-input v-model="planForm.description" type="textarea" :rows="3" /></el-form-item>
|
||||
|
||||
Reference in New Issue
Block a user