king
2023-08-15 a94b0a4d15b26ecf8fe99f0a1c3e60d60b97766d
src/views/billprint/index.jsx
@@ -38,10 +38,12 @@
    BID: '',
    data: '',
    tempId: '',
    pageId: '',
    config: null,
    urlParam: null,
    visible: false,
    rePos: false,
    loading: false,
    auto: true
  }
@@ -63,7 +65,8 @@
        this.setState({
          BID: param.id || '',
          tempId: param.tempId,
          urlParam: param
          urlParam: param,
          pageId: param.pageId || ''
        }, () => {
          setTimeout(() => {
            this.getMenuParam()
@@ -86,22 +89,36 @@
  componentDidMount() {
    const _this = this
    Object.defineProperty(window, 'debug', {
      configurable: true,
      enumerable: true,
      set(value) {
        if (value + '' === 'false') {
          window.debugger = false
          window.GLOB.breakpoint = false
          sessionStorage.removeItem('breakpoint')
        } else {
          window.debugger = true
          window.GLOB.breakpoint = value + ''
          sessionStorage.setItem('breakpoint', value)
    if (window.GLOB.sysType !== 'cloud') {
      Object.defineProperty(window, 'debugger', {
        configurable: true,
        enumerable: true,
        set(value) {
          if (value + '' === 'false') {
            window.GLOB.debugger = false
          } else {
            window.GLOB.debugger = true
          }
        }
        _this.debugChange()
      }
    })
      })
      Object.defineProperty(window, 'debug', {
        configurable: true,
        enumerable: true,
        set(value) {
          if (value + '' === 'false') {
            window.GLOB.debugger = false
            window.GLOB.breakpoint = false
            sessionStorage.removeItem('breakpoint')
          } else {
            window.GLOB.debugger = true
            window.GLOB.breakpoint = value + ''
            sessionStorage.setItem('breakpoint', value)
          }
          _this.debugChange()
        }
      })
    }
    document.onkeydown = (event) => {
      let e = event || window.event
@@ -121,7 +138,6 @@
      let _shortcut = `${preKey}+${keyCode}`
      if (window.GLOB.breakpoint && _shortcut === 'ctrl+67') {
        window.debugger = false
        window.GLOB.breakpoint = false
        sessionStorage.removeItem('breakpoint')
        
@@ -593,7 +609,7 @@
    }
    // 测试系统打印查询语句
    if (window.GLOB.debugger === true || (window.debugger === true && window.GLOB.sysType !== 'cloud')) {
    if (window.GLOB.debugger === true) {
      _customScript &&  console.info(`${_dataresource ? '' : '/*不执行默认sql*/\n'}${_customScript}`)
      _dataresource &&  console.info(_dataresource)
    }
@@ -845,9 +861,52 @@
  }
  print = () => {
    const { config, printing } = this.state
    const { config, printing, BID, tempId, pageId } = this.state
    
    if (printing) return
    this.setState({printing: true})
    if (config.callback === 'true') {
      this.setState({loading: true})
      Api.genericInterface({
        func: 's_print_proc',
        username: sessionStorage.getItem('User_Name') || '',
        fullname: sessionStorage.getItem('Full_Name') || '',
        BID: BID || '',
        print_type: config.callNo || '',
        MenuNo: config.MenuNo || '',
        Menuid: tempId || ''
      }).then(res => {
        if (!res.status) {
          notification.warning({
            top: 92,
            message: res.message,
            duration: 5
          })
          this.setState({printing: false, loading: false})
          return
        }
        this.setState({loading: false})
        if (pageId) {
          localStorage.setItem('menuUpdate', new Date().getTime() + ',' + pageId + ',menu')
        }
        setTimeout(() => {
          this.execPrint()
        }, 300)
      })
    } else {
      this.execPrint()
    }
  }
  execPrint = () => {
    const { config } = this.state
    let qrcodes = document.getElementsByClassName('qrcode-box')
@@ -878,8 +937,6 @@
    }
    let jubuData = document.getElementById('bill-print').innerHTML
    this.setState({printing: true})
    
    try {
      let iframe = document.createElement('IFRAME')
@@ -1038,11 +1095,11 @@
  }
  render() {
    const { loadingview, viewlost, config, pages, auto, rePos } = this.state
    const { loadingview, viewlost, config, pages, auto, rePos, loading } = this.state
    return (
      <div className="bill-print-wrap" >
        {loadingview && <Spin size="large" />}
        {loadingview || loading ? <Spin size="large" /> : null}
        {pages ? <div id="bill-print">
          {pages.map((components, index) => (<div className={'print-page' + (auto ? ' auto' : '') + (rePos ? ' reset-position' : '')} key={index} style={{...config.style, overflow: 'hidden', boxSizing: 'border-box'}}><Row className="component-wrap">{this.getComponents(components)}</Row></div>))}
        </div> : null}