layui table中記住當前頁


一 同一頁面中編輯后關閉浮窗刷新當前頁

table.reload('list', {
page: {
curr: $(".layui-laypage-em").next().html()
}
, where: { name: $('#search-name').val(), type_id: search_type }
});

二 跳轉頁面后返回當前頁

父頁面中:

table.render({
elem: '.cardapply-table'
, url: '/api/enter/Getcardapply'
, page: {
curr: history.state != null &&history.state.page!=null? history.state.page : 1
}//頁面緩存值為null時頁碼為1 否則取緩存值
, cols: [[
{ type: 'numbers', title: '序號', width: '10%' }
, { field: 'dept_name', width: '10%', title: '所屬室廳', align: 'center', rowspan: '1' }
, { field: 'entery_name', width: '10%', title: '進點聯系單', align: 'center', rowspan: '1' }
, { field: 'room_number', width: '20%', title: '房號', align: 'center', rowspan: '1' }
, { field: 'apply_user', width: '10%', title: '申請人', align: 'center', rowspan: '1' }
, { field: 'apply_reason', width: '10%', title: '申請原因', align: 'center', rowspan: '1' }
, { field: 'apply_date', width: '10%', title: '申請日期', align: 'center', rowspan: '1' }
, {title: '操作', width: '20%', align: 'center', rowspan: '1'}
]]

, where: {
user_name: $.cookie('realname'),
user_id: $.cookie('userId'),
module_id:'0014005'
}
, done: function (res, curr, count)
{
history.replaceState({ page: curr }, null, '#/main/enter/cardapply?page=' + curr); //保存記錄對象並重載頁面路由
}
, id: 'list'
});

跳轉頁面中

window.history.go(-1);//操作成功后返回

注:不能直接寫路由地址 否則頁面緩存會消失;如果是菜單欄切換 避免出現頁面緩存問題 需window.history.replaceState(null, null, null);清空緩存。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM