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

bug fixes

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