<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('服务公司许可打印')" />
	<th:block th:include="include :: footer" />
	<th:block th:include="include :: lodop" />
</head>
<body style="text-align: center;padding-top: 20px;font-weight: bold;font-size: 20px">
</body>

<script>
    var LODOP = null;
    var printState=0;
    var host="http://"+window.location.host;
    var printData = {
        gsmc:'[[${printData.gsmc}]]',
        gsdz:'[[${printData.gsdz}]]',
        frmc:'[[${printData.frmc}]]',
        management:'[[${printData.management}]]',
        pzwh:'[[${printData.pzwh}]]',
        fzrq:'[[${printData.fzrq}]]',
        xkzh:'[[${printData.xkzh}]]',
        clrq:'[[${printData.clrq}]]',
        zczb:'[[${printData.zczb}]]',
        id:'[[${printData.id}]]',
        zf: '[[${printData.zf}]]',
        qrcode:'[[${printData.qrcode}]]'
    };
    $(function(){
        LODOP = getLodop();
        if(LODOP != null){
            setTimeout("lodopPrint()", 1500);
            var zf = "[[${printData.zf}]]";
            if (zf == "f") {//副本

                lodopPrint2();
            } else {//正本
                lodopPrint1();
            }
        }
    });


    function lodopPrint1(){
        document.body.innerText="打印中...";
        printState=0;
		LODOP.PRINT_INITA("0mm","0mm","359.99mm","260.01mm","保安服务许可证正本-多行");
		LODOP.SET_PRINT_MODE("PRINT_NOCOLLATE",1);

// 公司名称
		LODOP.ADD_PRINT_HTM("65.62mm","81.76mm","177.27mm","17.2mm",
				`<div style="font-size:28px; font-family:SimSun, 仿宋_GB2312, Arial, sans-serif; font-weight:bold; letter-spacing:2px;">${printData.gsmc || ''}</div>`
		);

// 公司地址
		LODOP.ADD_PRINT_HTM("83.63mm","81.76mm","192.09mm","22.49mm",
				`<div style="font-size:28px; font-family:SimSun, 仿宋_GB2312, Arial, sans-serif; font-weight:bold; line-height:1.5; letter-spacing:2px;">${printData.gsdz.substring(0,20)}<br>${printData.gsdz.substring(20)}</div>`
		);

// 法人名称
		LODOP.ADD_PRINT_HTM("124.35mm","83.08mm","95.78mm","17.73mm",
				`<div style="font-size:28px; font-family:SimSun, 仿宋_GB2312, Arial, sans-serif; font-weight:bold; letter-spacing:2px;">${printData.frmc || ''}</div>`
		);

// 服务范围
		LODOP.ADD_PRINT_HTM("144.46mm","82.29mm","284.32mm","14.02mm",
				`<div style="font-size:28px; font-family:SimSun, 仿宋_GB2312, Arial, sans-serif; font-weight:bold; line-height:1.3; letter-spacing:-2px;">${(printData.management == null || printData.management == "" || printData.management.length < 25) ? (printData.management || '') : printData.management.substring(0,24) + printData.management.substring(24)}</div>`
		);

// 批准文号
		LODOP.ADD_PRINT_HTM("185.21mm","82.29mm","82.79mm","17.99mm",
				`<div style="font-size:28px; font-family:SimSun, 仿宋_GB2312, Arial, sans-serif; font-weight:bold; letter-spacing:2px;">${printData.pzwh == null ? "" : (printData.pzwh.replace("【","[").replace("】","]"))}</div>`
		);

// 发证日期 - 年
		LODOP.ADD_PRINT_HTM("220.93mm","232.83mm","62.44mm","16.93mm",
				`<div style="font-size:28px; font-family:SimSun, 仿宋_GB2312, Arial, sans-serif; font-weight:bold; letter-spacing:2px; text-align:center;">${printData.fzrq == null ? "" : (printData.fzrq).substring(0,4)}</div>`
		);

// 发证日期 - 月
		LODOP.ADD_PRINT_HTM("221.46mm","267.49mm","43.66mm","14.55mm",
				`<div style="font-size:28px; font-family:SimSun, 仿宋_GB2312, Arial, sans-serif; font-weight:bold; letter-spacing:2px; text-align:center;">${printData.fzrq == null ? "" : (printData.fzrq).substring(5,7)}</div>`
		);

// 发证日期 - 日
		LODOP.ADD_PRINT_HTM("221.19mm","293.69mm","31.49mm","15.61mm",
				`<div style="font-size:28px; font-family:SimSun, 仿宋_GB2312, Arial, sans-serif; font-weight:bold; letter-spacing:2px; text-align:center;">${printData.fzrq == null ? "" : (printData.fzrq).substring(8,10)}</div>`
		);

// 许可证编号
		LODOP.ADD_PRINT_HTM("49.95mm","294.14mm","60.36mm","18.52mm",
				`<div style="font-size:23px; font-family:SimSun, 仿宋_GB2312, Arial, sans-serif; font-weight:normal; letter-spacing:2px;">${printData.xkzh == null ? "" : printData.xkzh}</div>`
		);

// 成立日期
		LODOP.ADD_PRINT_HTM("164.25mm","82.21mm","86.52mm","15.08mm",
				`<div style="font-size:28px; font-family:SimSun, 仿宋_GB2312, Arial, sans-serif; font-weight:bold; letter-spacing:2px;">${printData.clrq == null ? "" : (printData.clrq).substring(0,10)}</div>`
		);

// 二维码
		LODOP.ADD_PRINT_IMAGE(276,1052,104,115,printData.qrcode);
		LODOP.SET_PRINT_STYLEA(0,"Stretch",2);

// 静态文字 - 扫描二维码
		LODOP.ADD_PRINT_HTM("402px","1042px","175px","67px",
				`<div style="font-size:15px; font-family:SimSun, 仿宋_GB2312, Arial, sans-serif; text-align:center;">扫描二维码<br>查看电子证照信息</div>`
		);


        //谷歌浏览器
        if (LODOP.CVERSION) {
            CLODOP.On_Return = function (TaskID, Value) {
                //打印状态
                printState = Value;
                if(printState >= 1) {
                    document.body.innerText="打印完成";
                    recordsGenerated(true);
                }else{
                    document.body.innerText="已取消打印";
                    recordsGenerated(false);
                }
            };
        }

        printState = LODOP.PRINT_DESIGN();
        //非谷歌
        if (!LODOP.CVERSION) {
            if(printState >= 1) {
                document.body.innerText="打印完成";
                recordsGenerated(true);
            }else{
                document.body.innerText="已取消打印";
                recordsGenerated(false);
            }
        }
    }

    function lodopPrint2(){
        document.body.innerText="打印中...";
        printState=0;
		LODOP.PRINT_INITA("-2.99mm","0mm","250mm","180mm","保安服务许可证副本单行");
		LODOP.SET_PRINT_MODE("PRINT_NOCOLLATE",1);

// 公司名称
		LODOP.ADD_PRINT_HTM("73.77mm","31.75mm","113.51mm","9.53mm",
				`<div style="font-size:18px; font-family:SimSun, 仿宋_GB2312, Arial, sans-serif; font-weight:bold; letter-spacing:2px;">${printData.gsmc || ''}</div>`
		);

// 公司地址
		LODOP.ADD_PRINT_HTM("84.35mm","31.49mm","111.92mm","15.35mm",
				`<div style="font-size:18px; font-family:SimSun, 仿宋_GB2312, Arial, sans-serif; font-weight:bold; letter-spacing:2px;">${(printData.gsdz == '' || printData.gsdz.length < 18) ? (printData.gsdz || '') : printData.gsdz.substring(0,14) + '<br>' + printData.gsdz.substring(14)}</div>`
		);

// 法人名称
		LODOP.ADD_PRINT_HTM("104.4mm","31.75mm","65.09mm","9mm",
				`<div style="font-size:18px; font-family:SimSun, 仿宋_GB2312, Arial, sans-serif; font-weight:bold; letter-spacing:2px;">${printData.frmc || ''}</div>`
		);

// 服务范围
		LODOP.ADD_PRINT_HTM("115.28mm","31.75mm","103.19mm","9.79mm",
				`<div style="font-size:18px; font-family:SimSun, 仿宋_GB2312, Arial, sans-serif; font-weight:bold; line-height:1.3; letter-spacing:1px;">${(printData.management == null || printData.management.length < 18) ? (printData.management || '') : printData.management.substring(0,14) + '<br>' + printData.management.substring(14)}</div>`
		);

// 批准文号
		LODOP.ADD_PRINT_HTM("125.81mm","31.75mm","91.78mm","9.79mm",
				`<div style="font-size:18px; font-family:SimSun, 仿宋_GB2312, Arial, sans-serif; font-weight:bold; letter-spacing:2px;">${printData.clrq == null ? "" : (printData.clrq).substring(0,10)}</div>`
		);

// 发证日期 - 年
		LODOP.ADD_PRINT_HTM("166.42mm","66.94mm","14.02mm","12.96mm",
				`<div style="font-size:18px; font-family:SimSun, 仿宋_GB2312, Arial, sans-serif; font-weight:bold; text-align:center;">${printData.fzrq == null ? "" : (printData.fzrq).substring(0,4)}</div>`
		);

// 发证日期 - 月
		LODOP.ADD_PRINT_HTM("166.16mm","83.34mm","9.53mm","11.64mm",
				`<div style="font-size:18px; font-family:SimSun, 仿宋_GB2312, Arial, sans-serif; font-weight:bold; text-align:center;">${printData.fzrq == null ? "" : (printData.fzrq).substring(5,7)}</div>`
		);

// 发证日期 - 日
		LODOP.ADD_PRINT_HTM("165.89mm","90.75mm","14.82mm","13.49mm",
				`<div style="font-size:18px; font-family:SimSun, 仿宋_GB2312, Arial, sans-serif; font-weight:bold; text-align:center;">${printData.fzrq == null ? "" : (printData.fzrq).substring(8,10)}</div>`
		);

// 许可证编号
		LODOP.ADD_PRINT_HTM("57.47mm","50.35mm","35.58mm","12.7mm",
				`<div style="font-size:16px; font-family:SimSun, 仿宋_GB2312, Arial, sans-serif; font-weight:normal; letter-spacing:2px;">${printData.xkzh == null ? "" : printData.xkzh}</div>`
		);

// 成立日期
		LODOP.ADD_PRINT_HTM("136.31mm","32.09mm","56.36mm","9.79mm",
				`<div style="font-size:18px; font-family:SimSun, 仿宋_GB2312, Arial, sans-serif; font-weight:bold; letter-spacing:2px;">${printData.pzwh == null ? "" : (printData.pzwh.replace("【","[").replace("】","]"))}</div>`
		);

// 二维码
		LODOP.ADD_PRINT_IMAGE(499,640,113,115,printData.qrcode);
		LODOP.SET_PRINT_STYLEA(0,"Stretch",2);

// 静态文字 - 扫描二维码
		LODOP.ADD_PRINT_HTM("611px","645px","136px","47px",
				`<div style="font-size:15px; font-family:SimSun, 仿宋_GB2312, Arial, sans-serif; text-align:center;">扫描二维码<br>查看电子证照信息</div>`
		);
		//谷歌浏览器
        if (LODOP.CVERSION) {
            CLODOP.On_Return = function (TaskID, Value) {
                //打印状态
                printState = Value;
                if(printState >= 1) {
                    document.body.innerText="打印完成";
                    recordsGenerated(true);
                }else{
                    document.body.innerText="已取消打印";
                    recordsGenerated(false);
                }
            };
        }

        printState = LODOP.PRINT_DESIGN();
        //非谷歌
        if (!LODOP.CVERSION) {
            if(printState >= 1) {
                document.body.innerText="打印完成";
                recordsGenerated(true);
            }else{
                document.body.innerText="已取消打印";
                recordsGenerated(false);
            }
        }
    }
    function recordsGenerated(isPrint) {
        $.ajax({
            type: 'POST',
            url: host + "/manage/cer/recordsComGenerated",
            dataType: "json",
            data: {
                "id":printData.id,
                "isPrint":isPrint
            },
            success: function (json) {
                if (json.successful == true || json.successful == "true") {
                    console.log("更新打印状态成功！");
                } else {
                    console.log("更新打印状态失败！");
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                console && console.log(errorThrown);
            }
        });
    }

</script>
</html>
