fix: set control value error in table #302
This commit is contained in:
@@ -301,8 +301,11 @@ export class Control {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public removeControl(startIndex: number): number | null {
|
public removeControl(
|
||||||
const elementList = this.getElementList()
|
startIndex: number,
|
||||||
|
context: IControlContext = {}
|
||||||
|
): number | null {
|
||||||
|
const elementList = context.elementList || this.getElementList()
|
||||||
const startElement = elementList[startIndex]
|
const startElement = elementList[startIndex]
|
||||||
const { deletable = true } = startElement.control!
|
const { deletable = true } = startElement.control!
|
||||||
if (!deletable) return null
|
if (!deletable) return null
|
||||||
@@ -343,8 +346,8 @@ export class Control {
|
|||||||
return leftIndex
|
return leftIndex
|
||||||
}
|
}
|
||||||
|
|
||||||
public removePlaceholder(startIndex: number) {
|
public removePlaceholder(startIndex: number, context: IControlContext = {}) {
|
||||||
const elementList = this.getElementList()
|
const elementList = context.elementList || this.getElementList()
|
||||||
const startElement = elementList[startIndex]
|
const startElement = elementList[startIndex]
|
||||||
const nextElement = elementList[startIndex + 1]
|
const nextElement = elementList[startIndex + 1]
|
||||||
if (
|
if (
|
||||||
@@ -364,8 +367,8 @@ export class Control {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public addPlaceholder(startIndex: number) {
|
public addPlaceholder(startIndex: number, context: IControlContext = {}) {
|
||||||
const elementList = this.getElementList()
|
const elementList = context.elementList || this.getElementList()
|
||||||
const startElement = elementList[startIndex]
|
const startElement = elementList[startIndex]
|
||||||
const control = startElement.control!
|
const control = startElement.control!
|
||||||
if (!control.placeholder) return
|
if (!control.placeholder) return
|
||||||
@@ -471,16 +474,23 @@ export class Control {
|
|||||||
if (isReadonly) return
|
if (isReadonly) return
|
||||||
let isExistSet = false
|
let isExistSet = false
|
||||||
const { conceptId, value } = payload
|
const { conceptId, value } = payload
|
||||||
const data = [
|
// 设置值
|
||||||
this.draw.getHeaderElementList(),
|
const setValue = (elementList: IElement[]) => {
|
||||||
this.draw.getOriginalMainElementList(),
|
|
||||||
this.draw.getFooterElementList()
|
|
||||||
]
|
|
||||||
for (const elementList of data) {
|
|
||||||
let i = 0
|
let i = 0
|
||||||
while (i < elementList.length) {
|
while (i < elementList.length) {
|
||||||
const element = elementList[i]
|
const element = elementList[i]
|
||||||
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]
|
||||||
|
setValue(td.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (element?.control?.conceptId !== conceptId) continue
|
if (element?.control?.conceptId !== conceptId) continue
|
||||||
isExistSet = true
|
isExistSet = true
|
||||||
const { type } = element.control!
|
const { type } = element.control!
|
||||||
@@ -544,6 +554,15 @@ export class Control {
|
|||||||
i = newEndIndex
|
i = newEndIndex
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 页眉、内容区、页脚同时处理
|
||||||
|
const data = [
|
||||||
|
this.draw.getHeaderElementList(),
|
||||||
|
this.draw.getOriginalMainElementList(),
|
||||||
|
this.draw.getFooterElementList()
|
||||||
|
]
|
||||||
|
for (const elementList of data) {
|
||||||
|
setValue(elementList)
|
||||||
|
}
|
||||||
if (isExistSet) {
|
if (isExistSet) {
|
||||||
this.draw.render({
|
this.draw.render({
|
||||||
isSetCursor: false
|
isSetCursor: false
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ export class SelectControl implements IControlInstance {
|
|||||||
const draw = this.control.getDraw()
|
const draw = this.control.getDraw()
|
||||||
draw.spliceElementList(elementList, leftIndex + 1, rightIndex - leftIndex)
|
draw.spliceElementList(elementList, leftIndex + 1, rightIndex - leftIndex)
|
||||||
// 增加占位符
|
// 增加占位符
|
||||||
this.control.addPlaceholder(preIndex)
|
this.control.addPlaceholder(preIndex, context)
|
||||||
this.element.control!.code = null
|
this.element.control!.code = null
|
||||||
return preIndex
|
return preIndex
|
||||||
}
|
}
|
||||||
@@ -195,7 +195,7 @@ export class SelectControl implements IControlInstance {
|
|||||||
)
|
)
|
||||||
// 清空选项
|
// 清空选项
|
||||||
const prefixIndex = this.clearSelect(context)
|
const prefixIndex = this.clearSelect(context)
|
||||||
this.control.removePlaceholder(prefixIndex)
|
this.control.removePlaceholder(prefixIndex, context)
|
||||||
// 属性赋值元素-默认为前缀属性
|
// 属性赋值元素-默认为前缀属性
|
||||||
const propertyElement = omitObject(
|
const propertyElement = omitObject(
|
||||||
elementList[prefixIndex],
|
elementList[prefixIndex],
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ export class TextControl implements IControlInstance {
|
|||||||
draw.spliceElementList(elementList, startIndex + 1, endIndex - startIndex)
|
draw.spliceElementList(elementList, startIndex + 1, endIndex - startIndex)
|
||||||
} else {
|
} else {
|
||||||
// 移除空白占位符
|
// 移除空白占位符
|
||||||
this.control.removePlaceholder(startIndex)
|
this.control.removePlaceholder(startIndex, context)
|
||||||
}
|
}
|
||||||
// 插入
|
// 插入
|
||||||
const startElement = elementList[startIndex]
|
const startElement = elementList[startIndex]
|
||||||
|
|||||||
Reference in New Issue
Block a user