浏览器实现打印文件效果

jsp:

style="margin: 0px 15px 15px 15px; ">

js:

var table;
var billNo="";
function initDatatableList() {
	table = $('#tablelist')
	.DataTable(
			{
				"ajax" : {
					"url" : ctx + "/pls/letterWork/letterWorkQueryList.in",
					"data" : function(d) {
						d.timeStart = $('#timeStart').val();
						d.timeEnd = $('#timeEnd').val();
						d.printStat = $('#printStat').val();
						d.letterNum = $('#letterNum').val();
						d.caseId = $('#caseId').val();
						d.letterCd = $('#letterCd').val();
					}
				},
				"columns" : [
					{
						"data" : "letterTemplateCode"
					},
					{
						"data" : "caseId"
					},
					{
						"data" : "letterNum"
					},
					{
						"data" : "idNo"
					},
					{
						"data" : "custName"
					},
					{
						"data" : "mobilePhone"
					},
					{
						"data" : "address"
					},
					{ "data":  
						function(row, type,val, meta) {
							return caseUser(row.lstUpdUser);
						}
					},
					{
						"data": "lstUpdTime" 
					},


					{
						data: function (row, type, val, meta ) {
							return caseEnum("cn.sunline.pls.param.def.enums.Indicator",row.printStat);
						}
					},
					{
						data : function(row, type,
								val, meta) {
							return '打印';
						}
					},
					]
			});
}
function loadCollPage(letterNum) {

	billNo=letterNum;
	collrecTable();
	initTable.modalAddress();
}
function collrecTable(){	
	$.ajax({     
		url : ctx + "/pls/letterWork/recInfo.in",
		type : 'post',
		dataType : 'json',
		data:{billNo},
		success : function(data) {
			 var html='';
			html += data.letterContent;
			
			$("#pls_remember_model").html(html);
		}
	});
}
var initTable = {
    
		modalAddress:function(){
			
			layer.open({
				type: 1,
				shade: false,
				shadeClose: true,
				maxmin: true,
				title :'提示',
				btn: ['确定', '取消'],
				area: ['60%', '60%'], //宽高
				content: $('#pls_remember_model'),
				yes:function(index,layero){
					var  bdhtml=$('#pls_remember_model').html();
					 window.document.body.innerHTML=bdhtml; 
					 window.print();
					 getEditPrintStat();
				},
			});
		},

}

//知识点:btn可以在弹出框加按钮 第一个用yes表示

//改变打印状态
function getEditPrintStat(){
	$.ajax({     
		url : ctx + "/pls/letterWork/getEditPrintStat.in",
		type : 'post',
		dataType : 'json',
		data:{billNo},
		success : function(data) {

		}
	});
}





你可能感兴趣的:(java,JavaScript(js))