From 7c35ece1b6c9df4bd8da7e86e535a096bde2b223 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 04 一月 2021 14:18:18 +0800 Subject: [PATCH] 2021-01-04 --- src/views/billprint/index.jsx | 28 ++++++++++++++++++---------- 1 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/views/billprint/index.jsx b/src/views/billprint/index.jsx index 0419dc9..56f813f 100644 --- a/src/views/billprint/index.jsx +++ b/src/views/billprint/index.jsx @@ -26,6 +26,7 @@ state = { dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, loadingview: true, + printing: false, pages: null, BID: '', data: '', @@ -120,7 +121,7 @@ horizontal: 1200, verticaldefault: 1.45789, verticalwithout: 1.41428, - horizontaldefault: 0.685, + horizontaldefault: 0.683, horizontalwithout: 0.705, }, A3: { @@ -476,8 +477,13 @@ } print = () => { - const { config } = this.state + const { config, printing } = this.state + + if (printing) return + let jubuData = document.getElementById('bill-print').innerHTML + + this.setState({printing: true}) try { let iframe = document.createElement('IFRAME') @@ -503,14 +509,16 @@ doc.write(`</body></html>`) doc.close() - iframe.contentWindow.focus() - iframe.contentWindow.print() - - document.body.removeChild(iframe) - setTimeout(() => { - window.close() - }, 2000) + iframe.contentWindow.focus() + iframe.contentWindow.print() + + document.body.removeChild(iframe) + + setTimeout(() => { + window.close() + }, 2000) + }, 500) } catch (e) { notification.warning({ top: 92, @@ -571,7 +579,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, overflow: 'hidden'}}><Row>{this.getComponents(components)}</Row></div>))} + {pages.map((components, index) => (<div className="print-page" key={index} style={{...config.style, overflow: 'hidden', boxSizing: 'border-box'}}><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