| | |
| | | } |
| | | } |
| | | |
| | | while (!over) { |
| | | let page = [] |
| | | let count = 0 |
| | | let _pageover = false |
| | | |
| | | comps.forEach(comp => { |
| | | let item = fromJS(comp).toJS() |
| | | |
| | | if (item.wrap.printType === 'headerOrfooter') { // 页眉页脚 |
| | | item.data = item.dataArray || null |
| | | setData(item) |
| | | page.push(item) |
| | | comp.added = true |
| | | } |
| | | |
| | | if (_pageover) return |
| | | |
| | | if (item.$page && comp.dataArray.length > 0) { |
| | | item.data = [] |
| | | |
| | | while (count + 1 <= limit && comp.dataArray.length > 0) { |
| | | item.data.push(comp.dataArray.shift()) |
| | | count++ |
| | | } |
| | | |
| | | if (count >= limit || comp.dataArray.length > 0) { |
| | | _pageover = true |
| | | } |
| | | |
| | | if (comp.dataArray.length === 0) { |
| | | if (this.state.config.printPage === 'custom' && this.state.config.printScripts) { |
| | | try { |
| | | // eslint-disable-next-line |
| | | let func = new Function('components', 'pages', 'notification', this.state.config.printScripts) |
| | | func(comps, pages, notification) |
| | | } catch (e) { |
| | | console.warn(e) |
| | | |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '自定义脚本执行错误!', |
| | | duration: 5 |
| | | }) |
| | | } |
| | | } else { |
| | | while (!over) { |
| | | let page = [] |
| | | let count = 0 |
| | | let _pageover = false |
| | | |
| | | comps.forEach(comp => { |
| | | let item = fromJS(comp).toJS() |
| | | |
| | | if (item.wrap.printType === 'headerOrfooter') { // 页眉页脚 |
| | | item.data = item.dataArray || null |
| | | setData(item) |
| | | page.push(item) |
| | | comp.added = true |
| | | } |
| | | |
| | | setData(item) |
| | | page.push(item) |
| | | } else if (!comp.added) { |
| | | if (item.wrap.printHeight) { |
| | | count += item.wrap.printHeight |
| | | if (count >= limit) { |
| | | _pageover = true |
| | | return |
| | | |
| | | if (_pageover) return |
| | | |
| | | if (item.$page && comp.dataArray.length > 0) { |
| | | item.data = [] |
| | | |
| | | while (count + 1 <= limit && comp.dataArray.length > 0) { |
| | | item.data.push(comp.dataArray.shift()) |
| | | count++ |
| | | } |
| | | |
| | | if (count >= limit || comp.dataArray.length > 0) { |
| | | _pageover = true |
| | | } |
| | | |
| | | if (comp.dataArray.length === 0) { |
| | | comp.added = true |
| | | } |
| | | |
| | | setData(item) |
| | | page.push(item) |
| | | } else if (!comp.added) { |
| | | if (item.wrap.printHeight) { |
| | | count += item.wrap.printHeight |
| | | if (count >= limit) { |
| | | _pageover = true |
| | | return |
| | | } |
| | | } |
| | | |
| | | item.data = item.dataArray || null |
| | | |
| | | setData(item) |
| | | page.push(item) |
| | | comp.added = true |
| | | } |
| | | |
| | | item.data = item.dataArray || null |
| | | |
| | | setData(item) |
| | | page.push(item) |
| | | comp.added = true |
| | | }) |
| | | |
| | | pages.push(page) |
| | | pageIndex++ |
| | | |
| | | if (pageIndex >= 2000 || comps.findIndex(comp => !comp.added) === -1) { |
| | | over = true |
| | | } |
| | | }) |
| | | |
| | | pages.push(page) |
| | | pageIndex++ |
| | | |
| | | if (pageIndex >= 2000 || comps.findIndex(comp => !comp.added) === -1) { |
| | | over = true |
| | | } |
| | | } |
| | | |