chore: 调整表单项默认值变更逻辑支持值格式是数组的情况

This commit is contained in:
2betop 2024-06-24 17:39:10 +08:00 committed by lmaomaoz
parent a76e8a7b6d
commit d4c540e121
2 changed files with 16 additions and 11 deletions

View File

@ -128,11 +128,23 @@ export function makeWrapper(
}
@autobind
wrapperRef(ref: any) {
wrapperRef(raw: any) {
let ref = raw;
while (ref?.getWrappedInstance) {
ref = ref.getWrappedInstance();
}
if (ref && !ref.props) {
Object.defineProperty(ref, 'props', {
get: () => this.props
});
} else if (!ref && raw) {
ref = {};
Object.defineProperty(ref, 'props', {
get: () => this.props
});
}
if (this.editorNode && isAlive(this.editorNode)) {
this.editorNode.setComponent(ref);

View File

@ -222,18 +222,11 @@ export class ItemPlugin extends BasePlugin {
context.info.renderer.isFormItem &&
context.diff?.some(change => change.path?.join('.') === 'value')
) {
const change: any = find(
context.diff,
change => change.path?.join('.') === 'value'
)!;
const component = this.manager.store
.getNodeById(context.id)
?.getComponent();
let value = change?.rhs;
let value = context.value.value;
const component = context.node?.getComponent();
if (typeof value === 'string' && isExpression(value)) {
const data = event.context.node?.getComponent()?.props.data || {};
const data = component?.props.data || {};
value = resolveVariableAndFilter(value, data, '| raw');
}
component?.props.onChange(value);