js分页

来源:未知 责任编辑:智问网络 发表时间:2013-11-08 08:46 点击:

function showSimplePageData(n){
          $("#simpleShowComp").hideLoading();
         $("#simpleShowComp table").html("");
        $('<tr class="tableTitle"><td>投诉日期</td><td>投诉类型</td><td>投诉个数</td></tr>').appendTo("#simpleShowComp table");
        $("#detailState").hide();
        $("#simpleState").show();
        //alert(simpleComplaintRecordList.simpleCurrData[0].complaintDate)
        for(var i=0,j=simpleComplaintRecordList.simpleCurrData.length;i<j;i++){ //consultationList.currData.length
            var data=simpleComplaintRecordList.simpleCurrData[i],elem;
            elem=$('<tr><td> '+(data.complaintDate==""?"&nbsp;":data.complaintDate)+'</td><td>'+complaintsType[data.complaintsType]+'</td><td>'+(data.count==""?"&nbsp;":data.count)+'</td></td></tr>').appendTo("#simpleShowComp table");
        }
/*        for(var i=consultationList.currData.length;i<7;i++){
            $('<dt></dt>').appendTo("#first_view dl");
            $('<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td class="tdend">&nbsp;</td></tr>').appendTo("#second_view table");
        }*/
         showSimplePages(n);
    }
