Просмотр исходного кода

feat(库存分配): 添加打印模式下备注显示切换功能

liujt 3 месяцев назад
Родитель
Сommit
1d8a85d9a9

+ 12 - 1
src/views/warehouseManagement/inventoryAllocation/components/print-template-bs-car.vue

@@ -133,7 +133,18 @@
                 autosize
               ></el-input>
             </td>
-            <td style="padding: 5px"> {{ item.remark }} </td>
+            <td style="padding: 5px">
+              <span v-if="isPrint">{{ item.remark }}</span>
+              <el-input
+                v-else
+                type="textarea"
+                style="width: 100%; border: none;"
+                placeholder=""
+                v-model="item.remark"
+                class="input-with-select"
+                autosize
+              ></el-input> 
+            </td>
           </tr>
           <tr style="height: 40px;">
             <td style="border: 1px solid #000; padding: 8px; text-align: center;"></td>

+ 34 - 2
src/views/warehouseManagement/inventoryAllocation/components/print-template-bs.vue

@@ -50,7 +50,18 @@
             <td style="border: 1px solid #000; padding: 8px; text-align: center;">{{ item.measureUnit || '' }}</td>
             <td style="border: 1px solid #000; padding: 8px; text-align: center;">{{ item.quantity || '' }}</td>
             <td style="border: 1px solid #000; padding: 8px; text-align: center;">{{ item.quantity || '' }}</td>
-            <td style="border: 1px solid #000; padding: 8px; text-align: center;">{{ item.remark || '' }}</td>
+            <td style="border: 1px solid #000; padding: 8px; text-align: center;">
+              <span v-if="isPrint">{{ item.remark }}</span>
+              <el-input
+                v-else
+                type="textarea"
+                style="width: 100%; border: none;"
+                placeholder=""
+                v-model="item.remark"
+                class="input-with-select"
+                autosize
+              ></el-input>
+            </td>
             <td style="border: 1px solid #000; padding: 8px; text-align: center;">{{ item.saleOrderNo || '' }}</td>
             <td style="border: 1px solid #000; padding: 8px; text-align: center;">{{ item.produceRoutingName || '' }}</td>
           </tr>
@@ -97,6 +108,7 @@ export default {
   data () {
     return {
       visible: false,
+      isPrint: false,
       row: {
         customerName: '',
         contactPerson: '',
@@ -157,7 +169,13 @@ export default {
         console.log('detailList', this.detailList)
     },
     confirm () {
-     const printSection = document.getElementById('printSection');
+      this.isPrint = true;
+      this.$nextTick(() => {
+        this.print();
+      });
+    },
+    print() {
+      const printSection = document.getElementById('printSection');
       // 创建打印任务
       const printWindow = window.open('', '_blank');
       printWindow.document.open();
@@ -169,6 +187,20 @@ export default {
       printWindow.document.write(printSection.innerHTML);
       printWindow.document.write('</body></html>');
       printWindow.document.close();
+
+      // 监听打印窗口关闭事件,恢复输入框
+        printWindow.onbeforeunload = function() {
+          self.isPrint = false;
+        };
+        
+        printWindow.onunload = function() {
+          self.isPrint = false;
+        };
+        
+        printWindow.onafterprint = function() {
+          self.isPrint = false;
+        };
+        
       printWindow.onload = function () {
         printWindow.print();
       };