From 8a2a8add39ef8fbd32332ab253103c667d30e569 Mon Sep 17 00:00:00 2001 From: yuk255 Date: Wed, 17 Sep 2025 10:38:18 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E8=AF=BE=E7=A8=8B=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E7=BC=96=E8=BE=91=E6=B7=BB=E5=8A=A0=E5=AD=A6=E6=9C=9F?= =?UTF-8?q?=E5=92=8C=E5=85=81=E8=AE=B8=E8=B5=84=E6=BA=90=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/CourseComponents/CourseCreate.vue | 138 +++++++++++++++++- 1 file changed, 132 insertions(+), 6 deletions(-) diff --git a/src/components/admin/CourseComponents/CourseCreate.vue b/src/components/admin/CourseComponents/CourseCreate.vue index bd1f1c1..896fb7a 100644 --- a/src/components/admin/CourseComponents/CourseCreate.vue +++ b/src/components/admin/CourseComponents/CourseCreate.vue @@ -24,12 +24,6 @@ - -
- - -
-
@@ -37,6 +31,12 @@ class="form-input" />
+ +
+ + +
+
@@ -71,6 +71,17 @@ class="form-input" />
+ +
+ +
+ + +
+
+
+ +
+ +
+ +
+
+
@@ -261,7 +280,12 @@ const formData = reactive({ selectedClasses: [] as string[], courseCover: null as File | null, courseDescription: '', + // 学期设置 + semesterYear: new Date().getFullYear(), // 当前年份 + semesterTerm: 'spring' as 'spring' | 'autumn', // 春季或秋季 + semester: '', // 最终的学期字符串,如"2025春" // 视频设置 + allowDownload: true, stopOnLeave: false, videoSpeedControl: false, showVideoText: false, @@ -363,7 +387,14 @@ const loadCourseData = async () => { } } + // 学期数据回显 + if (storeCourseData.semester) { + parseSemesterData(storeCourseData.semester); + } + // 视频设置选项:从后端字段映射到前端字段(数字0/1转布尔值) + formData.allowDownload = storeCourseData.allowDownload !== undefined ? + Boolean(Number(storeCourseData.allowDownload)) : true; formData.stopOnLeave = storeCourseData.pauseExit !== undefined ? Boolean(Number(storeCourseData.pauseExit)) : true; formData.videoSpeedControl = storeCourseData.allowSpeed !== undefined ? @@ -440,7 +471,14 @@ const loadCourseData = async () => { } } + // 学期数据回显 + if (courseData.semester) { + parseSemesterData(courseData.semester); + } + // 视频设置选项:从后端字段映射到前端字段(数字0/1转布尔值) + formData.allowDownload = courseData.allowDownload !== undefined ? + Boolean(Number(courseData.allowDownload)) : true; formData.stopOnLeave = courseData.pauseExit !== undefined ? Boolean(Number(courseData.pauseExit)) : true; formData.videoSpeedControl = courseData.allowSpeed !== undefined ? @@ -481,6 +519,59 @@ const instructorOptions = ref([] as { label: string; value: string }[]) // 班级选项 const classOptions = ref([] as { label: string; value: string }[]) +// 学期年份选项(从当前年份开始,向后5年) +const yearOptions = ref<{ label: string; value: number }[]>([]) + +// 初始化年份选项 +const initYearOptions = () => { + const currentYear = new Date().getFullYear() + const years = [] + for (let i = 0; i < 6; i++) { + const year = currentYear + i + years.push({ + label: `${year}年`, + value: year + }) + } + yearOptions.value = years +} + +// 学期选项 +const termOptions = ref([ + { label: '春季学期', value: 'spring' }, + { label: '秋季学期', value: 'autumn' } +]) + +// 更新学期字符串 +const updateSemester = () => { + const termMap = { + spring: '春', + autumn: '秋' + } + formData.semester = `${formData.semesterYear}${termMap[formData.semesterTerm]}` +} + +// 解析学期数据(如"2025春") +const parseSemesterData = (semesterStr: string) => { + if (!semesterStr) return + + // 提取年份(数字部分) + const yearMatch = semesterStr.match(/(\d{4})/) + if (yearMatch) { + formData.semesterYear = parseInt(yearMatch[1]) + } + + // 提取学期(春/秋) + if (semesterStr.includes('春')) { + formData.semesterTerm = 'spring' + } else if (semesterStr.includes('秋')) { + formData.semesterTerm = 'autumn' + } + + // 更新学期字符串 + formData.semester = semesterStr +} + // 文件上传相关方法 const triggerFileUpload = () => { fileInput.value?.click() @@ -694,9 +785,11 @@ const handleSubmit = async () => { classId: formData.studentType === 'all' ? '' : formData.selectedClasses.join(','), // classId startTime: formData.startTime ? formatDateTime(formData.startTime) : null, endTime: formData.endTime ? formatDateTime(formData.endTime) : null, + semester: formData.semester, // 学期 pauseExit: formData.stopOnLeave ? '1' : '0', // 离开页面停止播放 allowSpeed: formData.videoSpeedControl ? '1' : '0', // 视频倍数播放 showSubtitle: formData.showVideoText ? '1' : '0', // 显示视频文本 + allowDownload: formData.allowDownload ? '1' : '0', // 允许下载课件 // 其他可选字段 school: null, video: null, @@ -828,6 +921,10 @@ const getClassList = async () => { } onMounted(async () => { + // 初始化年份选项和默认学期字符串 + initYearOptions(); + updateSemester(); + // 先加载基础数据(课程分类、老师、班级) await Promise.all([ getCourseList(), @@ -1093,6 +1190,35 @@ onMounted(async () => { cursor: pointer; } +/* 学期选择器样式 */ +.semester-container { + display: flex; + gap: 12px; + flex: 1; +} + +.semester-year-input { + flex: 1; + height: 42px; +} + +.semester-term-input { + flex: 1; + height: 42px; +} + +.semester-year-input :deep(.n-base-selection), +.semester-term-input :deep(.n-base-selection) { + --n-height: 42px !important; + height: 42px !important; +} + +.semester-year-input :deep(.n-base-selection-label), +.semester-term-input :deep(.n-base-selection-label) { + height: 42px !important; + line-height: 42px !important; +} + /* 课程封面上传区域 */ .cover-upload-container { flex: 1;