|
|
|
@ -124,6 +124,8 @@ const { proxy } = getCurrentInstance();
|
|
|
|
import useUserStore from "@/store/modules/user";
|
|
|
|
import useUserStore from "@/store/modules/user";
|
|
|
|
const userStore = useUserStore();
|
|
|
|
const userStore = useUserStore();
|
|
|
|
const currentUserId = computed(() => userStore.userInfo.userId);
|
|
|
|
const currentUserId = computed(() => userStore.userInfo.userId);
|
|
|
|
|
|
|
|
const currentSchoolId = computed(() => userStore.userInfo.schoolId);
|
|
|
|
|
|
|
|
const isManagerTeacher = computed(() => userStore.userInfo.teacherAdmin === true || String(userStore.userInfo.roleId || userStore.userInfo.role) === "1");
|
|
|
|
import * as indexApi from "@/api/teacher";
|
|
|
|
import * as indexApi from "@/api/teacher";
|
|
|
|
const dialogVisible = ref(false);
|
|
|
|
const dialogVisible = ref(false);
|
|
|
|
const loading = ref(false);
|
|
|
|
const loading = ref(false);
|
|
|
|
@ -277,13 +279,21 @@ const normalizeClassType = (schoolClass) => {
|
|
|
|
if (schoolClass?.classType) return schoolClass.classType;
|
|
|
|
if (schoolClass?.classType) return schoolClass.classType;
|
|
|
|
return schoolClass?.createdBy ? "TEACHING" : "ADMIN";
|
|
|
|
return schoolClass?.createdBy ? "TEACHING" : "ADMIN";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const sameValue = (left, right) => String(left || "") === String(right || "");
|
|
|
|
|
|
|
|
const canUseAdminClassForStudent = (schoolClass) => {
|
|
|
|
|
|
|
|
if (normalizeClassType(schoolClass) !== "ADMIN") return false;
|
|
|
|
|
|
|
|
if (isManagerTeacher.value) {
|
|
|
|
|
|
|
|
return !schoolClass?.schoolId || sameValue(schoolClass.schoolId, currentSchoolId.value);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return sameValue(schoolClass?.createdBy, currentUserId.value);
|
|
|
|
|
|
|
|
};
|
|
|
|
const teachingClassList = computed(() => classList.value.filter((item) => normalizeClassType(item) === "TEACHING"));
|
|
|
|
const teachingClassList = computed(() => classList.value.filter((item) => normalizeClassType(item) === "TEACHING"));
|
|
|
|
const classOwnerMap = computed(() => {
|
|
|
|
const classOwnerMap = computed(() => {
|
|
|
|
return new Map(classList.value.map((item) => [item.schoolClassId, item.createdBy]));
|
|
|
|
return new Map(classList.value.map((item) => [item.schoolClassId, item.createdBy]));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
const canOperateStudent = (row) => {
|
|
|
|
const canOperateStudent = (row) => {
|
|
|
|
const teachingClassId = paramsquery.value.schoolClassId || row.schoolClassId;
|
|
|
|
const teachingClassId = paramsquery.value.schoolClassId || row.schoolClassId;
|
|
|
|
return classOwnerMap.value.get(teachingClassId) === currentUserId.value;
|
|
|
|
return sameValue(classOwnerMap.value.get(teachingClassId), currentUserId.value);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
const getClassList = () => {
|
|
|
|
const getClassList = () => {
|
|
|
|
indexApi.getClassListBySchoolId({ schoolId: userStore.userInfo.schoolId }).then((res) => {
|
|
|
|
indexApi.getClassListBySchoolId({ schoolId: userStore.userInfo.schoolId }).then((res) => {
|
|
|
|
@ -296,7 +306,7 @@ const getClassByMajor = () => {
|
|
|
|
if (!formInline.value.schoolMajorId) return;
|
|
|
|
if (!formInline.value.schoolMajorId) return;
|
|
|
|
formInline.value.schoolClassId = "";
|
|
|
|
formInline.value.schoolClassId = "";
|
|
|
|
indexApi.getClassListByMajorId({ schoolMajorId: formInline.value.schoolMajorId }).then((res) => {
|
|
|
|
indexApi.getClassListByMajorId({ schoolMajorId: formInline.value.schoolMajorId }).then((res) => {
|
|
|
|
classList1.value = (res.data || []).filter((item) => normalizeClassType(item) === "TEACHING" && item.createdBy === currentUserId.value);
|
|
|
|
classList1.value = (res.data || []).filter((item) => canUseAdminClassForStudent(item));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
//初始化密码
|
|
|
|
//初始化密码
|
|
|
|
|