Browse Source

修复搜索功能,添加重置按钮,确保搜索和重置时获取所有货源

Boss3
Default User 1 month ago
parent
commit
2321f84a7f
  1. 15
      supply.html

15
supply.html

@ -1343,9 +1343,10 @@
<!-- 搜索框 -->
<div class="search-container">
<div class="search-box">
<input type="text" class="search-input" placeholder="搜索货源名称" id="searchInput" oninput="onSearchInput(event)" onkeypress="onSearchConfirm(event)">
<div id="clearSearch" class="clear-icon" style="display: none;" onclick="clearSearch()"></div>
<div class="search-box" style="display: flex; gap: 10px; align-items: center;">
<input type="text" class="search-input" placeholder="搜索货源名称" id="searchInput" oninput="onSearchInput(event)" onkeypress="onSearchConfirm(event)" style="flex: 1;">
<div id="clearSearch" class="clear-icon" style="display: none; cursor: pointer; padding: 4px; border-radius: 4px; transition: all 0.3s ease;" onclick="clearSearch()"></div>
<button onclick="clearSearch()" style="padding: 10px 16px; background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%); color: #666; border: 2px solid #e0e0e0; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 500; transition: all 0.3s ease; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);">重置</button>
</div>
<!-- 当前登录用户信息提示 -->
<div id="currentUserInfo" style="margin-top: 10px; font-size: 12px; color: #666; text-align: right;"></div>
@ -5542,7 +5543,7 @@
searchInput.value = '';
supplyData.searchKeyword = '';
document.getElementById('clearSearch').style.display = 'none';
searchSupplies();
loadSupplies(); // 直接调用loadSupplies重新加载所有货源
}
async function searchSupplies() {
@ -5551,10 +5552,12 @@
const userInfo = checkLogin();
if (!userInfo) return;
// 构建查询参数,添加sellerId
// 构建查询参数,获取所有匹配的货源
const queryParams = new URLSearchParams({
sellerId: userInfo.userId,
keyword: supplyData.searchKeyword
keyword: supplyData.searchKeyword,
page: 1,
pageSize: 1000 // 设置较大的pageSize,确保获取所有匹配的记录
});
const response = await fetch(`/api/supplies?${queryParams}`);

Loading…
Cancel
Save