From fe227dd3d6c4ff9fd031033c15ae7b873dbf5535 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 31 三月 2022 22:39:47 +0800 Subject: [PATCH] 2022-03-31 --- src/views/billprint/index.jsx | 84 +++++++++++++++++++++++++++++++++++++---- 1 files changed, 75 insertions(+), 9 deletions(-) diff --git a/src/views/billprint/index.jsx b/src/views/billprint/index.jsx index ca30872..01b87ed 100644 --- a/src/views/billprint/index.jsx +++ b/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++ } @@ -457,11 +480,25 @@ } 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) { _item.added = true page.push(item) } - + if (index + 1 >= length && !_pageover) { pagesover = true } @@ -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} -- Gitblit v1.8.0