hookehuyr

refactor(teacher): 优化班级页面搜索功能并移除无用代码

- 移除性别图标显示和排序功能
- 修改搜索触发逻辑为blur和clear事件
- 增加清空搜索功能
- 调整分页limit从3改为10
......@@ -2,7 +2,7 @@
* @Author: hookehuyr hookehuyr@gmail.com
* @Date: 2025-01-20 10:00:00
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-06-26 11:06:33
* @LastEditTime: 2025-06-26 11:13:22
* @FilePath: /mlaj/src/views/teacher/myClassPage.vue
* @Description: 我的班级页面
-->
......@@ -83,12 +83,12 @@
<div class="p-4 border-b border-gray-100 bg-white">
<div class="flex items-center justify-between mb-3">
<h3 class="text-lg font-bold text-gray-800">班级成员 ({{ studentCount }})</h3>
<div @click="showSortPopup = true" class="flex items-center text-sm text-gray-600 cursor-pointer">
<!-- <div @click="showSortPopup = true" class="flex items-center text-sm text-gray-600 cursor-pointer">
<span>{{ sortFilter }}</span>
<van-icon name="arrow-down" size="14" class="ml-1" />
</div> -->
</div>
</div>
<van-search v-model="searchKeyword" placeholder="请搜索" shape="round" @search="handleSearch" @input="handleSearchInput" />
<van-search v-model="searchKeyword" placeholder="请搜索" shape="round" @blur="handleSearch" @clear="handleClearSearch" @input="handleSearchInput" />
</div>
<!-- 学生列表 -->
......@@ -103,8 +103,8 @@
<div class="flex-1">
<div class="flex items-center">
<span class="font-medium text-gray-800 mr-2">{{ student.name }}</span>
<font-awesome-icon v-if="student.gender === 'male'" icon="venus" color="#3b82f6" class="mr-2" style="font-size: 0.85rem;" />
<font-awesome-icon v-else icon="mars" color="#ec4899" class="mr-2" style="font-size: 0.85rem;" />
<!-- <font-awesome-icon v-if="student.gender === 'male'" icon="venus" color="#3b82f6" class="mr-2" style="font-size: 0.85rem;" />
<font-awesome-icon v-else icon="mars" color="#ec4899" class="mr-2" style="font-size: 0.85rem;" /> -->
</div>
<div class="text-sm text-gray-500" style="text-align: left;">
<span v-for="(item, index) in student.class_list" :key="index" class="mr-2">{{ item.class_name }}</span>
......@@ -204,7 +204,7 @@ const studentCount = ref(0);
// 列表加载状态
const loading = ref(false)
const finished = ref(false)
const limit = ref(3)
const limit = ref(10)
const page = ref(0)
// 请求控制器,用于取消重复请求
......@@ -312,8 +312,7 @@ const handleSearchInput = (value) => {
* 处理搜索 - 立即搜索,无需防抖
* @param {string} value - 搜索关键词
*/
const handleSearch = (value) => {
console.log('搜索:', value);
const handleSearch = () => {
// 清除之前的定时器
if (searchTimer) {
......@@ -321,7 +320,16 @@ const handleSearch = (value) => {
}
// 立即执行搜索
searchKeyword.value = value;
resetAndReload();
}
const handleClearSearch = () => {
// 清除之前的定时器
if (searchTimer) {
clearTimeout(searchTimer);
}
searchKeyword.value = '';
resetAndReload();
}
......