页面加入js和定义点击按钮 <a id="btn" href="#" data-options="iconCls:'icon-search'">打印</a> <script src="../scripts/lhgdialog/lhgdialog.js?skin=idialog"></script> 点击事件 $(function () { $('#btn').bind('click', function () { var row = grid.getSelectedRow(); console.log("所选择的行是:" + row); if (row) { if (confirm('确认要执行打印操作吗?')) { var rid = row.KeyId; var oid = row.orderid; var ysp = row.yspmc; console.log("所选择的行是1:" + rid); console.log("所选择的行是1:" + oid); print_printdy('打印后加工单JYD' + oid + ',' + ysp + '', '/JydWodrmb/print_printhjg.aspx?KeyId=' + rid + '&OrderID=' + oid + ''); } } else { msg.warning('请选择要打印的行。'); } }); }); 执行事件 function print_printdy(title, url) { var dialog = $.dialog({ title: title, content: 'url:' + url, min: false, max: false, lock: true, width: 850, height: 650, zIndex: 9999 }); } 做好一个打印模板 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="print_printhjg.aspx.cs" Inherits="NetWing.BPM.Admin.JydWodrmb.print_printhjg" %> <!DOCTYPE html> <%@ Import Namespace="System.Collections.Generic" %> <%@ Import Namespace="System.Text" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.Sql" %> <%@ Import Namespace="System.Data.SqlClient" %> <%@ Import Namespace="NetWing.Common" %> <%@ Import Namespace="NetWing.Common.Data" %> <%@ Import Namespace="NetWing.Common.Data.SqlServer" %> <%@ Import Namespace="NetWing.Common.Provider" %> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>聚源达后加工单</title> <meta content="" name="keywords"> <meta content="" name="description"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-status-bar-style" content="black"> <script type="text/javascript" src="../scripts/jquery-1.10.2.min.js"></script> <script type="text/javascript" src="../scripts/lhgdialog/lhgdialog.js?skin=idialog"></script> <link type="text/css" rel="stylesheet" href="css/base.css" /> <script> //窗口API var api = frameElement.api, W = api.opener; var myDate = new Date(); api.button( { name: '确认打印', focus: true, callback: function () { printWin(); return false; } }, //{ // name: '导出Excel', // callback: function () { // ajaxExcel(); // return false; // } //}, { name: '取消' } ); //打印方法 function printWin() { var oWin = window.open("", "_blank"); oWin.document.write(document.getElementById("print_content").innerHTML); oWin.focus(); oWin.document.close(); oWin.print() oWin.close() } </script> </head> <body> <form id="form1" runat="server"> <div id="print_content"> <!--全局变量--> <table cellspacing="0" cellpadding="0" width="100%" border="0"> <tr> <td valign="top"> <table cellspacing="0" cellpadding="0" width="100%" border="0"> <tr> <td height="11"> <!--接件单名--> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <p style="text-align:center;margin:0 auto;"> <img width="61" height="34" src="/JydWodrmb/img/dyt.png" / style="text-align:center;"><b style="font-size:24px;font-family: 微软雅黑;height:30px; line-height:30px;margin:4px 0 0 0; ">昆明聚源达彩印包装有限公司后加工单</span></span></b><b><span style="font-family: 宋体; font-size: 18pt;"></span></b> </p> <tr> <!--日期--> <table width="100%" border="0" id="3"> <tr style="width:100%; float:left; margin:0px 0 5px 0;" > <td style="width:32% !important;font-family: 微软雅黑;font-size: 12px;float:left; ">后加工厂:<%=myws %></td> <td style="width:25% !important;font-family: 微软雅黑;font-size: 12px;float:left; ">下单人:<%=myxd %></td> <td style="width:25% !important;font-family: 微软雅黑;font-size: 12px;float:left; ">后加工人: <%=mysh %></td> <%if(myxdrq == null){%> <%}else{%> <%if (!string.IsNullOrEmpty(myxdrq)){%> <td style="width:32% !important;font-family: 微软雅黑;font-size: 12px;float:left; ">开单日期:<%=DateTime.Parse(myxdrq).ToString("yyyy-MM-dd")%></td> <%} %> <%}%> <td style="width:25% !important;font-family: 微软雅黑;font-size: 12px;float:left; "> <%if(myjhrq == null){%> <%}else{%> <%if (!string.IsNullOrEmpty(myjhrq)) {%> <span>交货日期:<%=DateTime.Parse(myjhrq).ToString("yyyy-MM-dd") %></span> <%}else{%> <span>交货日期:<%=myjhrq%></span> <%} %> <%}%> </td> </tr> </table> </tr> </table> </td> </tr> </table> <div> <table border="1" cellspacing="0" style="border-collapse: collapse; width:100%;"> <tbody> <!--首行名称--> <tr> <td width="90" valign="center" style="font-family: 微软雅黑; font-size: 12px;"> <p style="text-align: center;"> <span style="font-family: 微软雅黑; font-size: 12px;">印刷品名</span> </p> </td> <td width="98" valign="center" style="font-family: 微软雅黑; font-size: 12px;"> <p style="text-align: center;"> <span style="font-family: 微软雅黑; font-size: 12px;">接件单号</span> </p> </td> <td width="39" valign="center" style="font-family: 微软雅黑; font-size: 12px;"> <p style="text-align: center;"> <span style="font-family: 微软雅黑; font-size: 12px;">加工尺寸</span> </p> </td> <td width="48" valign="center" style="font-family: 微软雅黑; font-size: 12px;"> <p style="text-align: center;"> <span style="font-family: 微软雅黑; font-size: 12px;">加工数量</span> </p> </td> <td width="64" valign="center" style="font-family: 微软雅黑; font-size: 12px;"> <p style="text-align: center;"> <span style="font-family: 微软雅黑; font-size: 12px;">单价</span> </p> </td> <td width="44" valign="center" style="font-family: 微软雅黑; font-size: 12px;"> <p style="text-align: center;"> <span style="font-family: 微软雅黑; font-size: 12px;">金额</span> </p> </td> </tr> <!--数值--> <%foreach (DataRow dr in dt.Rows) { %> <tr> <td width="90" valign="center" style="font-family: 微软雅黑; font-size: 12px;"> <p style="text-align: center;"> <span style="font-family: 微软雅黑; font-size: 12px;"><%=yspmc %></span> </p> </td> <td width="98" valign="center" style="font-family: 微软雅黑; font-size: 12px;"> <p style="text-align: center;"> <span style="font-family: 微软雅黑; font-size: 12px;"><%=orderid %></span> </p> </td> <td width="39" valign="center" style="font-family: 微软雅黑; font-size: 12px;"> <p style="text-align: center;"> <span style="font-family: 微软雅黑; font-size: 12px;"><%=mycc %></span> </p> </td> <td width="48" valign="center" style="font-family: 微软雅黑; font-size: 12px;"> <p style="text-align: center;"> <span style="font-family: 微软雅黑; font-size: 12px;"><%=mynum %></span> </p> </td> <td width="64" valign="center" style="font-family: 微软雅黑; font-size: 12px;"> <p style="text-align: center;"> <span style="font-family: 微软雅黑; font-size: 12px;"><%=mydj %></span> </p> </td> <td width="44" valign="center" style="font-family: 微软雅黑; font-size: 12px;"> <p style="text-align: center;"> <span style="font-family: 微软雅黑; font-size: 12px;"><%=myysf %></span> </p> </td> </tr> <!--工艺--> <%-- <tr> </tr>--%> <!--注释--> <%}%> <!--合计--> <tr> <td width="618" valign="top" colspan="12" style="border: 1.0000pt solid windowtext;"> <p style="text-align: justify;"> <span style="font-family: 微软雅黑; font-size: 12px;">金额:</span> <span style="font-family: 微软雅黑; font-size: 12px;"><%=myysf %>元</span> <span style="font-family: 微软雅黑; font-size: 12px;"></span> </p> <p style="text-align: justify;"> <span style="font-family: 微软雅黑; font-size: 12px;">加工项目:</span> <span style="font-family: 微软雅黑; font-size: 12px;"><%=myzzxm %></span> <span style="font-family: 微软雅黑; font-size: 12px;"></span> </p> <p style="text-align: justify;"> <span style="font-family: 微软雅黑; font-size: 12px;">加工备注:</span> <span style="font-family: 微软雅黑; font-size: 12px;"><%=wsjgbz %></span> <span style="font-family: 微软雅黑; font-size: 12px;"></span> </p> </td> </tr> </tbody> </table> </div> </div> </td> <td></td> </tr> </table> </form> </body> </html>
Copyright © 2004-2024 Ynicp.com 版权所有 法律顾问:建纬(昆明)律师事务所 昆明市网翼通科技有限公司 滇ICP备08002592号-4