新增
-
+
导入
导出
@@ -63,10 +63,13 @@
- 编辑
- 删除
- 密码初始化
- 数据初始化
+
+ 编辑
+ 删除
+ 密码初始化
+ 数据初始化
+
+ 仅查看
@@ -120,6 +123,7 @@ import { ElMessageBox } from "element-plus";
const { proxy } = getCurrentInstance();
import useUserStore from "@/store/modules/user";
const userStore = useUserStore();
+const currentUserId = computed(() => userStore.userInfo.userId);
import * as indexApi from "@/api/teacher";
const dialogVisible = ref(false);
const loading = ref(false);
@@ -161,7 +165,7 @@ const getList = () => {
};
// 删除院校
const delSchool = (id) => {
- indexApi.deleteStudent({ userId: id.userId }).then((res) => {
+ indexApi.deleteStudent({ userId: id.userId, operatorId: currentUserId.value }).then((res) => {
proxy.$message.success("删除成功");
getList();
});
@@ -186,6 +190,7 @@ const editSchool = (row) => {
const add = () => {
formInline.value.schoolMajorName = majorList.value?.filter((item) => item.schoolMajorId == formInline.value.schoolMajorId)[0].schoolMajorName;
formInline.value.schoolClassName = classList1.value?.filter((item) => item.schoolClassId == formInline.value.schoolClassId)[0].className;
+ formInline.value.userId = currentUserId.value;
indexApi.addStudent(formInline.value).then((res) => {
proxy.$message.success("添加成功");
dialogVisible.value = false;
@@ -194,6 +199,7 @@ const add = () => {
};
const edit = () => {
formInline.value.status = true;
+ formInline.value.operatorId = currentUserId.value;
indexApi.updateStudent(formInline.value).then((res) => {
proxy.$message.success("编辑成功");
dialogVisible.value = false;
@@ -267,6 +273,12 @@ const downloadTemplate = () => {
};
// 查询班级下拉
const classList = ref([]);
+const classOwnerMap = computed(() => {
+ return new Map(classList.value.map((item) => [item.schoolClassId, item.createdBy]));
+});
+const canOperateStudent = (row) => {
+ return classOwnerMap.value.get(row.schoolClassId) === currentUserId.value;
+};
const getClassList = () => {
indexApi.getClassListBySchoolId({ schoolId: userStore.userInfo.schoolId }).then((res) => {
classList.value = res.data;
@@ -278,7 +290,7 @@ const getClassByMajor = () => {
if (!formInline.value.schoolMajorId) return;
formInline.value.schoolClassId = "";
indexApi.getClassListByMajorId({ schoolMajorId: formInline.value.schoolMajorId }).then((res) => {
- classList1.value = res.data;
+ classList1.value = (res.data || []).filter((item) => item.createdBy === currentUserId.value);
});
};
//初始化密码
@@ -290,7 +302,7 @@ const initPassword = (row, status) => {
type: "warning",
})
.then(() => {
- indexApi.initStudentPassword({ userId: row.userId }).then((res) => {
+ indexApi.initStudentPassword({ userId: row.userId, operatorId: currentUserId.value }).then((res) => {
proxy.$message.success("密码初始化成功");
getList();
});
diff --git a/src/views/teacherEnd/task/index.vue b/src/views/teacherEnd/task/index.vue
index 1d4bb17..583c46b 100644
--- a/src/views/teacherEnd/task/index.vue
+++ b/src/views/teacherEnd/task/index.vue
@@ -22,7 +22,7 @@
@select="handleSelect"
@select-all="handleSelectAll"
>
-
+
@@ -39,11 +39,14 @@ const tableData = ref([]);
const loading = ref(false);
const tableRef = ref(null);
const classId = ref("");
+const currentUserId = computed(() => userStore.userInfo.userId);
+const selectedClass = computed(() => classList.value.find((item) => item.schoolClassId === classId.value));
+const canOperateSelectedClass = computed(() => selectedClass.value?.createdBy === currentUserId.value);
// 获取班级列表
const getClassList = () => {
indexApi.getClassListBySchoolId({ schoolId: userStore.userInfo.schoolId }).then((res) => {
- classList.value = res.data;
- classId.value = classList.value[0].schoolClassId;
+ classList.value = res.data || [];
+ classId.value = classList.value[0]?.schoolClassId || "";
getTaskList();
});
};
@@ -75,12 +78,14 @@ const setInitialSelection = () => {
// 修改单选处理方法
const handleSelect = async (selection, row) => {
if (isInitializing.value) return; // 初始化时不处理
+ if (!canOperateSelectedClass.value) return;
row.disabledStatus = row.disabledStatus == 0 ? 1 : 0;
handleTaskDistribution(tableData.value);
};
// 修改全选处理方法
const handleSelectAll = async (selection) => {
if (isInitializing.value) return; // 初始化时不处理
+ if (!canOperateSelectedClass.value) return;
const newStatus = selection.length > 0 ? 0 : 1; // 全选为0,取消为1
try {
loading.value = true;
@@ -126,11 +131,12 @@ function findMissingItems(arr1, arr2) {
// 修改任务分配
const handleTaskDistribution = (selection) => {
const uniqueUsers = [...new Map(selection.map((item) => [item.module, item])).values()];
- indexApi.addTask({ taskAllocationList: uniqueUsers, classId: classId.value, schoolId: userStore.userInfo.schoolId }).then((res) => {
+ indexApi.addTask({ taskAllocationList: uniqueUsers, classId: classId.value, schoolId: userStore.userInfo.schoolId, userId: currentUserId.value }).then((res) => {
getTaskList();
proxy.$modal.msgSuccess("分配成功");
});
};
+const canSelectTask = () => canOperateSelectedClass.value;
// 恢复选中状态
onMounted(() => {
getClassList();
@@ -142,4 +148,4 @@ onMounted(() => {
height: calc(100vh - 70px);
background: #ffffff;
}
-
\ No newline at end of file
+