...
|
...
|
@@ -2,7 +2,7 @@ |
|
|
* @Author: Targaryen
|
|
|
* @Date: 2016-06-02 15:50:47
|
|
|
* @Last Modified by: Targaryen
|
|
|
* @Last Modified time: 2016-06-02 16:05:54
|
|
|
* @Last Modified time: 2016-06-03 16:36:28
|
|
|
*/
|
|
|
|
|
|
'use strict';
|
...
|
...
|
@@ -14,7 +14,7 @@ const _ = require('lodash'); |
|
|
* @param {[type]} newParam [description]
|
|
|
* @return {[type]} [description]
|
|
|
*/
|
|
|
exports.handleFilterUrl = (originParam, newParam) => {
|
|
|
const handleFilterUrl = (originParam, newParam) => {
|
|
|
let dest = '?';
|
|
|
let tempOriginParam = {};
|
|
|
|
...
|
...
|
@@ -45,6 +45,12 @@ exports.handleFilterUrl = (originParam, newParam) => { |
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 筛选类链接处理的对外接口
|
|
|
* @type {[type]}
|
|
|
*/
|
|
|
exports.handleFilterUrl = handleFilterUrl;
|
|
|
|
|
|
/**
|
|
|
* 处理选中数据
|
|
|
* @param {[type]} params [description]
|
|
|
* @param {[type]} origin [description]
|
...
|
...
|
@@ -66,7 +72,7 @@ exports.handleCheckedData = (params, origin, param) => { |
|
|
|
|
|
tempParam[param] = '';
|
|
|
|
|
|
// checked.href = handleFilterUrl(params, tempParam);
|
|
|
checked.href = handleFilterUrl(params, tempParam);
|
|
|
|
|
|
dest.push(checked);
|
|
|
}
|
...
|
...
|
@@ -75,3 +81,83 @@ exports.handleCheckedData = (params, origin, param) => { |
|
|
|
|
|
return dest;
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 处理分页数据
|
|
|
* @param {[type]} total [description]
|
|
|
* @param {[type]} params [description]
|
|
|
* @return {[type]} [description]
|
|
|
*/
|
|
|
exports.handleSalePagerData = (total, params) => {
|
|
|
|
|
|
|
|
|
// 当前页
|
|
|
let currentPage = parseInt((_.isEmpty(params.page) ? 1 : params.page), 10);
|
|
|
let perPageCount = parseInt((_.isEmpty(params.limit) ? 60 : params.limit), 10);
|
|
|
let totalPage = parseInt(total / perPageCount, 10) + 1;
|
|
|
|
|
|
let dest = '<a href ="' + handleFilterUrl(params, { page: (currentPage) }) +
|
|
|
'" class="cur">' + currentPage + '</a>';
|
|
|
|
|
|
// 先处理大多数情况
|
|
|
if ((currentPage > 2) && (currentPage < (parseInt(total, 10) / perPageCount) - 1)) {
|
|
|
|
|
|
for (let i = 1; i < 3; i++) {
|
|
|
dest = '<a href ="' + handleFilterUrl(params, { page: (currentPage - i) }) + '">' +
|
|
|
(currentPage - i) + '</a> ' + dest + ' <a href ="' +
|
|
|
handleFilterUrl(params, { page: (currentPage + i) }) +
|
|
|
'">' + (currentPage + i) + '</a>';
|
|
|
}
|
|
|
|
|
|
// 处理页码小于2的情况
|
|
|
} else if (currentPage <= 2) {
|
|
|
for (let i = currentPage - 1; i > 0; i--) {
|
|
|
dest = '<a href ="' + handleFilterUrl(params, { page: i }) +
|
|
|
'">' + i + '</a>' + dest;
|
|
|
}
|
|
|
|
|
|
for (let i = currentPage + 1; i < (totalPage < 6 ? totalPage : 6); i++) {
|
|
|
dest += '<a href ="' + handleFilterUrl(params, { page: i }) +
|
|
|
'">' + i + '</a>';
|
|
|
}
|
|
|
|
|
|
// 处理页码大于最大页-2的情况
|
|
|
} else if (currentPage > totalPage - 2) {
|
|
|
for (let i = currentPage + 1; i < totalPage + 1; i++) {
|
|
|
dest += '<a href ="' + handleFilterUrl(params, { page: i }) +
|
|
|
'">' + i + '</a>';
|
|
|
}
|
|
|
|
|
|
for (let i = currentPage - 1; i > (currentPage - 5 > 1 ? currentPage - 5 : 1); i--) {
|
|
|
dest = '<a href ="' + handleFilterUrl(params, { page: i }) +
|
|
|
'">' + i + '</a>' + dest;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 处理后省略号的情况
|
|
|
if ((totalPage > 5) && (currentPage < (totalPage - 2))) {
|
|
|
|
|
|
dest += ' ... <a href ="' + handleFilterUrl(params, { page: totalPage }) +
|
|
|
'">' + totalPage + '</a>';
|
|
|
|
|
|
}
|
|
|
|
|
|
// 处理前省略号的情况
|
|
|
if (currentPage > 3) {
|
|
|
dest = '<a href ="' + handleFilterUrl(params, { page: 1 }) +
|
|
|
'">1</a> ... ' + dest;
|
|
|
}
|
|
|
|
|
|
// 处理上一页下一页
|
|
|
if (currentPage !== 1) {
|
|
|
dest = '<a href="' + handleFilterUrl(params, { page: currentPage - 1 }) +
|
|
|
'"><span class="iconfont">上一页</span></a>' + dest;
|
|
|
}
|
|
|
|
|
|
if (currentPage !== totalPage) {
|
|
|
dest += '<a href="' + handleFilterUrl(params, { page: currentPage + 1 }) +
|
|
|
'"><span class="iconfont">下一页</span></a>';
|
|
|
}
|
|
|
|
|
|
return dest;
|
|
|
}; |
...
|
...
|
|