feat: add executeSetControlProperties api #391
This commit is contained in:
@@ -892,6 +892,16 @@ Usage:
|
|||||||
instance.command.executeSetControlExtension(payload: ISetControlExtensionOption)
|
instance.command.executeSetControlExtension(payload: ISetControlExtensionOption)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## executeSetControlProperties
|
||||||
|
|
||||||
|
Feature: Set control properties
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
instance.command.executeSetControlProperties(payload: ISetControlProperties)
|
||||||
|
```
|
||||||
|
|
||||||
## executeSetControlHighlight
|
## executeSetControlHighlight
|
||||||
|
|
||||||
Feature: Set control highlight (by keyword)
|
Feature: Set control highlight (by keyword)
|
||||||
|
|||||||
@@ -892,6 +892,16 @@ instance.command.executeSetControlValue(payload: ISetControlValueOption)
|
|||||||
instance.command.executeSetControlExtension(payload: ISetControlExtensionOption)
|
instance.command.executeSetControlExtension(payload: ISetControlExtensionOption)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## executeSetControlProperties
|
||||||
|
|
||||||
|
功能:设置控件属性
|
||||||
|
|
||||||
|
用法:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
instance.command.executeSetControlProperties(payload: ISetControlProperties)
|
||||||
|
```
|
||||||
|
|
||||||
## executeSetControlHighlight
|
## executeSetControlHighlight
|
||||||
|
|
||||||
功能:设置控件高亮(根据关键词)
|
功能:设置控件高亮(根据关键词)
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ export class Command {
|
|||||||
public executeSetZone: CommandAdapt['setZone']
|
public executeSetZone: CommandAdapt['setZone']
|
||||||
public executeSetControlValue: CommandAdapt['setControlValue']
|
public executeSetControlValue: CommandAdapt['setControlValue']
|
||||||
public executeSetControlExtension: CommandAdapt['setControlExtension']
|
public executeSetControlExtension: CommandAdapt['setControlExtension']
|
||||||
|
public executeSetControlProperties: CommandAdapt['setControlProperties']
|
||||||
public executeSetControlHighlight: CommandAdapt['setControlHighlight']
|
public executeSetControlHighlight: CommandAdapt['setControlHighlight']
|
||||||
public getCatalog: CommandAdapt['getCatalog']
|
public getCatalog: CommandAdapt['getCatalog']
|
||||||
public getImage: CommandAdapt['getImage']
|
public getImage: CommandAdapt['getImage']
|
||||||
@@ -222,6 +223,7 @@ export class Command {
|
|||||||
// 控件
|
// 控件
|
||||||
this.executeSetControlValue = adapt.setControlValue.bind(adapt)
|
this.executeSetControlValue = adapt.setControlValue.bind(adapt)
|
||||||
this.executeSetControlExtension = adapt.setControlExtension.bind(adapt)
|
this.executeSetControlExtension = adapt.setControlExtension.bind(adapt)
|
||||||
|
this.executeSetControlProperties = adapt.setControlProperties.bind(adapt)
|
||||||
this.executeSetControlHighlight = adapt.setControlHighlight.bind(adapt)
|
this.executeSetControlHighlight = adapt.setControlHighlight.bind(adapt)
|
||||||
this.getControlValue = adapt.getControlValue.bind(adapt)
|
this.getControlValue = adapt.getControlValue.bind(adapt)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import {
|
|||||||
IGetControlValueResult,
|
IGetControlValueResult,
|
||||||
ISetControlExtensionOption,
|
ISetControlExtensionOption,
|
||||||
ISetControlHighlightOption,
|
ISetControlHighlightOption,
|
||||||
|
ISetControlProperties,
|
||||||
ISetControlValueOption
|
ISetControlValueOption
|
||||||
} from '../../interface/Control'
|
} from '../../interface/Control'
|
||||||
import {
|
import {
|
||||||
@@ -2288,6 +2289,12 @@ export class CommandAdapt {
|
|||||||
this.draw.getControl().setExtensionByConceptId(payload)
|
this.draw.getControl().setExtensionByConceptId(payload)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public setControlProperties(payload: ISetControlProperties) {
|
||||||
|
const isReadonly = this.draw.isReadonly()
|
||||||
|
if (isReadonly) return
|
||||||
|
this.draw.getControl().setPropertiesByConceptId(payload)
|
||||||
|
}
|
||||||
|
|
||||||
public setControlHighlight(payload: ISetControlHighlightOption) {
|
public setControlHighlight(payload: ISetControlHighlightOption) {
|
||||||
this.draw.getControl().setHighlightList(payload)
|
this.draw.getControl().setHighlightList(payload)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,9 +13,10 @@ import {
|
|||||||
IGetControlValueOption,
|
IGetControlValueOption,
|
||||||
IGetControlValueResult,
|
IGetControlValueResult,
|
||||||
ISetControlExtensionOption,
|
ISetControlExtensionOption,
|
||||||
|
ISetControlProperties,
|
||||||
ISetControlValueOption
|
ISetControlValueOption
|
||||||
} from '../../../interface/Control'
|
} from '../../../interface/Control'
|
||||||
import { IEditorOption } from '../../../interface/Editor'
|
import { IEditorData, IEditorOption } from '../../../interface/Editor'
|
||||||
import { IElement, IElementPosition } from '../../../interface/Element'
|
import { IElement, IElementPosition } from '../../../interface/Element'
|
||||||
import { EventBusMap } from '../../../interface/EventBus'
|
import { EventBusMap } from '../../../interface/EventBus'
|
||||||
import { IRange } from '../../../interface/Range'
|
import { IRange } from '../../../interface/Range'
|
||||||
@@ -702,4 +703,53 @@ export class Control {
|
|||||||
setExtension(elementList)
|
setExtension(elementList)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public setPropertiesByConceptId(payload: ISetControlProperties) {
|
||||||
|
const isReadonly = this.draw.isReadonly()
|
||||||
|
if (isReadonly) return
|
||||||
|
const { conceptId, properties } = payload
|
||||||
|
let isExistUpdate = false
|
||||||
|
const pageComponentData: IEditorData = {
|
||||||
|
header: this.draw.getHeaderElementList(),
|
||||||
|
main: this.draw.getOriginalMainElementList(),
|
||||||
|
footer: this.draw.getFooterElementList()
|
||||||
|
}
|
||||||
|
for (const key in pageComponentData) {
|
||||||
|
const elementList = pageComponentData[<keyof IEditorData>key]!
|
||||||
|
let i = 0
|
||||||
|
while (i < elementList.length) {
|
||||||
|
const element = elementList[i]
|
||||||
|
i++
|
||||||
|
if (element?.control?.conceptId !== conceptId) continue
|
||||||
|
isExistUpdate = true
|
||||||
|
element.control = {
|
||||||
|
...element.control,
|
||||||
|
...properties,
|
||||||
|
value: element.control.value
|
||||||
|
}
|
||||||
|
// 修改后控件结束索引
|
||||||
|
let newEndIndex = i
|
||||||
|
while (newEndIndex < elementList.length) {
|
||||||
|
const nextElement = elementList[newEndIndex]
|
||||||
|
if (nextElement.controlId !== element.controlId) break
|
||||||
|
newEndIndex++
|
||||||
|
}
|
||||||
|
i = newEndIndex
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!isExistUpdate) return
|
||||||
|
// 强制更新
|
||||||
|
for (const key in pageComponentData) {
|
||||||
|
const pageComponentKey = <keyof IEditorData>key
|
||||||
|
const elementList = zipElementList(pageComponentData[pageComponentKey]!)
|
||||||
|
pageComponentData[pageComponentKey] = elementList
|
||||||
|
formatElementList(elementList, {
|
||||||
|
editorOptions: this.options
|
||||||
|
})
|
||||||
|
}
|
||||||
|
this.draw.setEditorData(pageComponentData)
|
||||||
|
this.draw.render({
|
||||||
|
isSetCursor: false
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,3 +121,8 @@ export interface ISetControlExtensionOption {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export type ISetControlHighlightOption = IControlHighlight[]
|
export type ISetControlHighlightOption = IControlHighlight[]
|
||||||
|
|
||||||
|
export type ISetControlProperties = {
|
||||||
|
conceptId: string
|
||||||
|
properties: Partial<Omit<IControl, 'value'>>
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user