mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2026-05-09 18:18:08 +00:00
feat(editor): props 服务新增配置/值的批量获取与存在性判断方法
新增 getPropsConfigs、hasPropsConfig、getPropsValues、hasPropsValue 方法,便于外部按类型查询表单配置与初始值。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
a1f71f02d1
commit
d8133629b4
@ -93,6 +93,10 @@ class Props extends BaseService {
|
||||
this.emit('props-configs-change');
|
||||
}
|
||||
|
||||
public getPropsConfigs(): Record<string, FormConfig> {
|
||||
return this.state.propsConfigMap;
|
||||
}
|
||||
|
||||
public async fillConfig(config: FormConfig, labelWidth?: string) {
|
||||
return fillConfig(config, {
|
||||
labelWidth: typeof labelWidth !== 'function' ? labelWidth : '80px',
|
||||
@ -125,12 +129,20 @@ class Props extends BaseService {
|
||||
return cloneDeep(this.state.propsConfigMap[toLine(type)] || (await this.fillConfig([])));
|
||||
}
|
||||
|
||||
public hasPropsConfig(type: string): boolean {
|
||||
return !!this.state.propsConfigMap[toLine(type)];
|
||||
}
|
||||
|
||||
public setPropsValues(values: Record<string, Partial<MNode> | PropsFormValueFunction>) {
|
||||
Object.keys(values).forEach((type: string) => {
|
||||
this.setPropsValue(toLine(type), values[type]);
|
||||
});
|
||||
}
|
||||
|
||||
public getPropsValues(): Record<string, Partial<MNode>> {
|
||||
return this.state.propsValueMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 为指点类型组件设置组件初始值
|
||||
* @param type 组件类型
|
||||
@ -178,6 +190,10 @@ class Props extends BaseService {
|
||||
};
|
||||
}
|
||||
|
||||
public hasPropsValue(type: string): boolean {
|
||||
return !!this.state.propsValueMap[toLine(type)];
|
||||
}
|
||||
|
||||
public createId(type: string | number): string {
|
||||
return `${type}_${guid()}`;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user