/**
 * 显示投诉记录
 */
    function showSimplePages(curr){
         var showPages=5;
        var totalNum=simpleComplaintRecordList.simpleTotalNum;
        var totalPages=simpleComplaintRecordList.simpleTotalPages;
        var currData=simpleComplaintRecordList.simpleCurrData;
        var currPage=simpleComplaintRecordList.simpleCurrPage;
        //var type=consultationList.type;
        var beginPage=1,endPage=1;
        var quotient=Math.floor((curr-1)/showPages);
        beginPage=showPages*quotient+1;
        endPage=(beginPage+4)>totalPages?totalPages:(beginPage+4);
        if(beginPage>showPages && endPage-beginPage<showPages-1){ //保证如果总页数大于showPages 则次显示的页数为showPages
             beginPage=endPage-showPages+1;
        }
        if(totalPages<1){
            beginPage=1,endPage=1,totalPages=1;
        }
        var html='<span class="number w400">';
         html+=curr==1?'<a title="第一页">‹‹</a>':'<a class="valid" title="第一页" href="javascript:goToSimplePage(1);">‹‹</a>';
        html+=curr==1?'<a title="上一页">‹</a>':'<a class="valid" title="上一页"  href="javascript:goToSimplePage(\'prev\');">‹</a>';
        for(var i=beginPage;i<=endPage;i++){
            html+=i==curr?('<a title="第 '+i+' 页" class="cur">'+i+'</a>'):('<a class="valid"  title="第 '+i+' 页"  href="javascript:goToSimplePage('+i+');">'+i+'</a>');
        }
        html+=curr==totalPages?'<a title="下一页">›</a>':'<a class="valid" title="下一页"  href="javascript:goToSimplePage(\'next\');">›</a>';
        html+=curr==totalPages?'<a title="最后一页">››</a>':('<a class="valid" title="最后一页"  href="javascript:goToSimplePage('+totalPages+');">››</a>');
        html+='</span>';
         html+='<a href="javascript:goToSimplePage(\'\');" class="goto"><!--go--></a> <input type="text" id="pagetextchange" class="pagetext"><span class="count">当前页: '+curr+' / '+totalPages+'</span><span id="simpleSizeSpan" class="size">'+simpleComplaintRecordList.simplePageSize+'</span><span class="count">显示条数:</span>';
        $("#simplePages_pg").html(html).find("span#simpleSizeSpan").click(function(e){
             if($("#simpleSize_style").is(":hidden")){
                $("#simpleSize_style").css({
                    left:$(this).offset().left,
                    top:$(this).offset().top-$("#simpleSize_style").height()-2,
                    width:$(this).width()+5
                }).show();
            }else{
                $("#simpleSize_style").hide();
            }
            e.stopPropagation();
        });
        simpleComplaintRecordList.simpleCurrPage=curr;
    }
    function goToSimplePage(n){
        if(simpleComplaintRecordList.request){
            return;
        }
        if(n=="prev"){
            n=simpleComplaintRecordList.simpleCurrPage-1;
        }else if(n=="next"){
            n=simpleComplaintRecordList.simpleCurrPage+1;
        }else if(n==""){
            n=$("#pagetextchange").val().replace(/\D/g,"");
            if(n==""){
                $("#pagetextchange").val("").focus();
                return false;
            }else{
                n=parseInt(n,10);
                $("#pagetextchange").val(n);
            }
         }
        if(n>simpleComplaintRecordList.totalPages){
            n=simpleComplaintRecordList.totalPages;
        }
        if(n<1){
            n=1;
        }
         $("#simplePages_pg").html("");
        $("#simpleShowComp").showLoading();
        if(type=="detail"){
            getPageData(n);
        }else if(type=="simple"){
            getSimplePageData(n);
        }else{
            getPageData(n);
        }
        
     }
    function getSimplePageData(n){ //noDoctor辨别是否是不选医生的
        simpleComplaintRecordList.request=true; //标识数据正在请求   防止多次点击
        simpleComplaintRecordList.simpleCurrData=[];
        var complaintsProcess_ID=$("#complaintsProcess_ID").val();//投诉流水号(投诉信息事件id)
        var complainant_personID=$("#complainant_personID").val();
        var checkStatus=$("input[name=checkStatus]:checked").val();
        var complaintDate=$("#complaintDate").val().replace("年","-").replace("月","-").replace("日","");
        var complaintsSource=$("#complaintsSource").val();
        var orderName=$("#orderName").val();
        /*var docId=$("#docId").val();
        var userId=$("#userId").val();
        var timeIndex=$("input[name=timeIndex]:checked").val();
        var sourceType=$("input[name=sourceType]:checked").val()||"0";*/
        var data={};
       
            data={simplePageSize:simpleComplaintRecordList.simplePageSize,complaintsSource:complaintsSource,orderName:orderName,currPage:n,complaintsProcess_ID:complaintsProcess_ID,complainant_personID:complainant_personID,checkStatus:checkStatus,complaintDate:complaintDate};
   
        /*if(sourceType==0){
               data={patientId:checkList.patientId,departmentId:depId,doctorId:docId,timeIndex:timeIndex,orderName:checkList.orderName,nowPage:n};
        }else{
            data={patientId:checkList.patientId,userId:userId,timeIndex:timeIndex,orderName:checkList.orderName,nowPage:n};
        }*/

        $.ajax({
            type:"POST",
            url:showSimpleRecordAction,
            data:data,
            dataType:"text",
            success:function(data){
                simpleComplaintRecordList.request=false; //标识数据请求结束
                var data=data.split("|");
                 var dataArr=eval("("+data[0]+")");
                 var type=Object.prototype.toString.apply(dataArr);
                 type=type.substring(8,type.length-1);
                 if(type!="Array"){
                     location.href="loginerror.jsp";
                     return;
                 }
                 simpleComplaintRecordList.simpleTotalNum=data[1];
                 simpleComplaintRecordList.simpleTotalPages=data[2];
                for(var i=0;i<dataArr.length;i++){
                    simpleComplaintRecordList.simpleCurrData[i]={complaintDate:dataArr[i].complaintDate,complaintsType:dataArr[i].complaintsType,count:dataArr[i].count};      
                }
                if(simpleComplaintRecordList.simpleCurrData.length==0){
                    //hideFunPanel1(0);hideFunPanel2(0); //隐藏可能的弹出层
                }
                showSimplePageData(n);
             },
             error:function(){
                 simpleComplaintRecordList.request=false; //标识数据请求结束
                //hideFunPanel1(0);hideFunPanel2(0);
                 alert("获取数据失败!");
             }
        });
    }

摘自 web前端wyy的专栏

    发表评论
    请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
    用户名: 验证码:点击我更换图片
    最新评论 更多>>

    推荐热点

    • Gb2312转utf-8编码的方法(vbs+js)
    • 如何使用Ajax技术开发Web应用程序(1)
    • js跳转路径问题
    • JavaScript模仿桌面窗口
    • 用js检测两个线段是否相交
    • 我知道的JavaScript -- 设计模式(桥接)应用之 – 验证器
    • 运用JavaScript构建你的第一个Metro式应用程序(on Windows
    • 我是如何去了解jquery的(六),案例之幻灯片轮换
    • Jquery封装幻灯片效果
    网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
    Copyright © 2008-2015 计算机技术学习交流网. 版权所有

    豫ICP备11007008号-1