From 2af0847f555af5491640b7a8a650ec57fb309a2c Mon Sep 17 00:00:00 2001 From: Hufe921 Date: Fri, 31 May 2024 21:35:11 +0800 Subject: [PATCH] fix: get controls within the table #628 --- src/editor/core/draw/control/Control.ts | 26 ++++++++++++++----- .../core/draw/control/date/DateControl.ts | 11 +++----- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/editor/core/draw/control/Control.ts b/src/editor/core/draw/control/Control.ts index ae9b79f..47581c4 100644 --- a/src/editor/core/draw/control/Control.ts +++ b/src/editor/core/draw/control/Control.ts @@ -821,20 +821,34 @@ export class Control { } public getList(): IElement[] { - const data = [ - this.draw.getHeader().getElementList(), - this.draw.getOriginalMainElementList(), - this.draw.getFooter().getElementList() - ] const controlElementList: IElement[] = [] - for (const elementList of data) { + function getControlElementList(elementList: IElement[]) { for (let e = 0; e < elementList.length; e++) { const element = elementList[e] + 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] + const tdElement = td.value + getControlElementList(tdElement) + } + } + } if (element.controlId) { controlElementList.push(element) } } } + const data = [ + this.draw.getHeader().getElementList(), + this.draw.getOriginalMainElementList(), + this.draw.getFooter().getElementList() + ] + for (const elementList of data) { + getControlElementList(elementList) + } return zipElementList(controlElementList) } diff --git a/src/editor/core/draw/control/date/DateControl.ts b/src/editor/core/draw/control/date/DateControl.ts index 8323724..964ec0f 100644 --- a/src/editor/core/draw/control/date/DateControl.ts +++ b/src/editor/core/draw/control/date/DateControl.ts @@ -327,13 +327,10 @@ export class DateControl implements IControlInstance { this.datePicker = new DatePicker(this.draw, { onSubmit: this._setDate.bind(this) }) - const range = this.getValueRange() - const value = range - ? elementList - .slice(range[0] + 1, range[1] + 1) - .map(el => el.value) - .join('') - : '' + const value = + this.getValue() + .map(el => el.value) + .join('') || '' const dateFormat = this.element.control?.dateFormat this.datePicker.render({ value,