From 8190d6e5ac14616d85e3992169ecef6d99d03b76 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 13 十一月 2020 15:29:57 +0800
Subject: [PATCH] 2020-11-13

---
 src/views/billprint/index.jsx |   64 +++++++++++++-------------------
 1 files changed, 26 insertions(+), 38 deletions(-)

diff --git a/src/views/billprint/index.jsx b/src/views/billprint/index.jsx
index 57d0ea1..33a6125 100644
--- a/src/views/billprint/index.jsx
+++ b/src/views/billprint/index.jsx
@@ -107,46 +107,29 @@
         }
 
         config.style = config.style || {}
+        config.zoom = 1
 
-        if (config.pageSize === 'A0') {
+        if (config.pageSize === 'A3') {
           if (config.pageLayout === 'horizontal') {
-            config.style.height = 1305
+            config.zoom = 1.35
+            config.style.height = 845
           } else {
-            config.style.height = 1305
-          }
-        } else if (config.pageSize === 'A1') {
-          if (config.pageLayout === 'horizontal') {
-            config.style.height = 1305
-          } else {
-            config.style.height = 1305
-          }
-        } else if (config.pageSize === 'A2') {
-          if (config.pageLayout === 'horizontal') {
-            config.style.height = 1305
-          } else {
-            config.style.height = 1305
-          }
-        } else if (config.pageSize === 'A3') {
-          if (config.pageLayout === 'horizontal') {
-            config.style.height = 1305
-          } else {
-            config.style.height = 1305
+            config.style.height = 1695
           }
         } else if (config.pageSize === 'A5') {
+          config.zoom = 0.7
           if (config.pageLayout === 'horizontal') {
-            config.style.height = 1305
+            config.style.height = 840
           } else {
-            config.style.height = 1305
+            config.style.height = 1700
           }
         } else {
           if (config.pageLayout === 'horizontal') {
-            config.style.height = 895
+            config.style.height = 845
           } else {
-            config.style.height = 1305
+            config.style.height = 1680
           }
         }
-
-        // config.style.height = 895
 
         let params = []
         let _pars = []
@@ -194,9 +177,6 @@
             component.setting.dataresource = component.setting.dataresource.replace(/@\$|\$@/ig, '')
             _customScript = _customScript.replace(/@\$|\$@/ig, '')
           }
-
-          component.setting.dataresource = component.setting.dataresource.replace(/@BID@/ig, BID)
-          _customScript = _customScript.replace(/@BID@/ig, BID)
     
           component.setting.customScript = _customScript // 鏁寸悊鍚庤嚜瀹氫箟鑴氭湰
     
@@ -280,6 +260,8 @@
   }
 
   getFormatParam = (params) => {
+    const { BID } = this.state
+
     if (!params || params.length === 0) return ''
     let LText_field = []
     let LText = params.map((item, index) => {
@@ -301,7 +283,8 @@
     let param = {
       func: 'sPC_Get_structured_data',
       LText: LText.join(' union all '),
-      LText_field: LText_field.join(' union all ')
+      LText_field: LText_field.join(' union all '),
+      BID: BID || ''
     }
 
     param.LText = Utils.formatOptions(param.LText)
@@ -366,7 +349,6 @@
         this.setState({loadingview: false, pages})
       }
 
-      // everyPCount, firstCount, lastCount
       while (!over) {
         let page = []
         let count = 0
@@ -463,10 +445,13 @@
   }
 
   print = () => {
-    let bdhtml = window.document.body.innerHTML
+    const { config } = this.state
+
     let jubuData = document.getElementById('bill-print').innerHTML
     window.document.body.innerHTML = jubuData
-    document.getElementsByTagName('body')[0].style.zoom = 0.8
+    document.getElementsByTagName('body')[0].style.width = '1200px'
+    document.getElementsByTagName('body')[0].style.margin = '0 auto'
+    document.getElementsByTagName('body')[0].style.zoom = config.zoom
 
     try {
       if (window.ActiveXObject) {
@@ -508,6 +493,12 @@
       } else {
         window.print()
       }
+
+      document.getElementsByTagName('body')[0].style.zoom = 1
+
+      setTimeout(() => {
+        window.close()
+      }, 2000)
     } catch (e) {
       notification.warning({
         top: 92,
@@ -515,9 +506,6 @@
         duration: 5
       })
     }
-
-    window.document.body.innerHTML = bdhtml
-    window.location.reload()
   }
 
   getComponents = (components) => {
@@ -561,7 +549,7 @@
       <div className="bill-print-wrap" >
         {loadingview && <Spin size="large" />}
         {pages ? <div id="bill-print">
-          {pages.map((components, index) => (<div className="print-page" key={index} style={config.style}><Row>{this.getComponents(components)}</Row></div>))}
+          {pages.map((components, index) => (<div className="print-page" key={index} style={{...config.style, overflow: 'hidden'}}><Row>{this.getComponents(components)}</Row></div>))}
         </div> : null}
         {viewlost ? <NotFount msg={this.state.lostmsg} /> : null}
         {pages && !loadingview && !viewlost ? <div className="print-button"><Button icon="printer" size="large" shape="circle" onClick={this.print}></Button></div> : null}

--
Gitblit v1.8.0