fix: print error of control assistant components in table #311
This commit is contained in:
@@ -257,9 +257,15 @@ export class Draw {
|
||||
main: this.elementList,
|
||||
footer: this.footer.getElementList()
|
||||
}
|
||||
this.setEditorData(
|
||||
this.control.filterAssistElement(deepClone(this.printModeData))
|
||||
// 过滤控件辅助元素
|
||||
const clonePrintModeData = deepClone(this.printModeData)
|
||||
const editorDataKeys: (keyof IEditorData)[] = ['header', 'main', 'footer']
|
||||
editorDataKeys.forEach(key => {
|
||||
clonePrintModeData[key] = this.control.filterAssistElement(
|
||||
clonePrintModeData[key]
|
||||
)
|
||||
})
|
||||
this.setEditorData(clonePrintModeData)
|
||||
}
|
||||
// 取消打印模式
|
||||
if (this.mode === EditorMode.PRINT && this.printModeData) {
|
||||
@@ -500,7 +506,9 @@ export class Draw {
|
||||
public getTableElementList(sourceElementList: IElement[]): IElement[] {
|
||||
const positionContext = this.position.getPositionContext()
|
||||
const { index, trIndex, tdIndex } = positionContext
|
||||
return sourceElementList[index!].trList![trIndex!].tdList[tdIndex!].value
|
||||
return (
|
||||
sourceElementList[index!].trList?.[trIndex!].tdList[tdIndex!].value || []
|
||||
)
|
||||
}
|
||||
|
||||
public getElementList(): IElement[] {
|
||||
|
||||
@@ -11,7 +11,6 @@ import {
|
||||
ISetControlExtensionOption,
|
||||
ISetControlValueOption
|
||||
} from '../../../interface/Control'
|
||||
import { IEditorData } from '../../../interface/Editor'
|
||||
import { IElement, IElementPosition } from '../../../interface/Element'
|
||||
import { EventBusMap } from '../../../interface/EventBus'
|
||||
import { IRange } from '../../../interface/Range'
|
||||
@@ -57,12 +56,18 @@ export class Control {
|
||||
}
|
||||
|
||||
// 过滤控件辅助元素(前后缀、背景提示)
|
||||
public filterAssistElement(
|
||||
payload: Required<IEditorData>
|
||||
): Required<IEditorData> {
|
||||
const editorDataKeys: (keyof IEditorData)[] = ['header', 'main', 'footer']
|
||||
editorDataKeys.forEach(key => {
|
||||
payload[key] = payload[key].filter(element => {
|
||||
public filterAssistElement(elementList: IElement[]): IElement[] {
|
||||
return elementList.filter(element => {
|
||||
if (element.type === ElementType.TABLE) {
|
||||
const trList = element.trList!
|
||||
for (let r = 0; r < trList.length; r++) {
|
||||
const tr = trList[r]
|
||||
for (let d = 0; d < tr.tdList.length; d++) {
|
||||
const td = tr.tdList[d]
|
||||
td.value = this.filterAssistElement(td.value)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (element.type !== ElementType.CONTROL || element.control?.minWidth) {
|
||||
return true
|
||||
}
|
||||
@@ -72,8 +77,6 @@ export class Control {
|
||||
element.controlComponent !== ControlComponent.PLACEHOLDER
|
||||
)
|
||||
})
|
||||
})
|
||||
return payload
|
||||
}
|
||||
|
||||
// 判断选区部分在控件边界外
|
||||
|
||||
Reference in New Issue
Block a user