上一页 下一页

时间:2021-06-03 06:10:34
sessionStorage.removeItem('times');
var ding_pageSize = 10;//切换每页显示条数

function exportExcle(url){
$.ajax({

'type':'get',
'url':url,
"dataType":'json',
"data":{

},
"traditional" : true,
success:
function(myData){
// myData = JSON.parse(myData);
//
console.log(myData.data)
if(myData.code==200){


}
}
})
}
function consoleTable(url){
sessionStorage.removeItem(
'consoleCount');
$(
'#console_table').DataTable( {
"info":false,
"filter":false,
"lengthMenu":false,
"ordering":false,
"bDeferRender": true,//大数据量处理,加快速度;
"bAutoWidth": false,//表格自定义宽度,和swidth一起用
//
"pagingType": "simple_numbers", //分页首页和尾页
"paging": false, //开启分页
"iDisplayLength": 10,
"order":[[2]],
"bProcessing": false,
"bDestroy": true,
// "dom": 't<"foot_bottom"p>',
ajax:{
"type":"get",
"url":url,
"data":{


},
"dataType":'json',
"dataSrc": function (mdata) {
// $('#console_table>thead>tr>th:first-child').empty();
//
$('#console_table>thead>tr>th:first-child').append('<input id="allCheck" type="checkbox"/>');
if (!mdata.success || mdata.data == null) {
sessionStorage.setItem(
"consoleCount", 0);

return [];
}
if(mdata.code==200){
if(mdata.data.length>0){

sessionStorage.setItem(
"consoleCount",mdata.total);
return mdata.data;
}
else{
sessionStorage.setItem(
"consoleCount", 0);

return [];
}
}

}
},

// "language":{
//
"sProcessing": '加载中...',
//
"sLoadingRecords":" ",
//
"sEmptyTable": '暂无数据',
//
"decimal":",",
//
"thousands":".",
//
// "sProcessing" : "正在加载中......",
//
// "sLengthMenu" :[[10, 20, -1], [10, 20, "All"]],
//
//"sInfo" : "当前显示 _START_ 到 _END_ 条,共 _TOTAL_ 条记录",
//
// "sInfoEmpty": '显示第 0 至 0 项结果,共 0 项',
//
//"sInfoFiltered" : "数据表*为 _MAX_ 条记录",
//
"oPaginate" : {
//

//
"sPrevious" : "&lt;",
//
"sNext" : "&gt;",
//

//
}
//
//

//
},

"columns":[

{
"data":"gmtCreate"},
{
"data":"accountName"},
{
"data":"creatPerson"},
{
"data":"typeZn"},
{
"data":"definit"},
{
"data":"content"}

],
"aoColumnDefs" : [
{
render:
function(data,type,row){
if(data==null||data==""){
return "--";
}
else{
return new Date(data).format('yyyy-MM-dd HH:mm:ss');
//
}
},

"orderable":false,
"targets": [0]

},
{
//
render:function(data,type,row){
if(data==null||data==""){
return "--";
}
return data;
},

"orderable":false,
"targets": [1]

},
{
render:
function(data,type,row){

if(data==null||data==""){
return "--";
}

return data;


},

"orderable":true,
"targets": [2]


},
{
render:
function(data,type,row){

if(data==null||data==""){
return "--";
}

return data;
},

"orderable":true,
"targets": [3]


},
{
render:
function(data,type,row){

if(data==null||data==""){
return "--";
}

return data;
},

"orderable":true,
"targets": [4]


},
{
//dealEmpId dealRealName dealNickName
render:function(data,type,row){
// console.log(data);
//
console.log(row.contentHistory);
var content=JSON.stringify(data);
var contentlast=JSON.stringify(row.contentHistory);
if(data==null||data==""||data.length==0){
content
= '';
}
if(row.contentHistory==null||row.contentHistory==""||row.contentHistory.length==0){
contentlast
= '';
}
return '<span class="console_look" data-content=\''+content+'\' data-contentlast=\''+contentlast+'\'>查看</span>';
},

"orderable":true,
"targets": [5]


}
],
"fnCreatedRow": function(nRow, aData, iDataIndex) {
// $('td:eq(1)', nRow).addClass("mouseType");
//
$('td:eq(2)', nRow).addClass("ding_name_type");
//
$('td:eq(5)', nRow).addClass("processType");
},
"initComplete":function(data){


var times=sessionStorage.getItem('times');
if(times){

}
else{
var totalCount= sessionStorage.getItem("consoleCount");

if(totalCount==0){
$(
'.page_group').css('display','none');
}
else if(totalCount<=ding_pageSize){//默认显示10条
$('.page_group').css('display','block');
$(
'.pageDetails .mainBTotalNuber>em').html(totalCount);
$(
'.pageDetails .mainBTotalPage>em').html(Math.ceil(totalCount/ding_pageSize));
$('.pageDetails .currentPage>em').html(1);
$(
'.pageDetails span.upPage')[0].dataset.uppage=1;
$(
'.pageDetails span.downPage')[0].dataset.downpage=1;
// $('span.upPage')[0].dataset.saleid=saleId;
// $('span.downPage')[0].dataset.saleid=saleId;
$('.pageDetails span.downPage')[0].dataset.total=totalCount;
$(
'.pageDetails span.upPage').addClass('noAble');
$(
'.pageDetails span.downPage').addClass('noAble');

}
else if(totalCount>ding_pageSize){
$(
'.page_group').css('display','block');
$(
'.pageDetails .mainBTotalNuber>em').html(totalCount);
$(
'.pageDetails .mainBTotalPage>em').html(Math.ceil(totalCount/ding_pageSize));
$('.pageDetails .currentPage>em').html(1);
$(
'.pageDetails span.upPage')[0].dataset.uppage=1;
$(
'.pageDetails span.downPage')[0].dataset.downpage=1;
// $('span.upPage')[0].dataset.saleid=saleId;
// $('span.downPage')[0].dataset.saleid=saleId;
$('.pageDetails span.downPage')[0].dataset.total=totalCount;
$(
'.pageDetails span.upPage').addClass('noAble');
$(
'.pageDetails span.downPage').removeClass('noAble');
}
}

sessionStorage.setItem(
'times',1);

}
///


} );
}
function upPageClick(that,e){

var current=$(that)[0].dataset.uppage;//点击上一页 取下一页的当前值
current=parseInt(current);
// console.log(current);
console.log(ding_pageSize);
if(current==1||current==0){
return ;
}
else{

$(that).next(
'span.downPage').removeClass('noAble');
current
--;

var queryTimes = $("#console_time").val();
var queryTimeList = queryTimes.split(" - ");
var startTime = queryTimeList[0];//开始时间
var endTime = queryTimeList[1];//结束时间
var parentName = $("#customer_name").val();//结束时间
consoleTable('/enterpriseServe/getLogByMap?parentId=&creatPerson=&pageNo='+current+'&pageSize='+ding_pageSize+'&start='+startTime+'&end='+endTime+'&parentName='+parentName);


// $(this).parent().parent('td>table').html(newTable(zjp));/
if(current<=1){//保证下一页最小为第二页 上一页最小为第一页
current=1;
$(that).addClass(
'noAble');
}

$(that).prevAll().filter(
".currentPage").children('em').html(current);//为当前页赋值
$(that).next('span.downPage')[0].dataset.downpage=current;//为下一页赋值(下一页始终比上一页大一个数)

$(that)[
0].dataset.uppage=current;//把页数赋值给上一页

e.stopPropagation();
// $(this).unbind("click"); //移除click
return false;
}
}
function downPageClick(that,e){
var total=$(that)[0].dataset.total;
total
=parseInt(total);
var current=$(that)[0].dataset.downpage;
// var current=$(this).prev('span.upPage')[0].dataset.uppage;
//
console.log(current);
console.log(ding_pageSize);
current
=parseInt(current);

if(current>=(Math.ceil(total/ding_pageSize))){//判断总页数
return ;
}
else{

$(that).prev(
'span.upPage').removeClass('noAble');//能走到这说明下一页可点击 把上一页不可用样式移除
//var pageNo=current++;$(this)[0].dataset.uppage=nn;

current
++;

var queryTimes = $("#console_time").val();
var queryTimeList = queryTimes.split(" - ");
var startTime = queryTimeList[0];//开始时间
var endTime = queryTimeList[1];//结束时间
var parentName = $("#customer_name").val();//结束时间
consoleTable('/enterpriseServe/getLogByMap?parentId=&creatPerson=&pageNo='+current+'&pageSize='+ding_pageSize+'&start='+startTime+'&end='+endTime+'&parentName='+parentName);

if(current>=(Math.ceil(total/ding_pageSize))){//总页数
// current=(Math.ceil(total/10))-1;
$(that).addClass('noAble');

}
$(that).prevAll().filter(
".currentPage").children('em').html(current);//为当前页赋值
$(that).prev('span.upPage')[0].dataset.uppage=current;
$(that)[
0].dataset.downpage=current;//把页数赋值给上一页


e.stopPropagation();
// $(this).unbind("click"); //移除click
return false;
}

}