fix: use AssignedField

This commit is contained in:
chenos 2023-05-13 10:51:32 +08:00
parent 901c05bc35
commit 3a8db04161
2 changed files with 4 additions and 4 deletions

View File

@ -1,15 +1,15 @@
import React from 'react'; import React from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useCompile } from '../../schema-component';
import { SchemaInitializer } from '../SchemaInitializer'; import { SchemaInitializer } from '../SchemaInitializer';
import { gridRowColWrap, useCustomFormItemInitializerFields, useInheritsFormItemInitializerFields } from '../utils'; import { gridRowColWrap, useCustomFormItemInitializerFields, useInheritsFormItemInitializerFields } from '../utils';
import { useCompile } from '../../schema-component';
// 表单里配置字段 // 表单里配置字段
export const CustomFormItemInitializers = (props: any) => { export const CustomFormItemInitializers = (props: any) => {
const { t } = useTranslation(); const { t } = useTranslation();
const compile = useCompile(); const compile = useCompile();
const { insertPosition, component } = props; const { insertPosition, component } = props;
const inheritFields = useInheritsFormItemInitializerFields(); const inheritFields = useInheritsFormItemInitializerFields({ component: 'AssignedField' });
const fieldItems: any[] = [ const fieldItems: any[] = [
{ {
type: 'itemGroup', type: 'itemGroup',

View File

@ -456,7 +456,7 @@ export const useInheritsFormItemInitializerFields = (options?) => {
return inherits?.map((v) => { return inherits?.map((v) => {
const fields = getParentCollectionFields(v, name); const fields = getParentCollectionFields(v, name);
const { readPretty = form.readPretty, block = 'Form' } = options || {}; const { readPretty = form.readPretty, block = 'Form', component = 'CollectionField' } = options || {};
const targetCollection = getCollection(v); const targetCollection = getCollection(v);
return { return {
[targetCollection?.title]: fields [targetCollection?.title]: fields
@ -473,7 +473,7 @@ export const useInheritsFormItemInitializerFields = (options?) => {
name: field.name, name: field.name,
title: field?.uiSchema?.title || field.name, title: field?.uiSchema?.title || field.name,
'x-designer': 'FormItem.Designer', 'x-designer': 'FormItem.Designer',
'x-component': 'CollectionField', 'x-component': component,
'x-decorator': 'FormItem', 'x-decorator': 'FormItem',
'x-collection-field': `${name}.${field.name}`, 'x-collection-field': `${name}.${field.name}`,
'x-component-props': {}, 'x-component-props': {},