Lodop打印从前端到后台

一、前端页面

1.引用js

<script src="${pageContext.request.contextPath}/scripts/LodopFuncs.js" type="text/javascript"></script>

src里面的位置主要是看把这个Lodap的控件放在哪个位置,就引用那个位置。

2.打印按钮,方法名随便写

3.打印加载

function print1(){
		var hosid = mini.get("hosid1").getValue().trim(); // 获取医院编号
    	var hosname = mini.get("hosname1").getValue().trim(); // 获取医院名称
    	var payym = mini.formatDate (mini.get("payym1").getValue(), "yyyy-MM" );//获取日期
       	$.ajax({
			url:"${pageContext.request.contextPath}/HosFeeMonBal.do?method=getPrint1",
			type:"post",
			async:false,
			data:{hosid:hosid,hosname:hosname,payym:payym
				},
			success : function(text) {
				//json转对象
				var data = JSON.parse(text);
				//判断   是否有打印数据
				if(data.length>0){
					//打印方法
					CreateOneFormPage1(data);
					//打印预览
					LODOP.PREVIEW();
				}else{
					mini.alert("未查询到打印数据");
				}
		},
		error : function(jqXHR, textStatus, errorThrown) {	
			mini.unmask();
			mini.alert(jqXHR.responseText);
		}
		});
	}

4.打印。后台处理获取结果集后,进行打印

function CreateOneFormPage1(result){
	    
		var size = result.length;//总记录条数
    	var startRow = 1000;//初始表格
    	var textRow = 120;//表格文本起始高度
    	var allHeight = 30;//表格高度
		LODOP=getLodop();
		
		LODOP.ADD_PRINT_TEXT(12,364,247,34,"医院结算费用待拨付信息");
        LODOP.SET_PRINT_STYLEA(0,"FontSize",12);
        LODOP.SET_PRINT_STYLEA(0,"Alignment",2);
        LODOP.SET_PRINT_STYLEA(0,"Bold",1);
        LODOP.SET_PRINT_STYLEA(0,"Horient",2);
		LODOP.SET_PRINT_STYLE("Alignment",2);
           
        //固定打印方向为横向
		//LODOP.SET_PRINT_PAGESIZE(2);
		
		/* LODOP.ADD_PRINT_TEXT(40,60,40,90,"序号");
		LODOP.ADD_PRINT_RECT(40,60,40,90,0,1); */
		LODOP.ADD_PRINT_TEXT(40,100,75,90,"医院编号");
		LODOP.ADD_PRINT_RECT(40,100,75,90,0,1);
		LODOP.ADD_PRINT_TEXT(40,175,95,90,"医院名称");
		LODOP.ADD_PRINT_RECT(40,175,95,90,0,1);		
		LODOP.ADD_PRINT_TEXT(100,270,45,30,"人次");
		LODOP.ADD_PRINT_RECT(100,270,45,30,0,1);
		LODOP.ADD_PRINT_TEXT(100,315,95,30,"医药费(元)");
		LODOP.ADD_PRINT_RECT(100,315,95,30,0,1);
		LODOP.ADD_PRINT_TEXT(70,270,140,30,"门诊");
		LODOP.ADD_PRINT_RECT(70,270,140,30,0,1);
		LODOP.ADD_PRINT_TEXT(100,410,45,30,"人次");
		LODOP.ADD_PRINT_RECT(100,410,45,30,0,1);
		LODOP.ADD_PRINT_TEXT(100,455,75,30,"住院天数");
		LODOP.ADD_PRINT_RECT(100,455,75,30,0,1);
		LODOP.ADD_PRINT_TEXT(100,530,95,30,"医药费(元)");
		LODOP.ADD_PRINT_RECT(100,530,95,30,0,1);
		LODOP.ADD_PRINT_TEXT(70,410,215,30,"住院");
		LODOP.ADD_PRINT_RECT(70,410,215,30,0,1);
		LODOP.ADD_PRINT_TEXT(70,625,75,60,"小计(元)");
		LODOP.ADD_PRINT_RECT(70,625,75,60,0,1);
		LODOP.ADD_PRINT_TEXT(40,270,430,30,"保健处支付");
		LODOP.ADD_PRINT_RECT(40,270,430,30,0,1);
		LODOP.ADD_PRINT_TEXT(40,700,105,90,"个人支付(元)");
		LODOP.ADD_PRINT_RECT(40,700,105,90,0,1);
		LODOP.ADD_PRINT_TEXT(40,805,95,90,"总费用(元)");
		LODOP.ADD_PRINT_RECT(40,805,95,90,0,1);
		LODOP.ADD_PRINT_TEXT(40,900,45,90,"状态");
		LODOP.ADD_PRINT_RECT(40,900,45,90,0,1);
		           
        //宽度溢出压缩
        LODOP.SET_PRINT_MODE("FULL_WIDTH_FOR_OVERFLOW",true); 

		//循环赋值
		for(var i = 0;i<size;i++){
		 	/* LODOP.ADD_PRINT_TEXT(textRow + (i*allHeight),60,40,90,result[i].indexcolumn);
			LODOP.ADD_PRINT_RECT(textRow + (i*allHeight),60,40,90,0,1); */
		 	
			LODOP.ADD_PRINT_TEXT(textRow + (i*allHeight),100,75,allHeight,result[i].hosid);
			LODOP.ADD_PRINT_RECT(textRow + (i*allHeight),100,75,allHeight,0,1);
			
			LODOP.ADD_PRINT_TEXT(textRow + (i*allHeight),175,95,allHeight,result[i].hosname);
			LODOP.ADD_PRINT_RECT(textRow + (i*allHeight),175,95,allHeight,0,1);
			
			LODOP.ADD_PRINT_TEXT(textRow + (i*allHeight),270,45,allHeight,result[i].outpatpercount);
			LODOP.ADD_PRINT_RECT(textRow + (i*allHeight),270,45,allHeight,0,1);
			
			LODOP.ADD_PRINT_TEXT(textRow + (i*allHeight),315,95,allHeight,result[i].outpatpubfee);
			LODOP.ADD_PRINT_RECT(textRow + (i*allHeight),315,95,allHeight,0,1);
			
			LODOP.ADD_PRINT_TEXT(textRow + (i*allHeight),410,45,allHeight,result[i].inpatpercount);
			LODOP.ADD_PRINT_RECT(textRow + (i*allHeight),410,45,allHeight,0,1);
			
			LODOP.ADD_PRINT_TEXT(textRow + (i*allHeight),455,75,allHeight,result[i].inhosdays);
			LODOP.ADD_PRINT_RECT(textRow + (i*allHeight),455,75,allHeight,0,1);
			
			LODOP.ADD_PRINT_TEXT(textRow + (i*allHeight),530,95,allHeight,result[i].inpatpubfee);
			LODOP.ADD_PRINT_RECT(textRow + (i*allHeight),530,95,allHeight,0,1);
			
			LODOP.ADD_PRINT_TEXT(textRow + (i*allHeight),625,75,allHeight,result[i].totalfee);
			LODOP.ADD_PRINT_RECT(textRow + (i*allHeight),625,75,allHeight,0,1);
			
			LODOP.ADD_PRINT_TEXT(textRow + (i*allHeight),700,105,allHeight,result[i].cashpay);
			LODOP.ADD_PRINT_RECT(textRow + (i*allHeight),700,105,allHeight,0,1);
			
			LODOP.ADD_PRINT_TEXT(textRow + (i*allHeight),805,95,allHeight,result[i].sumfee);
			LODOP.ADD_PRINT_RECT(textRow + (i*allHeight),805,95,allHeight,0,1);
			
			LODOP.ADD_PRINT_TEXT(textRow + (i*allHeight),900,45,allHeight,result[i].auditflag);
			LODOP.ADD_PRINT_RECT(textRow + (i*allHeight),900,45,allHeight,0,1);
			
		} 
	}

 

