From f05801f2ee1f1d394f3b018255f5a84df5356a2e Mon Sep 17 00:00:00 2001
From: zhanghua <314079846@qq.com>
Date: 星期二, 24 十二月 2024 12:09:58 +0800
Subject: [PATCH] 打印优化

---
 src/views/order/index.vue |   68 ++++++++++++++++++++++++++++++---
 1 files changed, 61 insertions(+), 7 deletions(-)

diff --git a/src/views/order/index.vue b/src/views/order/index.vue
index 05f2131..c3e6348 100644
--- a/src/views/order/index.vue
+++ b/src/views/order/index.vue
@@ -16,7 +16,7 @@
         </el-input>
       </div>
     </div>
-    <div style="height: calc(100vh - 208px)">
+    <div style="height: calc(100vh - 168px)">
       <el-table
         v-loading="listLoading"
         :data="list"
@@ -70,8 +70,8 @@
 </template>
 
 <script>
-import { getData } from "@/api/order";
-import { printHtml } from "@/utils/print";
+import { getData, findPlayerAccByOrderId } from "@/api/order";
+import { printHtml, loadPrintStyle } from "@/utils/print";
 import { convertCurrency } from "@/utils/ruoyi";
 
 export default {
@@ -109,6 +109,7 @@
   },
   created() {
     this.fetchData();
+    // loadPrintStyle();
   },
   methods: {
     reloadData() {
@@ -136,13 +137,27 @@
     },
     handlePrint(row) {
       const orgName = JSON.parse(localStorage.getItem("selectStaff")).org.name;
+      row.orgName = orgName;
 
+      if (row.payType == "DIRECT") {
+        findPlayerAccByOrderId({ orderId: row.id }).then((res) => {
+          if (res.data.findPlayerAccByOrderId.length > 0) {
+            row.saleStaffName = res.data.findPlayerAccByOrderId[0].staffName;
+          }
+
+          this.doPrint(row);
+        });
+      } else {
+        this.doPrint(row);
+      }
+    },
+    doPrint(row) {
       let detail = "";
       row.details.forEach((o) => {
         detail += `<tr>
-                <td> ${o.voucherName || o.goodsName}</td>
+                <td>${o.voucherName || o.goodsName}</td>
                 <td>${o.qty} </td>
-                <td> ${o.giftQty}</td>
+                <td>${o.giftQty || 0}</td>
                 <td>${o.amt}</td>
                 <td>${row.saleStaff.name} </td>
             </tr>`;
@@ -150,7 +165,7 @@
 
       let printData = `<div style="display: flex; justify-content: center;">
     <div style="margin-top: 50px; width: 600px;line-height: 2;">
-        <h2 style="text-align: center;">${orgName}缂磋垂鏀舵嵁 </h2>
+        <h2 style="text-align: center;">${row.orgName}缂磋垂鏀舵嵁 </h2>
         <div> 璁㈠崟鍙凤細${row.number}</div>
         <div class="div-2-column">
             <div> 瀛﹀憳濮撳悕锛�<u>${
@@ -192,11 +207,12 @@
         <br>
         <br>
         <div class="div-2-column">
-            <div> 缁忓姙浜猴細${row.buyer.name}  </div>
+            <div>缁忓姙浜猴細${row.saleStaffName || ""}  </div>
             <div>缁忓姙鏃ユ湡锛�${row.createTime} </div>
         </div>
     </div>
 </div>`;
+
       printHtml(printData);
     },
     showCreate() {
@@ -205,3 +221,41 @@
   },
 };
 </script>
+<style>
+#print-container {
+  display: none;
+}
+@media print {
+  body > :not(.print-container) {
+    display: none;
+  }
+  html,
+  body {
+    display: block !important;
+  }
+  #print-container {
+    display: block;
+  }
+}
+@page {
+  margin-top: 0;
+  margin-bottom: 0;
+}
+.div-2-column {
+  display: flex;
+  flex-direction: row;
+  justify-content: space-between;
+}
+.m-h2 {
+  text-align: center;
+  font-size: 1.17em;
+  margin-top: 50px;
+  font-weight: bold;
+}
+#tr {
+  height: 30px;
+}
+.txt-center {
+  text-align: center;
+}
+</style>
\ No newline at end of file

--
Gitblit v1.8.0