king
2022-03-31 fe227dd3d6c4ff9fd031033c15ae7b873dbf5535
src/views/billprint/index.jsx
@@ -36,6 +36,7 @@
    data: '',
    tempId: '',
    config: null,
    auto: true
  }
  UNSAFE_componentWillMount() {
@@ -424,6 +425,12 @@
        this.setState({loadingview: false, pages})
      }
      let auto = true
      if (comps[comps.length - 1].wrap && comps[comps.length - 1].wrap.printHeight) {
        auto = false
      }
      while (!over) {
        let page = []
        let count = 0
@@ -444,10 +451,26 @@
          } else if (_pageover) {
            return
          } else if (item.subtype === 'datacard' || item.type === 'table') {
            if (_item.dataArray && _item.dataArray.length > 0) {
            if (!_item.dataArray || _item.dataArray.length === 0) return
            if (item.subtype === 'datacard' && item.wrap.layout === 'flex') {
              if (!item.added && item.wrap.printHeight) {
                count += item.wrap.printHeight
                if (count >= limit) {
                  _pageover = true
                }
                if (count <= limit) {
                  _item.added = true
                  page.push(item)
                }
              } else if (!item.added) {
                _item.added = true
                page.push(item)
              }
            } else {
              item.data = []
              while (count < limit && _item.dataArray.length > 0) {
              while (count + 1 <= limit && _item.dataArray.length > 0) {
                item.data.push(_item.dataArray.shift())
                count++
              }
@@ -455,6 +478,20 @@
              if (count >= limit) {
                _pageover = true
              }
              page.push(item)
            }
          } else if (!item.added && item.wrap && item.wrap.printHeight) {
            if (item.wrap.empty === 'hidden' && (!item.data || item.data.length === 0)) {
              _item.added = true
              return
            }
            count += item.wrap.printHeight
            if (count >= limit) {
              _pageover = true
            }
            if (count <= limit) {
              _item.added = true
              page.push(item)
            }
          } else if (!item.added) {
@@ -490,10 +527,26 @@
            } else if (_pageover) {
              return
            } else if (item.subtype === 'datacard' || item.type === 'table') {
              if (_item.dataArray && _item.dataArray.length > 0) {
              if (!_item.dataArray || _item.dataArray.length === 0) return
              if (item.subtype === 'datacard' && item.wrap.layout === 'flex') {
                if (!item.added && item.wrap.printHeight) {
                  count += item.wrap.printHeight
                  if (count >= limit) {
                    _pageover = true
                  }
                  if (count <= limit) {
                    _item.added = true
                    page.push(item)
                  }
                } else if (!item.added) {
                  _item.added = true
                  page.push(item)
                }
              } else {
                item.data = []
  
                while (count < limit && _item.dataArray.length > 0) {
                while (count + 1 <= limit && _item.dataArray.length > 0) {
                  item.data.push(_item.dataArray.shift())
                  count++
                }
@@ -501,6 +554,19 @@
                if (count >= limit) {
                  _pageover = true
                }
                page.push(item)
              }
            } else if (!item.added && item.wrap && item.wrap.printHeight) {
              if (item.wrap.empty === 'hidden' && (!item.data || item.data.length === 0)) {
                _item.added = true
                return
              }
              count += item.wrap.printHeight
              if (count >= limit) {
                _pageover = true
              }
              if (count <= limit) {
                _item.added = true
                page.push(item)
              }
            } else if (!item.added) {
@@ -522,7 +588,7 @@
        }
      }
      this.setState({loadingview: false, pages})
      this.setState({loadingview: false, pages, auto})
    })
  }
@@ -648,13 +714,13 @@
  }
  render() {
    const { loadingview, viewlost, config, pages } = this.state
    const { loadingview, viewlost, config, pages, auto } = this.state
    return (
      <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', boxSizing: 'border-box'}}><Row>{this.getComponents(components)}</Row></div>))}
          {pages.map((components, index) => (<div className={'print-page' + (auto ? ' auto' : '')} 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}