diff --git a/src/components/teacher/ClassManagement.vue b/src/components/teacher/ClassManagement.vue
index 56ea6a8..01c8b4f 100644
--- a/src/components/teacher/ClassManagement.vue
+++ b/src/components/teacher/ClassManagement.vue
@@ -42,10 +42,12 @@
-
@@ -335,8 +340,8 @@ interface FormData {
className: string[] // 修改为数组类型支持多选
}
-const totalStudents = ref(1333)
-const inviteCode = ref('56685222')
+const totalStudents = ref(0)
+const inviteCode = ref('')
const currentInviteClassId = ref(null) // 当前邀请码对应的班级ID
const message = useMessage()
@@ -439,6 +444,29 @@ const selectedStudents = computed(() => {
return data.value.filter(student => selectedRowKeys.value.includes(student.id))
})
+// 计算属性:过滤后的学员数据(用于搜索)
+const filteredData = computed(() => {
+ if (!searchKeyword.value.trim()) {
+ return data.value
+ }
+
+ const keyword = searchKeyword.value.trim().toLowerCase()
+ return data.value.filter(student =>
+ student.studentName.toLowerCase().includes(keyword) ||
+ student.accountNumber.toLowerCase().includes(keyword) ||
+ student.loginName.toLowerCase().includes(keyword) ||
+ student.college.toLowerCase().includes(keyword) ||
+ student.className.toLowerCase().includes(keyword)
+ )
+})
+
+// 计算属性:分页后的数据
+const paginatedData = computed(() => {
+ const start = (pagination.value.page - 1) * pagination.value.pageSize
+ const end = start + pagination.value.pageSize
+ return filteredData.value.slice(start, end)
+})
+
// 计算属性:统一数据源生成的各种选项
// 部门选项(用于页面顶部筛选)
@@ -618,14 +646,15 @@ const pagination = ref({
pageSize: 10,
showSizePicker: true,
pageSizes: [10, 20, 50],
+ itemCount: computed(() => filteredData.value.length), // 使用过滤后的数据长度
onChange: (page: number) => {
pagination.value.page = page
- loadData(props.classId)
+ // 前端分页不需要重新加载数据
},
onUpdatePageSize: (pageSize: number) => {
pagination.value.pageSize = pageSize
pagination.value.page = 1
- loadData(props.classId)
+ // 前端分页不需要重新加载数据
}
})
@@ -1190,6 +1219,24 @@ const handleTemplateDownload = (type?: string) => {
// TODO: 实现模板下载逻辑
}
+// 搜索处理
+const handleSearch = () => {
+ // 搜索是实时的,通过计算属性filteredData自动过滤
+ // 重置到第一页
+ pagination.value.page = 1
+}
+
+// 监听搜索关键词变化,重置分页
+watch(searchKeyword, () => {
+ pagination.value.page = 1
+})
+
+// 清空搜索
+const clearSearch = () => {
+ searchKeyword.value = ''
+ pagination.value.page = 1
+}
+
// 监听班级ID变化,重新加载数据
watch(
() => props.classId,
@@ -1197,6 +1244,9 @@ watch(
if (newClassId !== oldClassId) {
// 同步更新选择器的状态(不触发选择器的watch)
selectedDepartment.value = newClassId ? String(newClassId) : ''
+ // 切换班级时清空搜索
+ searchKeyword.value = ''
+ pagination.value.page = 1
loadData(newClassId)
}
},
@@ -1212,6 +1262,9 @@ watch(
// 如果当前props.classId存在且与选择器值一致,说明是props驱动的变化,不需要重复加载
const currentPropsClassId = props.classId ? String(props.classId) : ''
if (newDepartmentId !== oldDepartmentId && newDepartmentId !== currentPropsClassId) {
+ // 切换班级时清空搜索
+ searchKeyword.value = ''
+ pagination.value.page = 1
const targetClassId = newDepartmentId || null
loadData(targetClassId)
}
@@ -1482,57 +1535,6 @@ defineExpose({
gap: 8px;
}
-.batch-delete-content {
- text-align: center;
-}
-
-.batch-delete-content p {
- margin: 8px 0;
- font-size: 14px;
-}
-
-.selected-students {
- margin: 16px 0;
- max-height: 200px;
- overflow-y: auto;
-}
-
-.student-list {
- display: flex;
- flex-direction: column;
- gap: 8px;
- padding: 12px;
- background-color: #f8f9fa;
- border-radius: 6px;
- border: 1px solid #e9ecef;
-}
-
-.student-item {
- display: flex;
- align-items: center;
- gap: 8px;
- padding: 6px 12px;
- background-color: white;
- border-radius: 4px;
- border: 1px solid #dee2e6;
-}
-
-.student-name {
- font-weight: 500;
- color: #333;
-}
-
-.student-account {
- color: #666;
- font-size: 12px;
-}
-
-.batch-warning {
- color: #ff4d4f;
- font-weight: 500;
- margin-top: 16px;
-}
-
.batch-delete-content {
text-align: center;
padding: 20px 0;
diff --git a/src/views/teacher/AdminDashboard.vue b/src/views/teacher/AdminDashboard.vue
index 7ee9ef6..20308fd 100644
--- a/src/views/teacher/AdminDashboard.vue
+++ b/src/views/teacher/AdminDashboard.vue
@@ -133,7 +133,7 @@
diff --git a/src/views/teacher/student/StudentLibrary.vue b/src/views/teacher/student/StudentLibrary.vue
index e7fb1f9..99fc095 100644
--- a/src/views/teacher/student/StudentLibrary.vue
+++ b/src/views/teacher/student/StudentLibrary.vue
@@ -1,5 +1,5 @@
-
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -360,4 +709,37 @@ onMounted(() => {
align-items: center;
gap: 12px;
}
+
+/* 班级列样式 */
+.class-cell {
+ line-height: 1.4;
+ word-break: break-all;
+ white-space: normal;
+ max-width: 150px;
+ min-height: 20px;
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ padding: 4px 8px;
+}
+
+.class-cell-item {
+ padding: 1px 0;
+ font-size: 13px;
+ color: #333;
+ border-radius: 2px;
+ margin: 1px 0;
+}
+
+.class-cell-item:not(:last-child) {
+ border-bottom: 1px solid #f0f0f0;
+ padding-bottom: 2px;
+ margin-bottom: 2px;
+}
+
+.modal-footer {
+ display: flex;
+ justify-content: end;
+ gap: 12px;
+}