js分页
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==""?" ":data.complaintDate)+'</td><td>'+complaintsType[data.complaintsType]+'</td><td>'+(data.count==""?" ":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> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td class="tdend"> </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的专栏
相关新闻>>
- 发表评论
-
- 最新评论 更多>>