You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
klhis/file/yzdtemplate/Yzd.html

100 lines
2.5 KiB

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style>
/*
@media print {
@page {margin: 0;size:A4 portrait;}
body {margin: 0cm;}
}
*/
</style>
</head>
<body style="height: 100%;" onload="init()">
<div id="yzd" style='width:210mm;height:297mm;border:1px none red'>
</div>
<script >
function init(){
let cbData = new YzdToWatData("load","");
YzdToWatData.feedbackDataToWat(JSON.stringify(cbData));
}
//定义打印前事件
const beforePrint = function () {
console.log("打印前");
};
//定义打印后事件
const afterPrint = function () {
let cbData = new YzdToWatData("printNext","");
YzdToWatData.feedbackDataToWat(JSON.stringify(cbData));
}
//监听window状态
if (window.matchMedia) {
let mediaQueryList = window.matchMedia('print');
//为印添加事件
mediaQueryList.addListener(function (mql) {
debugger;
if (mql.matches) {
beforePrint();
} else {
afterPrint();
}
});
}
//打印前事件
window.onbeforeprint = beforePrint;
//打印后事件
window.onafterprint = afterPrint;
function watResultToIFrame(data){
//debugger;
//alert(data);
var jsonData = JSON.parse(data);
if(jsonData.event=="render"){
//twdRender(jsonData);
document.getElementById('yzd').innerHTML=jsonData.content;
}else if(jsonData.event=="print"){
window.print();
}else if(jsonData.event=="renderPrint"){
//document.getElementById('yzd').innerHTML=data;
document.getElementById('yzd').innerHTML=jsonData.content;
window.print();
}
}
function watPrint(){
window.print();
}
class YzdToWatData{
constructor(event,data){
this.event = event;
this.data = data ;
}
static GetQueryString(name){
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null){
return unescape(r[2]);
}
return null;
}
static feedbackDataToWat(data){
return window.parent.top.DxURLPage.action(YzdToWatData.GetQueryString('strwinid'),YzdToWatData.GetQueryString('strctrid'),data);
}
}
</script>
</body>
</html>