1
z8018
2025-12-17 68389acdc272b78f1cc4d80180d4650e6254edcf
ÏîÄ¿´úÂë/WIDESEA_WMSClient/src/extension/basic/extend/printView.vue
@@ -59,13 +59,97 @@
    print() {
      let printContent = document.getElementById("printContent");
      let palletcode=document.getElementById("palletcode");
      var printWindow = window.open("", "");
      printWindow.document.write(printContent.innerHTML);
      printWindow.document.write(palletcode.innerHTML);
      var printWindow = window.open("", "", "width=400,height=400");
      // åˆ›å»ºå®Œæ•´çš„HTML结构以避免空白页
      printWindow.document.write(`
        <!DOCTYPE html>
        <html>
        <head>
          <meta charset="UTF-8">
          <title>打印</title>
          <style>
            @page {
              size: auto;
              margin: 0;
            }
            body {
              margin: 0;
              padding: 10px;
              font-family: Arial, sans-serif;
              background: white;
            }
            .print-container {
              width: 100%;
              height: 100vh;
              display: flex;
              flex-direction: column;
              justify-content: center;
              align-items: center;
              page-break-after: avoid;
            }
            .qrcode-container {
              display: flex;
              justify-content: center;
              align-items: center;
              margin-bottom: 20px;
            }
            .pallet-code {
              display: flex;
              justify-content: center;
              align-items: center;
              font-size: 18px;
              font-weight: bold;
            }
            canvas {
              display: block !important;
              margin: auto !important;
            }
            @media print {
              body {
                margin: 0;
                padding: 5mm;
              }
              .print-container {
                width: 100%;
                height: 100vh;
                page-break-after: avoid;
                page-break-inside: avoid;
              }
            }
          </style>
        </head>
        <body>
          <div class="print-container">
            <div class="qrcode-container">
              ${printContent.innerHTML}
            </div>
            <div class="pallet-code">
              ${palletcode.innerHTML}
            </div>
          </div>
          <script>
            window.onload = function() {
              setTimeout(function() {
                window.print();
                window.close();
              }, 500);
            };
          <\/script>
        </body>
        </html>
      `);
      printWindow.document.close();
      printWindow.focus();
      printWindow.print();
      printWindow.close();
      this.http
            .post("api/palletCodeInfo/PrintStatusUp?printCode="+this.palletCode, null, "数据处理中")
            .then((x) => {