1. 程式人生 > >LODOP列印控制每頁列印一定行數

LODOP列印控制每頁列印一定行數

function doPrint(){
	intype=combo_intype.getActualValue();
	dept=combo_dept.getActualValue();
	checkdate=$("#checkdate").val();
	checkdate2=$("#checkdate2").val();
	//empname=comb_empname.getActualValue();
	 empname=$("#empname").val();
	 if(empname.match(/\d*/)){
	 	
	 }else if(empname.match([\u4e00-\u9fa5]/g)){
     	empname=encodeURI(empname);
     }
	var str="checkdate="+checkdate+"&medtype="+encodeURI(encodeURI(intype))+"&empname="+empname+"&dept="+dept+
	"&checkdate2="+checkdate2+"&time="+(new Date()).valueOf();
	var zongshu;
	$.ajax({
		async: false,
		cache: false,
		ifModified: true,
		type: "post",
		url: "staform/tongjichuyuanbingrenCount.htm",
		data:str,
		dataType: "json",
		error:function(){
            alert("伺服器內部錯誤!");
        },
		success: function(data){
				var count = data.value;
				zongshu=count;
  		}
	});
	$.ajax({
		async:false,
		cache:false,
		type: "post",
		url:'staform/cybrPrint.htm',
		data:str,
		error:function(){
			alert('fail');
		},
		success:function(data){
			var textHtm='<table width="700" border="0" cellspacing="0" cellpadding="0" class="biangeng_5">'
                     +'<tr>'
                     +'<td colspan="2" style="font-size:20px; font-weight:bold; text-align:center; height:49px;">按日期統計出院病人</td>'
                     +'</tr>'
                     +'<tr>'
                     +'   <td colspan="2" class="biangeng_8" height="38";>'
	                 +'       <table width="700" border="0" cellspacing="0" cellpadding="0">'
	                 +'           <tr>'
	                 +'             <td width="100" style="font-size:15.6px;">合計人數:</td>'
	                 +'             <td width="100" style="font-size:15.6px;">'+zongshu+'</td>'
	                 +'           <td width="100"></td>'
	                 +'            <td width="85" style="font-size:15.6px;">統計日期:</td>'
	                 +'           <td width="165" style="font-size:15.6px;"> '+checkdate+' 至 '+checkdate2+' </td>'
	                 +'           </tr>'
	                 +'      </table>'
                     +' </td>'
                     +'  </tr>'
                     +' </table>';
			var textHtml='<table width="100%" border="1" width="100%" cellspacing="0" cellpadding="0" bgcolor="#000000" class="mar3" style="font-size:14px;">'
	                 +'         <tr bgcolor="#FFFFFF" align="center">'
	                 +'          <td width="8%" style="font-size:15.6px;height:30px;">病案號</td>'
	                 +'          <td width="10%" style="font-size:15.6px;height:30px;">病人姓名</td>'
	                 +'          <td width="6%" style="font-size:15.6px;height:30px;">床位號</td>'
	                 +'         <td width="12%" style="font-size:15.6px;height:30px;">科室名稱</td>'
	                 +'         <td width="12%" style="font-size:15.6px;height:30px;">出院日期</td>'
	                 +'         <td width="12%" style="font-size:15.6px;height:30px;">結算日期</td>'
	                 +'         <td width="10%" style="font-size:15.6px;height:30px;">主治醫生</td>'
	                 +'         <td width="30%" style="font-size:15.6px;height:30px;">出院診斷</td>'
	                 +'       </tr>'

			LODOP.NEWPAGE();
			LODOP.PRINT_INITA(0,0,"210mm","297mm",""); //列印前初始化,若放在迴圈裡初始化,則只會打印出最後一次LODOP.ADD_PRINT_HTM,只能初始化一次
			LODOP.SET_PRINT_PAGESIZE(1,2100,0,"A4");
			LODOP.ADD_PRINT_HTM(0,10,663,"60mm","<style>  tr{height:50px;} td {font-size:13px;height:20px;} input{border:none; border:1px solid #000;}</style>"+textHtm);
			LODOP.ADD_PRINT_HTM(84,10,736,"270mm","<style>  tr{height:50px;} td {font-size:13px;height:20px;} input{border:none; border:1px solid #000;}</style>"+textHtml);			
			var js=eval("("+data+")");
			var flag=1;
			for(var i=0;i<js.length;i++){
			    var bedno=js[i].bedno==null?'':js[i].bedno;
				textHtml+='<tr bgcolor="#FFFFFF" align="center">'
				+'<td width="8%" style="font-size:15.6px;height:30px;">'+js[i].inpno+'</td>'
				+'<td width="10%" style="font-size:15.6px;height:30px;">'+js[i].patname+'</td>'
				+'<td width="6%" align="center" style="font-size:15.6px;text-align:left;height:30px;">'+(js[i].bedno==null?'':js[i].bedno)+'</td>'
				+'<td width="12%" align="center" style="font-size:15.6px;height:30px;">'+js[i].wardname+'</td>'
				+'<td width="12%" align="center" style="font-size:15.6px;height:30px;">'+(js[i].preout_date==null?'':js[i].preout_date)+'</td>'
				+'<td width="12%" style="font-size:15.6px;height:30px;">'+(js[i].out_date==null?'':js[i].out_date)+'</td>'
				+'<td width="10%" style="font-size:15.6px;height:30px;">'+js[i].doctorname+'</td>'
				+'<td width="30%" style="font-size:15.6px;text-align:left;height:30px;">'+(js[i].diagname.substring(0,14))+'</td></tr>'
				flag=flag+1;//alert(flag);
				if(flag>=31){
					flag=1;
					textHtml+="</table>";
					LODOP.ADD_PRINT_HTM(84,10,736,"270mm","<style>  tr{height:50px;} td {font-size:13px;height:20px;} input{border:none; border:1px solid #000;}</style>"+textHtml);
				    LODOP.NEWPAGE();
				    textHtml='<table width="100%" border="1" width="100%" cellspacing="0" cellpadding="0" bgcolor="#000000" class="mar3" style="font-size:14px;">'
	                 +'         <tr bgcolor="#FFFFFF" align="center">'
	                 +'          <td width="8%" style="font-size:15.6px;height:30px;">病案號</td>'
	                 +'          <td width="10%" style="font-size:15.6px;height:30px;">病人姓名</td>'
	                 +'          <td width="6%" style="font-size:15.6px;height:30px;">床位號</td>'
	                 +'         <td width="12%" style="font-size:15.6px;height:30px;">科室名稱</td>'
	                 +'         <td width="12%" style="font-size:15.6px;height:30px;">出院日期</td>'
	                 +'         <td width="12%" style="font-size:15.6px;height:30px;">結算日期</td>'
	                 +'         <td width="10%" style="font-size:15.6px;height:30px;">主治醫生</td>'
	                 +'         <td width="30%" style="font-size:15.6px;height:30px;">出院診斷</td>'
	                 +'       </tr>'
				}
			}	
			if(flag<31)	{
			textHtml+="</table>";
			//LODOP.NEWPAGE();
			LODOP.ADD_PRINT_HTM(84,10,736,"270mm","<style>  tr{height:50px;} td {font-size:13px;height:20px;} input{border:none; border:1px solid #000;}</style>"+textHtml);
			}
			LODOP.PREVIEW();
  			//LODOP.PRINT_DESIGN(); 			
  			//LODOP.PRINT();
		}
	});	
}