feat: add set control extension value api #293
This commit is contained in:
@@ -833,3 +833,13 @@ Usage:
|
|||||||
```javascript
|
```javascript
|
||||||
instance.command.executeSetControlValue(payload: ISetControlValueOption)
|
instance.command.executeSetControlValue(payload: ISetControlValueOption)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## executeSetControlExtension
|
||||||
|
|
||||||
|
Feature: Set control extension value
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
instance.command.executeSetControlExtension(payload: ISetControlExtensionOption)
|
||||||
|
```
|
||||||
|
|||||||
@@ -833,3 +833,13 @@ instance.command.executeLocationGroup(groupId: string)
|
|||||||
```javascript
|
```javascript
|
||||||
instance.command.executeSetControlValue(payload: ISetControlValueOption)
|
instance.command.executeSetControlValue(payload: ISetControlValueOption)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## executeSetControlExtension
|
||||||
|
|
||||||
|
功能:设置控件扩展值
|
||||||
|
|
||||||
|
用法:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
instance.command.executeSetControlExtension(payload: ISetControlExtensionOption)
|
||||||
|
```
|
||||||
@@ -83,6 +83,7 @@ export class Command {
|
|||||||
public executeDeleteGroup: CommandAdapt['deleteGroup']
|
public executeDeleteGroup: CommandAdapt['deleteGroup']
|
||||||
public executeLocationGroup: CommandAdapt['locationGroup']
|
public executeLocationGroup: CommandAdapt['locationGroup']
|
||||||
public executeSetControlValue: CommandAdapt['setControlValue']
|
public executeSetControlValue: CommandAdapt['setControlValue']
|
||||||
|
public executeSetControlExtension: CommandAdapt['setControlExtension']
|
||||||
public getCatalog: CommandAdapt['getCatalog']
|
public getCatalog: CommandAdapt['getCatalog']
|
||||||
public getImage: CommandAdapt['getImage']
|
public getImage: CommandAdapt['getImage']
|
||||||
public getOptions: CommandAdapt['getOptions']
|
public getOptions: CommandAdapt['getOptions']
|
||||||
@@ -209,6 +210,7 @@ export class Command {
|
|||||||
this.getContainer = adapt.getContainer.bind(adapt)
|
this.getContainer = adapt.getContainer.bind(adapt)
|
||||||
// 控件
|
// 控件
|
||||||
this.executeSetControlValue = adapt.setControlValue.bind(adapt)
|
this.executeSetControlValue = adapt.setControlValue.bind(adapt)
|
||||||
|
this.executeSetControlExtension = adapt.setControlExtension.bind(adapt)
|
||||||
this.getControlValue = adapt.getControlValue.bind(adapt)
|
this.getControlValue = adapt.getControlValue.bind(adapt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import { DeepRequired } from '../../interface/Common'
|
|||||||
import {
|
import {
|
||||||
IGetControlValueOption,
|
IGetControlValueOption,
|
||||||
IGetControlValueResult,
|
IGetControlValueResult,
|
||||||
|
ISetControlExtensionOption,
|
||||||
ISetControlValueOption
|
ISetControlValueOption
|
||||||
} from '../../interface/Control'
|
} from '../../interface/Control'
|
||||||
import {
|
import {
|
||||||
@@ -2083,6 +2084,12 @@ export class CommandAdapt {
|
|||||||
this.draw.getControl().setValueByConceptId(payload)
|
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 {
|
public getContainer(): HTMLDivElement {
|
||||||
return this.draw.getContainer()
|
return this.draw.getContainer()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import {
|
|||||||
IControlOption,
|
IControlOption,
|
||||||
IGetControlValueOption,
|
IGetControlValueOption,
|
||||||
IGetControlValueResult,
|
IGetControlValueResult,
|
||||||
|
ISetControlExtensionOption,
|
||||||
ISetControlValueOption
|
ISetControlValueOption
|
||||||
} from '../../../interface/Control'
|
} from '../../../interface/Control'
|
||||||
import { IEditorData } from '../../../interface/Editor'
|
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
|
conceptId: string
|
||||||
value: string
|
value: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ISetControlExtensionOption {
|
||||||
|
conceptId: string
|
||||||
|
extension: unknown
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user