fix: get and set control property in table #323
This commit is contained in:
@@ -419,16 +419,23 @@ export class Control {
|
||||
payload: IGetControlValueOption
|
||||
): IGetControlValueResult {
|
||||
const { conceptId } = payload
|
||||
const elementList = [
|
||||
...this.draw.getHeaderElementList(),
|
||||
...this.draw.getOriginalMainElementList(),
|
||||
...this.draw.getFooterElementList()
|
||||
]
|
||||
const result: IGetControlValueResult = []
|
||||
const getValue = (elementList: IElement[]) => {
|
||||
let i = 0
|
||||
while (i < elementList.length) {
|
||||
const element = elementList[i]
|
||||
i++
|
||||
// 表格下钻处理
|
||||
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]
|
||||
getValue(td.value)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (element?.control?.conceptId !== conceptId) continue
|
||||
const { type, code, valueSets } = element.control!
|
||||
let j = i
|
||||
@@ -450,7 +457,10 @@ export class Control {
|
||||
value: textControlValue || null,
|
||||
innerText: textControlValue || null
|
||||
})
|
||||
} else if (type === ControlType.SELECT || type === ControlType.CHECKBOX) {
|
||||
} else if (
|
||||
type === ControlType.SELECT ||
|
||||
type === ControlType.CHECKBOX
|
||||
) {
|
||||
const innerText = code
|
||||
?.split(',')
|
||||
.map(
|
||||
@@ -467,6 +477,13 @@ export class Control {
|
||||
}
|
||||
i = j
|
||||
}
|
||||
}
|
||||
const elementList = [
|
||||
...this.draw.getHeaderElementList(),
|
||||
...this.draw.getOriginalMainElementList(),
|
||||
...this.draw.getFooterElementList()
|
||||
]
|
||||
getValue(elementList)
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -575,16 +592,22 @@ export class Control {
|
||||
const isReadonly = this.draw.isReadonly()
|
||||
if (isReadonly) return
|
||||
const { conceptId, extension } = payload
|
||||
const data = [
|
||||
this.draw.getHeaderElementList(),
|
||||
this.draw.getOriginalMainElementList(),
|
||||
this.draw.getFooterElementList()
|
||||
]
|
||||
for (const elementList of data) {
|
||||
const setExtension = (elementList: IElement[]) => {
|
||||
let i = 0
|
||||
while (i < elementList.length) {
|
||||
const element = elementList[i]
|
||||
i++
|
||||
// 表格下钻处理
|
||||
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]
|
||||
setExtension(td.value)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (element?.control?.conceptId !== conceptId) continue
|
||||
element.control.extension = extension
|
||||
// 修改后控件结束索引
|
||||
@@ -597,5 +620,13 @@ export class Control {
|
||||
i = newEndIndex
|
||||
}
|
||||
}
|
||||
const data = [
|
||||
this.draw.getHeaderElementList(),
|
||||
this.draw.getOriginalMainElementList(),
|
||||
this.draw.getFooterElementList()
|
||||
]
|
||||
for (const elementList of data) {
|
||||
setExtension(elementList)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user