开放实验项目发布后修正功能
This commit is contained in:
@@ -37,6 +37,7 @@ const taskKeyword = ref('')
|
||||
|
||||
const projectDialog = ref(false)
|
||||
const editingProjectId = ref('')
|
||||
const correctingPublishedProject = ref(false)
|
||||
const projectForm = reactive({
|
||||
teachingTaskIds: [] as string[],
|
||||
scheduleEntryId: '',
|
||||
@@ -158,6 +159,7 @@ const statusLabels: Record<string, string> = {
|
||||
|
||||
function resetProjectForm() {
|
||||
editingProjectId.value = ''
|
||||
correctingPublishedProject.value = false
|
||||
Object.assign(projectForm, {
|
||||
teachingTaskIds: [],
|
||||
scheduleEntryId: '',
|
||||
@@ -197,6 +199,7 @@ function openCreateProject() {
|
||||
|
||||
function openEditProject(project: any) {
|
||||
editingProjectId.value = project.id
|
||||
correctingPublishedProject.value = false
|
||||
Object.assign(projectForm, {
|
||||
teachingTaskIds: [project.teachingTaskId],
|
||||
scheduleEntryId: project.scheduleEntryId ?? '',
|
||||
@@ -212,18 +215,23 @@ function openEditProject(project: any) {
|
||||
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 = editingProjectId.value
|
||||
const hasValidName = correctingPublishedProject.value || editingProjectId.value
|
||||
? !!projectForm.name.trim()
|
||||
: projectForm.nameMode === 'InputNames'
|
||||
? names.length > 0
|
||||
: !!projectForm.name.trim()
|
||||
if (!projectForm.teachingTaskIds.length ||
|
||||
if ((!correctingPublishedProject.value && !projectForm.teachingTaskIds.length) ||
|
||||
(editingProjectId.value && projectForm.arrangementMode === 'Centralized' && !projectForm.scheduleEntryId) ||
|
||||
!projectForm.code.trim()
|
||||
|| !hasValidName || projectForm.dates.length !== 2) {
|
||||
@@ -244,7 +252,14 @@ async function saveProject() {
|
||||
endDate: projectForm.dates[1],
|
||||
}
|
||||
try {
|
||||
if (editingProjectId.value) {
|
||||
if (correctingPublishedProject.value) {
|
||||
await http.put(`/experiments/${editingProjectId.value}/published-details`, {
|
||||
name: projectForm.name,
|
||||
description: projectForm.description || null,
|
||||
requirements: projectForm.requirements || null,
|
||||
})
|
||||
ElMessage.success('已修正已发布项目的教学内容,并通知学生查看')
|
||||
} else if (editingProjectId.value) {
|
||||
await http.put(`/experiments/${editingProjectId.value}`, payload)
|
||||
ElMessage.success('实验项目已更新')
|
||||
} else {
|
||||
@@ -842,7 +857,10 @@ onMounted(async () => {
|
||||
@click="publishProject(row)"
|
||||
>发布</el-button>
|
||||
</template>
|
||||
<el-button v-else-if="row.status === 'Published'" size="small" text @click="closeProject(row)">关闭项目</el-button>
|
||||
<template v-else-if="row.status === 'Published'">
|
||||
<el-button size="small" text @click="openCorrectPublishedProject(row)">修正内容</el-button>
|
||||
<el-button size="small" text @click="closeProject(row)">关闭项目</el-button>
|
||||
</template>
|
||||
<el-button
|
||||
v-if="row.status !== 'Closed' && row.arrangementMode === 'SelfScheduled'"
|
||||
size="small"
|
||||
@@ -952,11 +970,17 @@ onMounted(async () => {
|
||||
|
||||
<el-dialog
|
||||
v-model="projectDialog"
|
||||
:title="editingProjectId ? '编辑实验项目' : '批量设置实验任务'"
|
||||
:title="correctingPublishedProject ? '修正已发布实验项目内容' : editingProjectId ? '编辑实验项目' : '批量设置实验任务'"
|
||||
width="720px"
|
||||
top="5vh"
|
||||
>
|
||||
<el-form label-position="top" class="experiment-form">
|
||||
<el-alert
|
||||
v-if="correctingPublishedProject"
|
||||
title="已发布项目仅可修正名称、实验内容和到场要求;编码、安排方式、课表绑定及开放日期保持不变。保存后将通知相关学生。"
|
||||
type="info"
|
||||
:closable="false"
|
||||
/>
|
||||
<div class="form-section">
|
||||
<header><span>PROJECT</span><b>规定实验项目</b></header>
|
||||
<el-form-item v-if="editingProjectId && projectForm.arrangementMode === 'Centralized'" label="已发布课表中的实验课" required>
|
||||
@@ -1027,7 +1051,7 @@ onMounted(async () => {
|
||||
</el-form-item>
|
||||
<div class="form-grid two">
|
||||
<el-form-item label="项目编码" required>
|
||||
<el-input v-model="projectForm.code" maxlength="40" placeholder="如 LAB-01" />
|
||||
<el-input v-model="projectForm.code" :disabled="correctingPublishedProject" maxlength="40" placeholder="如 LAB-01" />
|
||||
</el-form-item>
|
||||
<el-form-item v-if="editingProjectId" label="项目名称" required>
|
||||
<el-input v-model="projectForm.name" maxlength="120" placeholder="如 数据库事务与并发实验" />
|
||||
@@ -1058,7 +1082,7 @@ onMounted(async () => {
|
||||
|
||||
<div class="form-section">
|
||||
<header><span>ROUTE</span><b>选择运行轨道</b></header>
|
||||
<el-radio-group v-model="projectForm.arrangementMode" class="mode-choice" :disabled="!!editingProjectId">
|
||||
<el-radio-group v-model="projectForm.arrangementMode" class="mode-choice" :disabled="!!editingProjectId || correctingPublishedProject">
|
||||
<el-radio-button value="Centralized">
|
||||
<b>集中安排</b><small>复用已发布课表的实验课</small>
|
||||
</el-radio-button>
|
||||
@@ -1069,6 +1093,7 @@ onMounted(async () => {
|
||||
<el-form-item label="项目开放日期" required>
|
||||
<el-date-picker
|
||||
v-model="projectForm.dates"
|
||||
:disabled="correctingPublishedProject"
|
||||
type="daterange"
|
||||
value-format="YYYY-MM-DD"
|
||||
range-separator="至"
|
||||
@@ -1105,7 +1130,9 @@ onMounted(async () => {
|
||||
<template #footer>
|
||||
<el-button @click="projectDialog = false">取消</el-button>
|
||||
<el-button type="primary" @click="saveProject">
|
||||
{{ editingProjectId
|
||||
{{ correctingPublishedProject
|
||||
? '保存修正'
|
||||
: editingProjectId
|
||||
? '保存项目'
|
||||
: projectForm.teachingTaskIds.length
|
||||
? `创建 ${projectForm.teachingTaskIds.length} 个项目`
|
||||
|
||||
Reference in New Issue
Block a user