| | |
| | | params.unshift(_pars) |
| | | } |
| | | |
| | | if (config.everyPCount && !config.printPage) { // 兼容 |
| | | config.printPage = 'page' |
| | | } |
| | | |
| | | config.printPage = config.printPage || 'auto' |
| | | |
| | | if (config.printPage === 'auto') { |
| | | config.everyPCount = 99999 |
| | | } |
| | | |
| | | config.limit = config.everyPCount || 15 |
| | | |
| | | this.setState({ |
| | | auto: config.printPage === 'auto', |
| | | config |
| | | }, () => { |
| | | if (params.length === 0) { |
| | |
| | | * @description 主表数据加载 |
| | | */ |
| | | loadmaindata = (params) => { |
| | | const { components, everyPCount, firstCount, lastCount } = this.state.config |
| | | const { components, limit } = this.state.config |
| | | |
| | | let deffers = params.map(item => { |
| | | let componentId = item.componentId |
| | |
| | | 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 |
| | | let _pageover = false |
| | | let pagesover = false |
| | | |
| | | let limit = pageIndex === 1 ? (firstCount || 20) : (everyPCount || 20) |
| | | |
| | | comps.forEach((_item, index) => { |
| | | let item = fromJS(_item).toJS() |
| | |
| | | |
| | | if (count >= limit) { |
| | | _pageover = true |
| | | } else if (_item.dataArray.length > 0) { |
| | | _pageover = true |
| | | |
| | | } |
| | | |
| | | page.push(item) |
| | | } |
| | | _item.added = true |
| | |
| | | } |
| | | }) |
| | | |
| | | if (pagesover && lastCount && count > lastCount) { |
| | | pagesover = false |
| | | page = [] |
| | | count = 0 |
| | | _pageover = false |
| | | |
| | | if (pageIndex === 1) { |
| | | limit = (everyPCount - firstCount) + (everyPCount - lastCount) |
| | | |
| | | if (limit <= 0) { |
| | | limit = firstCount |
| | | } |
| | | } else { |
| | | limit = lastCount |
| | | } |
| | | |
| | | comps.forEach((_item, index) => { |
| | | let item = fromJS(_item).toJS() |
| | | if (item.wrap && item.wrap.printType === 'headerOrfooter') { // 页眉页脚 |
| | | page.push(item) |
| | | } else if (_pageover) { |
| | | return |
| | | } else if (item.subtype === 'datacard' || item.type === 'table') { |
| | | if (_item.dataArray && _item.dataArray.length > 0) { |
| | | 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 + 1 <= limit && _item.dataArray.length > 0) { |
| | | item.data.push(_item.dataArray.shift()) |
| | | count++ |
| | | } |
| | | |
| | | if (count >= limit) { |
| | | _pageover = true |
| | | } |
| | | page.push(item) |
| | | } |
| | | _item.added = true |
| | | } else if (!item.added) { |
| | | _item.added = 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) { |
| | | _item.added = true |
| | | page.push(item) |
| | | } |
| | | |
| | | if (index + 1 === length && !_pageover) { |
| | | pagesover = true |
| | | } |
| | | }) |
| | | } |
| | | |
| | | pages.push(page) |
| | | pageIndex++ |
| | | |
| | | if (pageIndex >= 200 || pagesover) { |
| | | if (pageIndex >= 2000 || pagesover) { |
| | | over = true |
| | | } |
| | | } |
| | | |
| | | this.setState({loadingview: false, pages, auto}) |
| | | this.setState({loadingview: false, pages}) |
| | | }) |
| | | } |
| | | |