feat:添加学校列表接口
This commit is contained in:
parent
d9d80c8337
commit
3461499661
@ -218,6 +218,19 @@ export class TeachCourseApi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询课学校列表
|
||||||
|
*/
|
||||||
|
static async getSchoolList(): Promise<ApiResponseWithResult<any>> {
|
||||||
|
try {
|
||||||
|
const response = await ApiRequest.get<{ result: any[] }>(`/aiol/aiolUser/schools`)
|
||||||
|
return response
|
||||||
|
} catch (error) {
|
||||||
|
console.error('❌ 查询学校失败:', error)
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 课程添加老师
|
* 课程添加老师
|
||||||
|
@ -314,7 +314,7 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted, h, computed, watch } from 'vue'
|
import { ref, onMounted, h, computed, watch } from 'vue'
|
||||||
import { ClassApi } from '@/api/modules/teachCourse'
|
import TeachCourseApi, { ClassApi } from '@/api/modules/teachCourse'
|
||||||
import { useRouter, useRoute } from 'vue-router'
|
import { useRouter, useRoute } from 'vue-router'
|
||||||
import { AddCircleOutline, SettingsOutline, QrCode } from '@vicons/ionicons5'
|
import { AddCircleOutline, SettingsOutline, QrCode } from '@vicons/ionicons5'
|
||||||
import {
|
import {
|
||||||
@ -468,13 +468,7 @@ const classRules: FormRules = {
|
|||||||
const masterClassList = ref<ClassItem[]>([])
|
const masterClassList = ref<ClassItem[]>([])
|
||||||
|
|
||||||
// 学院选项
|
// 学院选项
|
||||||
const collegeOptions = ref([
|
const collegeOptions = ref([])
|
||||||
{ label: '计算机学院', value: '计算机学院' },
|
|
||||||
{ label: '软件学院', value: '软件学院' },
|
|
||||||
{ label: '数学学院', value: '数学学院' },
|
|
||||||
{ label: '物理学院', value: '物理学院' },
|
|
||||||
{ label: '化学学院', value: '化学学院' }
|
|
||||||
])
|
|
||||||
|
|
||||||
// 导入单选框选项
|
// 导入单选框选项
|
||||||
const importRadioOptions = ref([
|
const importRadioOptions = ref([
|
||||||
@ -967,11 +961,43 @@ const handleSubmit = async () => {
|
|||||||
await formRef.value?.validate()
|
await formRef.value?.validate()
|
||||||
|
|
||||||
if (isEditMode.value) {
|
if (isEditMode.value) {
|
||||||
// 编辑模式
|
// 编辑模式暂不实现
|
||||||
message.success(`已更新学员 ${formData.value.studentName} 的信息`)
|
message.info('编辑功能暂未实现,敬请期待')
|
||||||
|
return
|
||||||
} else {
|
} else {
|
||||||
// 添加模式
|
// 添加模式
|
||||||
message.success(`已添加学员 ${formData.value.studentName}`)
|
console.log('🚀 开始新增学员...')
|
||||||
|
console.log('表单数据:', formData.value)
|
||||||
|
console.log('当前班级ID:', props.classId)
|
||||||
|
|
||||||
|
// 验证必要参数
|
||||||
|
if (!formData.value.className || formData.value.className.length === 0) {
|
||||||
|
message.error('请选择班级')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 构建API请求参数,根据接口文档字段映射
|
||||||
|
const payload = {
|
||||||
|
realName: formData.value.studentName,
|
||||||
|
studentNumber: formData.value.studentId,
|
||||||
|
password: formData.value.loginPassword,
|
||||||
|
school: formData.value.college,
|
||||||
|
classId: formData.value.className.join(',')
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('📝 API请求参数:', payload)
|
||||||
|
|
||||||
|
// 调用创建学员API
|
||||||
|
const response = await ClassApi.createdStudents(payload)
|
||||||
|
|
||||||
|
console.log('✅ 创建学员响应:', response)
|
||||||
|
|
||||||
|
if (response.data && (response.data.success || response.data.code === 200)) {
|
||||||
|
message.success(`已成功添加学员 ${formData.value.studentName}`)
|
||||||
|
} else {
|
||||||
|
message.error(response.data?.message || '添加学员失败')
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 关闭弹窗并重置表单
|
// 关闭弹窗并重置表单
|
||||||
@ -980,8 +1006,9 @@ const handleSubmit = async () => {
|
|||||||
|
|
||||||
// 重新加载数据
|
// 重新加载数据
|
||||||
loadData(props.classId)
|
loadData(props.classId)
|
||||||
} catch (error) {
|
} catch (error: any) {
|
||||||
message.error('请检查表单信息')
|
console.error('❌ 添加学员失败:', error)
|
||||||
|
message.error(error.message || '添加学员失败,请重试')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1254,9 +1281,22 @@ watch(
|
|||||||
{ immediate: false }
|
{ immediate: false }
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const loadSchoolList = () => {
|
||||||
|
TeachCourseApi.getSchoolList().then(res => {
|
||||||
|
console.log('获取学校列表:', res)
|
||||||
|
collegeOptions.value = res.data.result.map((school: any) => ({
|
||||||
|
label: school,
|
||||||
|
value: school
|
||||||
|
}))
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('获取学校列表失败:', err)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
// 首先加载班级列表数据
|
// 首先加载班级列表数据
|
||||||
await loadClassList()
|
await loadClassList()
|
||||||
|
loadSchoolList()
|
||||||
|
|
||||||
// 初始加载时,优先使用使用传入的classId,其次使用选择器的值
|
// 初始加载时,优先使用使用传入的classId,其次使用选择器的值
|
||||||
const initialClassId = props.classId ? props.classId : Number(selectedDepartment.value)
|
const initialClassId = props.classId ? props.classId : Number(selectedDepartment.value)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user