mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 09:29:16 +00:00
fix: field loss enum (#667)
This commit is contained in:
parent
73d4b15040
commit
9f7f482aa4
@ -1,11 +1,11 @@
|
||||
import { Field } from '@formily/core';
|
||||
import { connect, useField, useFieldSchema } from '@formily/react';
|
||||
import { merge } from '@formily/shared';
|
||||
import { concat } from 'lodash';
|
||||
import React, { useEffect } from 'react';
|
||||
import { useCompile, useComponent, useFormBlockContext } from '..';
|
||||
import { CollectionFieldProvider } from './CollectionFieldProvider';
|
||||
import { useCollectionField } from './hooks';
|
||||
import { concat } from 'lodash';
|
||||
|
||||
// TODO: 初步适配
|
||||
const InternalField: React.FC = (props) => {
|
||||
@ -40,7 +40,7 @@ const InternalField: React.FC = (props) => {
|
||||
setFieldProps('description', uiSchema.description);
|
||||
setFieldProps('initialValue', uiSchema.default);
|
||||
if (!field.validator && (uiSchema['x-validator'] || fieldSchema['x-validator'])) {
|
||||
const concatSchema = concat([], uiSchema['x-validator'] || [], fieldSchema['x-validator'] || [])
|
||||
const concatSchema = concat([], uiSchema['x-validator'] || [], fieldSchema['x-validator'] || []);
|
||||
field.validator = concatSchema;
|
||||
}
|
||||
if (fieldSchema['x-disabled'] === true) {
|
||||
@ -69,7 +69,7 @@ const InternalField: React.FC = (props) => {
|
||||
if (!uiSchema) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
return React.createElement(component, props, props.children);
|
||||
};
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { Field } from '@formily/core';
|
||||
import { connect, useField, useFieldSchema } from '@formily/react';
|
||||
import { merge } from '@formily/shared';
|
||||
import { Cascader, Select, Space } from 'antd';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
@ -18,7 +19,6 @@ const DYNAMIC_TIME_REG = /\{\{\s*currentTime\s*\}\}/;
|
||||
|
||||
const InternalField: React.FC = (props) => {
|
||||
const field = useField<Field>();
|
||||
|
||||
const fieldSchema = useFieldSchema();
|
||||
const { name, interface: interfaceType, uiSchema } = useCollectionField();
|
||||
const component = useComponent(uiSchema?.['x-component']);
|
||||
@ -59,9 +59,10 @@ const InternalField: React.FC = (props) => {
|
||||
}
|
||||
setRequired();
|
||||
// @ts-ignore
|
||||
// field.dataSource = uiSchema.enum;
|
||||
// const originalProps = compile(uiSchema['x-component-props']) || {};
|
||||
// const componentProps = merge(originalProps, field.componentProps || {});
|
||||
field.dataSource = uiSchema.enum;
|
||||
const originalProps = compile(uiSchema['x-component-props']) || {};
|
||||
const componentProps = merge(originalProps, field.componentProps || {});
|
||||
field.componentProps = componentProps;
|
||||
// field.component = [component, componentProps];
|
||||
}, [JSON.stringify(uiSchema)]);
|
||||
if (!uiSchema) {
|
||||
|
Loading…
Reference in New Issue
Block a user