二、后台处理

在前台执行第3步后,会调到后台进行处理

1.Controller 控制层

/**
	 * 待拨付导出(无分页,打印用)
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(params = "method=getPrint1")
	@ResponseBody
	public void getPrint1(HttpServletRequest request, HttpServletResponse response) throws Exception{
		//获取前台传入参数  分区代码(后期更改)
		String areacode = Component.getSession("AAA027", request);
		//获取前台传入参数  
		String hosid = Component.getQuest("hosid", request);		//医院编号
		String hosname = Component.getQuest("hosname", request);	//医院名称
		String payym = Component.getQuest("payym",request);    		//发生年月
		//查询
		List<HashMap<?,?>> getPrint1 = hosfeemonbalservice.getPrint1(areacode, hosid,hosname,payym);
		//返回
		Component.print(Util.Encode(getPrint1), response);
	}

 

2.Service 业务逻辑层,这里面sql业务逻辑我清空了,根据自己的业务来写,基本上是和查询业务一样,即查询到什么打印什么。

/**
	 * 待拨付导出(无分页,打印用)
	 * @param obj
	 * @param parms
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	public List<HashMap<?, ?>> getPrint1(String areacode,String hosid,String hosname,String payym) throws Exception{
		StringBuffer sb =new StringBuffer();
		sb.append("这里写你的业务sql");
		return sys.SelResultList(sb.toString());
	}

最后将获取到的结果集执行前端页面步骤4

展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客
应支付0元
点击重新获取
扫码支付

支付成功即可阅读