高章伟
2022-03-18 4bfe21c4b5ddc089ae5a95f4b10f6cff148b690d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<apex:page controller="OFSRepairConsignPDFOuterController" showHeader="false" sidebar="false" action="{!init}" applyHtmlTag="false" id="Page">
<head>
<meta name="viewport" content="user-scalable=yes" />
<apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
<apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
<apex:includeScript value="{!URLFOR($Resource.signaturePadMinJs)}"/>
<apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
 
<style type="text/css">
    .ifrm-container {
      overflow:auto;
      -webkit-overflow-scrolling:touch;
      height:800px;
    }
    .ifrm {
      width:100%;
      height: 80%;
      border:none;
    }
</style>
 
<script type="text/javascript">
var signaturePad;
function signCanvas() {
    j$(escapeVfId('Page:Form:outputCanvas')).hide();
    j$(escapeVfId('myCanvas')).show();
    j$(escapeVfId('myCanvas')).css("pointer-events","");
    j$(escapeVfId('myCanvas')).css("background-color","");
    signaturePad.clear();
}
 
function bolckCanvas() {
    blockme();
    saveSignfunc(signaturePad.toDataURL());
}
 
function finishAlert() {
    alert("已签字完毕");
    location.href='/apex/OFSWindowClose';
}
</script>
<title>{!rp.Name}</title>
</head>
    <apex:form id="Form">
    <div class="ifrm-container">
        <iframe src="/apex/OFSRepairConsignPDF?id={!
URLENCODE(rp.Id)}" scrolling="true" width="100%;" class="ifrm"></iframe>
        
        <apex:actionFunction name="saveSignfunc" action="{!saveSign}" rerender="Form" onComplete="savePDF();">
            <apex:param name="firstParam" assignTo="{!signStr}" value="" />
        </apex:actionFunction>
        
        <apex:actionFunction name="savePDF" action="{!savePDF}" rerender="Form" onComplete="finishAlert();return false;" />
        
        <div style="float:right;">
            <apex:outputPanel layout="none" rendered="{!rp.Sign__c == null}">
                <div id="myCanvas_div" style="border:1px solid #000000; width:300px; height:150px;"><apex:outputField Id="outputCanvas" value="{!rp.Sign__c}" /></div>
            </apex:outputPanel>
            <br/>
<!--             <input type="button" value="返回" onclick="location.href='/apex/OFSInsReportLayout?id={!rp.Id}';return false;" style="width:100px"/> -->
            <apex:outputPanel layout="none" rendered="{!rp.Sign__c == null}">
                <input type="button" value="签字" onclick="signCanvas();return false;" style="width:100px"/>
                <input type="button" value="确认并上传" onclick="bolckCanvas();" style="width:100px"/>
            </apex:outputPanel>
        </div>
<script type="text/javascript">
jQuery(document).ready(function() {
    j$(escapeVfId('myCanvas_div')).append("<canvas id='myCanvas' width='300px' height='150px'></canvas>");
    var canvas = j$(escapeVfId('myCanvas'))[0];
    signaturePad = new SignaturePad(canvas);
    j$(escapeVfId('myCanvas')).css("pointer-events","none");
    //if ('{!rp.Sign__c}' != null && '{!rp.Sign__c}' != '') {
        j$(escapeVfId('myCanvas')).hide();
    //} else {
    //    j$(escapeVfId('myCanvas')).css("background-color","rgba(0, 0, 0, 0.06)");
    //}
    
    var rt = document.getElementsByClassName('sfdc_richtext')[0];
    rt.style.width = "300px";
    rt.style.height = "150px";
});
</script>
</div>
    </apex:form>
</apex:page>