|
@@ -0,0 +1,110 @@
|
|
|
+<template>
|
|
|
+ <Dialog title="校内导师分配" v-model="dialogVisible">
|
|
|
+ <el-form
|
|
|
+ ref="formRef"
|
|
|
+ :model="formData"
|
|
|
+ label-width="130px"
|
|
|
+ v-loading="formLoading"
|
|
|
+ :rules="formRules"
|
|
|
+ >
|
|
|
+ <el-table :data="formData.studentList" :stripe="true" :show-overflow-tooltip="true" >
|
|
|
+ <el-table-column label="学生姓名" align="center" prop="nickname" />
|
|
|
+ <el-table-column label="学生学号" align="center" prop="username" />
|
|
|
+ <el-table-column label="学生专业" align="center" prop="major" />
|
|
|
+ <el-table-column label="校外导师" align="center" prop="externalSupervisor" />
|
|
|
+ <el-table-column label="校内导师" align="center">
|
|
|
+ <template #default="scope">
|
|
|
+ <el-select
|
|
|
+ v-model="scope.row.supervisorId"
|
|
|
+ placeholder="请选择参与导师"
|
|
|
+ clearable
|
|
|
+ filterable
|
|
|
+ class="!w-full"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="supervisor in supervisors"
|
|
|
+ :key="supervisor.id"
|
|
|
+ :label="supervisor.nickname"
|
|
|
+ :value="supervisor.id"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </el-form>
|
|
|
+ <template #footer>
|
|
|
+ <el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
|
|
|
+ <el-button @click="dialogVisible = false">取 消</el-button>
|
|
|
+ </template>
|
|
|
+ </Dialog>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup lang="ts">
|
|
|
+import { studentSelectionProjectApi, studentSelectionProjectVO } from '@/api/system/studentSelectionProject'
|
|
|
+import * as UserApi from '@/api/system/user'
|
|
|
+import { ref, onMounted } from 'vue'
|
|
|
+
|
|
|
+defineOptions({ name: 'StudentSelectionProjectForm' })
|
|
|
+
|
|
|
+const { t } = useI18n() // 国际化
|
|
|
+const message = useMessage() // 消息弹窗
|
|
|
+const dialogVisible = ref(false) // 弹窗的是否展示
|
|
|
+const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
|
|
+const formData = ref({
|
|
|
+ studentList: []
|
|
|
+})
|
|
|
+
|
|
|
+const formRef = ref() // 表单 Ref
|
|
|
+
|
|
|
+const formRules = {
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+/** 打开弹窗 */
|
|
|
+const open = async (id?: number) => {
|
|
|
+ dialogVisible.value = true
|
|
|
+ if (id) {
|
|
|
+ formLoading.value = true
|
|
|
+ try {
|
|
|
+ const data = await studentSelectionProjectApi.getStudentSelectExternalSupervisorsList(id)
|
|
|
+ formData.value.studentList = data;
|
|
|
+ } finally {
|
|
|
+ formLoading.value = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
|
|
+
|
|
|
+/** 提交表单 */
|
|
|
+const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
|
|
+const submitForm = async () => {
|
|
|
+ // 校验表单
|
|
|
+ await formRef.value.validate()
|
|
|
+ // 提交请求
|
|
|
+ formLoading.value = true
|
|
|
+ try {
|
|
|
+ const data = formData.value.studentList
|
|
|
+ await studentSelectionProjectApi.updateInnerSupervisor(data)
|
|
|
+ dialogVisible.value = false
|
|
|
+ emit('success')
|
|
|
+ } finally {
|
|
|
+ formLoading.value = false
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 获取所有导师
|
|
|
+const supervisors = ref<{ id: number; nickname: string }[]>([])
|
|
|
+const getSupervisor = async () => {
|
|
|
+ try {
|
|
|
+ const result = await UserApi.getSupervisor()
|
|
|
+ supervisors.value = result
|
|
|
+ } catch (error) {
|
|
|
+ console.error('未获取到导师', error)
|
|
|
+ message.error('获取导师列表失败,请稍后再试')
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+onMounted(() => {
|
|
|
+ getSupervisor()
|
|
|
+})
|
|
|
+</script>
|