controls 可能是对象的问题处理 (#2221)

This commit is contained in:
liaoxuezhi 2021-07-05 18:53:49 +08:00 committed by GitHub
parent 7e55499d39
commit a46b37588d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -444,16 +444,19 @@ addSchemaFilter(function (schema: Schema, renderer: any, props: any) {
}; };
} }
if (Array.isArray(schema?.controls) && schema.type !== 'audio') { if (schema?.controls && schema.type !== 'audio') {
schema = { schema = {
...schema, ...schema,
[schema.type === 'combo' ? `items` : 'body']: schema?.controls.map( [schema.type === 'combo' ? `items` : 'body']: (Array.isArray(
controlToNormalRenderer schema.controls
) )
? schema.controls
: [schema.controls]
).map(controlToNormalRenderer)
}; };
delete schema.controls; delete schema.controls;
} else if ( } else if (
Array.isArray(schema?.quickEdit?.controls) && schema?.quickEdit?.controls &&
(!schema.quickEdit.type || (!schema.quickEdit.type ||
!~['combo', 'group', 'panel', 'fieldSet', 'fieldset'].indexOf( !~['combo', 'group', 'panel', 'fieldSet', 'fieldset'].indexOf(
schema.quickEdit.type schema.quickEdit.type
@ -463,7 +466,10 @@ addSchemaFilter(function (schema: Schema, renderer: any, props: any) {
...schema, ...schema,
quickEdit: { quickEdit: {
...schema.quickEdit, ...schema.quickEdit,
body: schema.quickEdit.controls.map(controlToNormalRenderer) body: (Array.isArray(schema.quickEdit.controls)
? schema.quickEdit.controls
: [schema.quickEdit.controls]
).map(controlToNormalRenderer)
} }
}; };
delete schema.quickEdit.controls; delete schema.quickEdit.controls;
@ -535,13 +541,13 @@ addSchemaFilter(function (schema: Schema, renderer: any, props: any) {
return column; return column;
}) })
}; };
} else if ( } else if (schema?.type === 'service' && schema?.body?.controls) {
schema?.type === 'service' &&
Array.isArray(schema?.body?.controls)
) {
schema = { schema = {
...schema, ...schema,
body: schema.body.controls.map(controlToNormalRenderer) body: (Array.isArray(schema.body.controls)
? schema.body.controls
: [schema.body.controls]
).map(controlToNormalRenderer)
}; };
} }