2015-12-02 44 views
0

難以理解如何在BMC Remedy 9.0中打印Join窗體的內容。補救措施的文檔只解釋打印報告,而不是加入表格。我希望能夠使用Ctrl-P或通過內部補救流程/操作鏈接進行打印。我的加入表單主要包含字符字段。儘管頁面寬度爲915像素,高度爲1000像素,但打印預覽會在第一個〜20像素高處截斷。有誰知道我如何在瀏覽器中打印表單?如何打印聯接表單?

回答

0

想通了如何 - 如果您通過所見即所得將所有內容放置在Remedy面板對象中,則可以在Web頁腳中添加一個腳本以將document.body.innerHTML設置爲與面板的innerHTML相同。這個小技巧通過使用window.print()或Ctrl-P使頁面可打印的方式來組織元素。但是,請注意,這個innerHTML分配常常會破壞或丟失兒童textarea或輸入值等屬性。因此,您必須在打印之前查找這些值並將其附加回頁面。

<div> 
    <script> 

    function myPrint() 
    { 
     var idTexts = []; 
     var textareas = document.querySelectorAll('textarea[id][readonly]'); 

     for(var i = 0; i < textareas.length; i++) 
     { 
      idTexts.push(textareas[i].id); 
      idTexts.push(textareas[i].value); 
     } 

     var inputs = document.querySelectorAll('input[id][readonly]'); 

     for(var i = 0; i < inputs.length; i++) 
     { 
      idTexts.push(inputs[i].id); 
      idTexts.push(inputs[i].value); 
     } 

     //Assume there is only one panel object, so only one .pnl class on the page 

     var printContents = document.querySelector('.pnl').innerHTML; 
     document.body.innerHTML = printContents; 

     for(var i = 0; i < idTexts.length; i++) 
     { 
      if(document.getElementById(idTexts[i])) 
      { 
       document.getElementById(idTexts[i]).value = idTexts[i+1]; 
      } 
     } 

     window.print(); 
    } 

    /*On page load, I noticed the click event fired for a visible button 
    without the user actually needing to click. 
    Will not work unless the button's visibility is set to true (Remedy is a weird creature). 
    Used the setTimeout to allow time for the initial page load, as the onload event fired too early. 
    If you don't want this button to appear on the page when it is printed 
    overlay a transparent image on the button's display properties.*/ 

    document.querySelector('a[ardbn="btnPrintMe"]').onclick = setTimeout(function(){ myPrint(); }, 500); 
    </script> 
</div> 

如果仍然有問題打印,確保這個按鈕btnPrintMe至少有正確的6個特權:1101/-1101,1102/-1102,1103/-1103和用戶,您用了這個測試適當的特權也是如此。