1. 程式人生 > >上一頁 下一頁

上一頁 下一頁

console head 表格 def checkbox getitem table ini 點擊

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;
    }
    
}

上一頁 下一頁