Browse Source

三测单打印错格

LIJU 1 week ago
parent
commit
26fe9d3c34
1 changed files with 44 additions and 0 deletions
  1. 44 0
      src/components/medical-advice/temperature/graphics.vue

+ 44 - 0
src/components/medical-advice/temperature/graphics.vue

@@ -1578,6 +1578,7 @@ export default {
     },
     // 设置刻度样式
     setScaleStyles(screenWidth, screenHeight) {
+      this.applyConditionalPrintAdjustment()
       // 默认刻度样式
       let pulseStyle = {
         titleMarginTop: '0px',
@@ -1855,6 +1856,49 @@ export default {
       this.legendStyle = legendStyle;
       this.containerStyle = containerStyle;
     },
+    // 打印位置调整已通过CSS媒体查询处理,无需JavaScript逻辑
+     
+     // 条件化打印位置调整方法 - 可在需要时调用
+     applyConditionalPrintAdjustment() {
+       try {
+         console.log('🔧 应用条件化打印位置调整');
+         
+         // 移除之前的条件化打印样式(如果存在)
+         this.removeConditionalPrintCSS();
+         
+         // 创建新的样式元素
+         const style = document.createElement('style');
+         style.id = 'conditional-print-adjustment';
+         style.textContent = `
+           @media print {
+             .container {
+               left: 35px !important;
+             }
+           }
+         `;
+         
+         // 添加到页面头部
+         document.head.appendChild(style);
+         console.log('✅ 条件化打印CSS样式已添加');
+         
+       } catch (error) {
+         console.error('❌ 条件化打印位置调整失败:', error);
+       }
+     },
+     
+     // 移除条件化打印CSS样式
+     removeConditionalPrintCSS() {
+       const style = document.getElementById('conditional-print-adjustment');
+       if (style) {
+         style.remove();
+         console.log('✅ 条件化打印CSS样式已移除');
+       }
+     },
+  },
+  beforeUnmount() {
+    console.log('🧹 组件卸载,清理打印调整功能');
+    // 清理条件化打印CSS样式
+    this.removeConditionalPrintCSS();
   },
 };