| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- /**
- * @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 = '<input type="hidden" name="currentPageNo" id="currentPageNo" value="' + space.core.dev.page.form.currentPageNo.value + '" /><br>';
- var current_page_no_html = '<input type="hidden" name="rowCountPerPage" id="rowCountPerPage" value="' + space.core.dev.page.form.rowCountPerPage.value + '" /><br>';
- $("#devForm").append(row_count_per_page_html);
- $("#devForm").append(current_page_no_html);
- $("#devForm").submit();
- }
|