feat(platform): Clear pagination cache on search to ensure results start from the first page
Added functionality to clear pagination cache when a search is performed, forcing the results to display from the first page. This includes checks for search keywords and updates to local storage accordingly.
This commit is contained in:
@@ -87,6 +87,14 @@ var table,form,element,repeat_flag = false;
|
|||||||
|
|
||||||
// 搜索功能
|
// 搜索功能
|
||||||
form.on('submit(search)', function(data) {
|
form.on('submit(search)', function(data) {
|
||||||
|
// 搜索时清除分页缓存,强制从第一页开始
|
||||||
|
if (table && table.options && table.options.routeUrl) {
|
||||||
|
var tablePageLocalStoreAge = getLocalStorage('tablePageLocalStoreAge');
|
||||||
|
if (tablePageLocalStoreAge && tablePageLocalStoreAge[table.options.routeUrl]) {
|
||||||
|
delete tablePageLocalStoreAge[table.options.routeUrl];
|
||||||
|
setLocalStorage('tablePageLocalStoreAge', tablePageLocalStoreAge);
|
||||||
|
}
|
||||||
|
}
|
||||||
refreshTable();
|
refreshTable();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -168,6 +176,19 @@ var table,form,element,repeat_flag = false;
|
|||||||
|
|
||||||
// 刷新表格列表
|
// 刷新表格列表
|
||||||
function refreshTable(){
|
function refreshTable(){
|
||||||
|
// 获取搜索关键词
|
||||||
|
var searchText = $("input[name='keyword']").val();
|
||||||
|
|
||||||
|
// 如果有搜索条件,强制从第一页开始(清除分页缓存)
|
||||||
|
if (searchText && searchText.trim() !== '') {
|
||||||
|
var routeUrl = getRoute().url;
|
||||||
|
var tablePageLocalStoreAge = getLocalStorage('tablePageLocalStoreAge');
|
||||||
|
if (tablePageLocalStoreAge && tablePageLocalStoreAge[routeUrl]) {
|
||||||
|
delete tablePageLocalStoreAge[routeUrl];
|
||||||
|
setLocalStorage('tablePageLocalStoreAge', tablePageLocalStoreAge);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
table = new Table({
|
table = new Table({
|
||||||
id: 'store_list',
|
id: 'store_list',
|
||||||
elem: '#store_list',
|
elem: '#store_list',
|
||||||
@@ -217,10 +238,14 @@ function refreshTable(){
|
|||||||
}]
|
}]
|
||||||
],
|
],
|
||||||
where: {
|
where: {
|
||||||
search_text: $("input[name='keyword']").val(),
|
search_text: searchText,
|
||||||
status: $(".layui-tab.table-tab .layui-tab-title .layui-this").attr('lay-id'),
|
status: $(".layui-tab.table-tab .layui-tab-title .layui-this").attr('lay-id'),
|
||||||
type: $(".layui-tab.table-tab .layui-tab-title .layui-this").attr('lay-type')
|
type: $(".layui-tab.table-tab .layui-tab-title .layui-this").attr('lay-type')
|
||||||
}
|
},
|
||||||
|
// 如果有搜索条件,强制设置从第一页开始
|
||||||
|
page: searchText && searchText.trim() !== '' ? {
|
||||||
|
curr: 1
|
||||||
|
} : undefined
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function joinPlatform(uniacid){
|
function joinPlatform(uniacid){
|
||||||
|
|||||||
Reference in New Issue
Block a user