fix: disable table pagination in continuous page mode

pr675
Hufe921 2 years ago
parent 3f8399de62
commit d0500ac583

@ -3,6 +3,7 @@ import { ZERO } from '../../dataset/constant/Common'
import { RowFlex } from '../../dataset/enum/Row' import { RowFlex } from '../../dataset/enum/Row'
import { import {
IAppendElementListOption, IAppendElementListOption,
IComputeRowListPayload,
IDrawFloatPayload, IDrawFloatPayload,
IDrawOption, IDrawOption,
IDrawPagePayload, IDrawPagePayload,
@ -1095,7 +1096,8 @@ export class Draw {
return el.actualSize || el.size || this.options.defaultSize return el.actualSize || el.size || this.options.defaultSize
} }
public computeRowList(innerWidth: number, elementList: IElement[]) { public computeRowList(payload: IComputeRowListPayload) {
const { innerWidth, elementList, isPagingMode = false } = payload
const { defaultSize, defaultRowMargin, scale, tdPadding, defaultTabWidth } = const { defaultSize, defaultRowMargin, scale, tdPadding, defaultTabWidth } =
this.options this.options
const defaultBasicRowMarginHeight = this.getDefaultBasicRowMarginHeight() const defaultBasicRowMarginHeight = this.getDefaultBasicRowMarginHeight()
@ -1206,10 +1208,11 @@ export class Draw {
const tr = trList[t] const tr = trList[t]
for (let d = 0; d < tr.tdList.length; d++) { for (let d = 0; d < tr.tdList.length; d++) {
const td = tr.tdList[d] const td = tr.tdList[d]
const rowList = this.computeRowList( const rowList = this.computeRowList({
(td.width! - tdPaddingWidth) * scale, innerWidth: (td.width! - tdPaddingWidth) * scale,
td.value elementList: td.value,
) isPagingMode
})
const rowHeight = rowList.reduce((pre, cur) => pre + cur.height, 0) const rowHeight = rowList.reduce((pre, cur) => pre + cur.height, 0)
td.rowList = rowList td.rowList = rowList
// 移除缩放导致的行高变化-渲染时会进行缩放调整 // 移除缩放导致的行高变化-渲染时会进行缩放调整
@ -1279,6 +1282,7 @@ export class Draw {
metrics.boundingBoxDescent = elementHeight metrics.boundingBoxDescent = elementHeight
metrics.boundingBoxAscent = -rowMargin metrics.boundingBoxAscent = -rowMargin
// 表格分页处理(拆分表格) // 表格分页处理(拆分表格)
if (isPagingMode) {
const height = this.getHeight() const height = this.getHeight()
const marginHeight = this.getMainOuterHeight() const marginHeight = this.getMainOuterHeight()
let curPagePreHeight = marginHeight let curPagePreHeight = marginHeight
@ -1381,6 +1385,7 @@ export class Draw {
} }
} }
} }
}
} else if (element.type === ElementType.SEPARATOR) { } else if (element.type === ElementType.SEPARATOR) {
element.width = availableWidth / scale element.width = availableWidth / scale
metrics.width = availableWidth metrics.width = availableWidth
@ -2143,7 +2148,11 @@ export class Draw {
} }
} }
// 行信息 // 行信息
this.rowList = this.computeRowList(innerWidth, this.elementList) this.rowList = this.computeRowList({
isPagingMode,
innerWidth,
elementList: this.elementList
})
// 页面信息 // 页面信息
this.pageRowList = this._computePageList() this.pageRowList = this._computePageList()
// 位置信息 // 位置信息

@ -55,7 +55,10 @@ export class Footer {
private _computeRowList() { private _computeRowList() {
const innerWidth = this.draw.getInnerWidth() const innerWidth = this.draw.getInnerWidth()
this.rowList = this.draw.computeRowList(innerWidth, this.elementList) this.rowList = this.draw.computeRowList({
innerWidth,
elementList: this.elementList
})
} }
private _computePositionList() { private _computePositionList() {

@ -55,7 +55,10 @@ export class Header {
private _computeRowList() { private _computeRowList() {
const innerWidth = this.draw.getInnerWidth() const innerWidth = this.draw.getInnerWidth()
this.rowList = this.draw.computeRowList(innerWidth, this.elementList) this.rowList = this.draw.computeRowList({
innerWidth,
elementList: this.elementList
})
} }
private _computePositionList() { private _computePositionList() {

@ -38,7 +38,10 @@ export class Placeholder {
private _computeRowList() { private _computeRowList() {
const innerWidth = this.draw.getInnerWidth() const innerWidth = this.draw.getInnerWidth()
this.rowList = this.draw.computeRowList(innerWidth, this.elementList) this.rowList = this.draw.computeRowList({
innerWidth,
elementList: this.elementList
})
} }
private _computePositionList() { private _computePositionList() {

@ -61,3 +61,9 @@ export interface IGetImageOption {
pixelRatio?: number pixelRatio?: number
mode?: EditorMode mode?: EditorMode
} }
export interface IComputeRowListPayload {
innerWidth: number
elementList: IElement[]
isPagingMode?: boolean
}

Loading…
Cancel
Save