提交 1d3fcaaa authored 作者: 王鹏飞's avatar 王鹏飞

bug fixes

上级 84bb9138
......@@ -22,10 +22,6 @@ const emit = defineEmits<{
// 机构列表
const { organizations } = useGetProjectList()
// 课程列表
const { courses } = useGetCourseList()
// 指导教师列表
const { teachers } = useGetTeacherList()
// 实验类型
const types = useMapStore().getMapValuesByKey('experiment_type')
// 数据状态
......@@ -51,6 +47,17 @@ watchEffect(() => {
Object.assign(form, props.data, { score, length, teachers_ids })
})
// 课程列表
const { courses, updateCourses } = useGetCourseList()
watchEffect(() => {
updateCourses(form.organ_id)
})
// 指导教师列表
const { teachers, updateTeachers } = useGetTeacherList()
watchEffect(() => {
updateTeachers(form.organ_id)
})
const rules = ref<FormRules>({
organ_id: [{ required: true, message: '请选择实验所属部门/学校' }],
course_id: [{ required: true, message: '请选择实验课程' }],
......@@ -66,6 +73,10 @@ const isUpdate = $computed(() => {
const title = $computed(() => {
return isUpdate ? '编辑实验' : '新增实验'
})
function handleOrgChange() {
form.course_id = ''
form.teachers_ids = []
}
// 提交
function handleSubmit() {
......@@ -99,7 +110,7 @@ function handleUpdate(params: ExperimentCreateItem) {
<el-dialog :title="title" :close-on-click-modal="false" width="600px" @update:modelValue="$emit('update:modelValue')">
<el-form ref="formRef" :model="form" :rules="rules" label-width="150px">
<el-form-item label="实验所属部门/学校" prop="organ_id">
<el-select v-model="form.organ_id" style="width: 100%" :disabled="isUpdate">
<el-select v-model="form.organ_id" style="width: 100%" :disabled="isUpdate" @change="handleOrgChange">
<el-option v-for="item in organizations" :key="item.id" :label="item.name" :value="item.id"></el-option>
</el-select>
</el-form-item>
......
import { getExperimentCourseList } from '../api'
import { useUserStore } from '@/stores/user'
interface CourseType {
id: string
name: string
}
const store = useUserStore()
const courses = ref<CourseType[]>([])
export function useGetCourseList() {
if (!courses.value.length && store.organization?.id) {
getExperimentCourseList({ organ_id: store.organization.id }).then((res: any) => {
const courses = ref<CourseType[]>([])
function updateCourses(organId: string) {
getExperimentCourseList({ organ_id: organId }).then((res: any) => {
courses.value = res.data
})
}
return { courses }
return { courses, updateCourses }
}
import { getExperimentTeacherList } from '../api'
import { useUserStore } from '@/stores/user'
interface TeacherType {
id: string
name: string
}
const store = useUserStore()
const teachers = ref<TeacherType[]>([])
export function useGetTeacherList() {
if (!teachers.value.length && store.organization?.id) {
getExperimentTeacherList({ organ_id: store.organization.id }).then((res: any) => {
const teachers = ref<TeacherType[]>([])
function updateTeachers(organId: string) {
getExperimentTeacherList({ organ_id: organId }).then((res: any) => {
teachers.value = res.data
})
}
return { teachers }
return { teachers, updateTeachers }
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论