feat: add set control extension value api #293
This commit is contained in:
@@ -83,6 +83,7 @@ export class Command {
|
||||
public executeDeleteGroup: CommandAdapt['deleteGroup']
|
||||
public executeLocationGroup: CommandAdapt['locationGroup']
|
||||
public executeSetControlValue: CommandAdapt['setControlValue']
|
||||
public executeSetControlExtension: CommandAdapt['setControlExtension']
|
||||
public getCatalog: CommandAdapt['getCatalog']
|
||||
public getImage: CommandAdapt['getImage']
|
||||
public getOptions: CommandAdapt['getOptions']
|
||||
@@ -209,6 +210,7 @@ export class Command {
|
||||
this.getContainer = adapt.getContainer.bind(adapt)
|
||||
// 控件
|
||||
this.executeSetControlValue = adapt.setControlValue.bind(adapt)
|
||||
this.executeSetControlExtension = adapt.setControlExtension.bind(adapt)
|
||||
this.getControlValue = adapt.getControlValue.bind(adapt)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import { DeepRequired } from '../../interface/Common'
|
||||
import {
|
||||
IGetControlValueOption,
|
||||
IGetControlValueResult,
|
||||
ISetControlExtensionOption,
|
||||
ISetControlValueOption
|
||||
} from '../../interface/Control'
|
||||
import {
|
||||
@@ -2083,6 +2084,12 @@ export class CommandAdapt {
|
||||
this.draw.getControl().setValueByConceptId(payload)
|
||||
}
|
||||
|
||||
public setControlExtension(payload: ISetControlExtensionOption) {
|
||||
const isReadonly = this.draw.isReadonly()
|
||||
if (isReadonly) return
|
||||
this.draw.getControl().setExtensionByConceptId(payload)
|
||||
}
|
||||
|
||||
public getContainer(): HTMLDivElement {
|
||||
return this.draw.getContainer()
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
IControlOption,
|
||||
IGetControlValueOption,
|
||||
IGetControlValueResult,
|
||||
ISetControlExtensionOption,
|
||||
ISetControlValueOption
|
||||
} from '../../../interface/Control'
|
||||
import { IEditorData } from '../../../interface/Editor'
|
||||
@@ -547,4 +548,32 @@ export class Control {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
public setExtensionByConceptId(payload: ISetControlExtensionOption) {
|
||||
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) {
|
||||
let i = 0
|
||||
while (i < elementList.length) {
|
||||
const element = elementList[i]
|
||||
i++
|
||||
if (element?.control?.conceptId !== conceptId) continue
|
||||
element.control.extension = extension
|
||||
// 修改后控件结束索引
|
||||
let newEndIndex = i
|
||||
while (newEndIndex < elementList.length) {
|
||||
const nextElement = elementList[newEndIndex]
|
||||
if (nextElement.controlId !== element.controlId) break
|
||||
newEndIndex++
|
||||
}
|
||||
i = newEndIndex
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,3 +86,8 @@ export interface ISetControlValueOption {
|
||||
conceptId: string
|
||||
value: string
|
||||
}
|
||||
|
||||
export interface ISetControlExtensionOption {
|
||||
conceptId: string
|
||||
extension: unknown
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user