feat: sub-form suport nest

This commit is contained in:
katherinehhh 2023-04-27 11:39:27 +08:00
parent 49c3dab9a8
commit 2d64123b2a
2 changed files with 47 additions and 29 deletions

View File

@ -103,38 +103,55 @@ export const o2m: IField = {
const association = `${field.collectionName}.${field.name}`;
schema.type = 'void';
schema.properties = {
block: {
type: 'void',
'x-decorator': 'SubFormProvider',
'x-decorator-props': {
collection: field.target,
association: association,
resource: association,
action: action,
fieldName: field.name,
readPretty,
},
'x-component': 'CardItem',
'x-component-props': {
bordered: true,
},
properties: {
[field.name]: {
type: 'object',
'x-component': 'FormV2',
'x-component-props': {
useProps: '{{ useSubFormProps }}',
},
properties: {
__form_grid: {
type: 'void',
'x-component': 'Grid',
'x-initializer': 'FormItemInitializers',
properties: {},
array: {
type: 'array',
'x-component': 'ArrayCards',
default:[{}],
items: {
type: 'object',
properties: {
block: {
type: 'void',
'x-decorator': 'SubFormProvider',
'x-decorator-props': {
collection: field.target,
association: association,
resource: association,
action: action,
fieldName: field.name,
readPretty,
},
'x-component': 'CardItem',
'x-component-props': {
bordered: true,
},
properties: {
[field.name]: {
type: 'object',
'x-component': 'FormV2',
'x-component-props': {
useProps: '{{ useSubFormProps }}',
},
properties: {
__form_grid: {
type: 'void',
'x-component': 'Grid',
'x-initializer': 'FormItemInitializers',
properties: {},
},
},
},
},
},
},
},
properties: {
addition: {
type: 'void',
title: 'Add new',
'x-component': 'ArrayCards.Addition',
},
},
},
};
} else if (schema['x-component'] === 'AssociationSelect') {

View File

@ -40,5 +40,6 @@ export * from './time-picker';
export * from './tree-select';
export * from './upload';
export * from './variable';
export * from './gantt'
export * from './gantt';
export { ArrayCards } from '@formily/antd';
import './index.less';