/** * @author SPACE * @date 2019年2月13日16:54 */ if(!window.space) { var space = { core: { dev: { page: {} } }, plugins: {}, utils: {} }; } (function() { var currParent = window; var i = 1; while(currParent != top) { currParent = currParent.parent; } space.core.topWindow = currParent; })(); space.core.dev.page.initPage = function() { space.core.dev.page.form = {}; space.core.dev.page.form.rowCount = {}; // 总条数 space.core.dev.page.form.rowCountPerPage = {}; // 单页数据条数 space.core.dev.page.form.currentPageNo = {}; // 当前页码数 space.core.dev.page.form.limits = [10, 15, 20, 25, 30]; // 单页数据条数下拉选择项 }(); space.core.dev.page.loadPage = function(row_count, row_count_per_page, current_page_no) { var devForm = $("#devForm"); var devPage = $("#devForm").attr("devPage"); // 开启分页 if(devPage && devPage == "true") { // 保存分页对象 with(space.core.dev.page.form) { rowCount.value = row_count; rowCountPerPage.value = row_count_per_page; currentPageNo.value = current_page_no; } // 初始化分页容器 layui.laypage.render({ elem: 'devPageDiv', theme: '#28a3ef', curr: space.core.dev.page.form.currentPageNo.value, limit: space.core.dev.page.form.rowCountPerPage.value, count: space.core.dev.page.form.rowCount.value, limits: space.core.dev.page.form.limits, // layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip'], layout: ['count', 'prev', 'page', 'next', 'skip'], jump: function(obj, first) { if(!first) { space.core.dev.page.goPage(obj.curr, obj.limit); } } }); } } /** * 分页跳转 * @param {Object} go_page_no 页码数 * @param {Object} row_count_per_page 单页数据条数 */ space.core.dev.page.goPage = function(go_page_no, row_count_per_page) { space.core.dev.page.form.currentPageNo.value = go_page_no; space.core.dev.page.form.rowCountPerPage.value = row_count_per_page; space.core.dev.page.devFormSubmit(); } /** * 表单提交,将分页对象放入隐藏域 */ space.core.dev.page.devFormSubmit = function() { var row_count_per_page_html = '
'; var current_page_no_html = '
'; $("#devForm").append(row_count_per_page_html); $("#devForm").append(current_page_no_html); $("#devForm").submit(); }