king
2021-01-04 158a48ac7861279c02c01d1020ef54ce94e62770
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}