group |
title |
path |
order |
字段组件 |
/zh-CN/components/collection-fields |
3 |
|
Attachment - 附件
Interface
export const attachment: FieldOptions = {
name: 'attachment',
type: 'object',
group: 'media',
title: '附件',
isAssociation: true,
default: {
dataType: 'belongsToMany',
target: 'attachments',
// name,
uiSchema: {
type: 'array',
// title,
'x-component': 'Upload.Attachment',
'x-decorator': 'FormItem',
'x-designable-bar': 'Upload.DesignableBar',
},
},
initialize: (values: any) => {
if (!values.through) {
values.through = `t_${uid()}`;
}
if (!values.foreignKey) {
values.foreignKey = `f_${uid()}`;
}
if (!values.otherKey) {
values.otherKey = `f_${uid()}`;
}
if (!values.sourceKey) {
values.sourceKey = 'id';
}
if (!values.targetKey) {
values.targetKey = 'id';
}
},
properties: {
...defaultProps,
'uiSchema.x-component-props.multiple': {
type: 'boolean',
'x-content': '允许上传多个文件',
'x-decorator': 'FormItem',
'x-component': 'Checkbox',
default: true,
},
},
};