fix: avoid error

This commit is contained in:
Rairn 2023-05-16 19:51:07 +08:00
parent 0eb1c31514
commit 8ba90b126f
2 changed files with 10 additions and 10 deletions

View File

@ -14,6 +14,7 @@ import {
useSortFields, useSortFields,
} from '../../../collection-manager'; } from '../../../collection-manager';
import { isTitleField } from '../../../collection-manager/Configuration/CollectionFields'; import { isTitleField } from '../../../collection-manager/Configuration/CollectionFields';
import { GeneralSchemaItems } from '../../../schema-items';
import { GeneralSchemaDesigner, SchemaSettings, isPatternDisabled, isShowDefaultValue } from '../../../schema-settings'; import { GeneralSchemaDesigner, SchemaSettings, isPatternDisabled, isShowDefaultValue } from '../../../schema-settings';
import { useIsShowMultipleSwitch } from '../../../schema-settings/hooks/useIsShowMultipleSwitch'; import { useIsShowMultipleSwitch } from '../../../schema-settings/hooks/useIsShowMultipleSwitch';
import { useCompile, useDesignable, useFieldComponentOptions, useFieldTitle } from '../../hooks'; import { useCompile, useDesignable, useFieldComponentOptions, useFieldTitle } from '../../hooks';
@ -23,7 +24,6 @@ import { defaultFieldNames } from '../select';
import { FilterDynamicComponent } from '../table-v2/FilterDynamicComponent'; import { FilterDynamicComponent } from '../table-v2/FilterDynamicComponent';
import { ReadPretty } from './ReadPretty'; import { ReadPretty } from './ReadPretty';
import useServiceOptions from './useServiceOptions'; import useServiceOptions from './useServiceOptions';
import { GeneralSchemaItems } from '../../../schema-items';
export type AssociationSelectProps<P = any> = RemoteSelectProps<P> & { export type AssociationSelectProps<P = any> = RemoteSelectProps<P> & {
action?: string; action?: string;
@ -112,7 +112,7 @@ AssociationSelect.Designer = function Designer() {
const interfaceConfig = getInterface(collectionField?.interface); const interfaceConfig = getInterface(collectionField?.interface);
const validateSchema = interfaceConfig?.['validateSchema']?.(fieldSchema); const validateSchema = interfaceConfig?.['validateSchema']?.(fieldSchema);
const originalTitle = collectionField?.uiSchema?.title; const originalTitle = collectionField?.uiSchema?.title;
const targetFields = collectionField?.target ? getCollectionFields(collectionField.target) : []; const targetFields = collectionField?.target ? getCollectionFields(collectionField?.target) : [];
const initialValue = { const initialValue = {
title: field.title === originalTitle ? undefined : field.title, title: field.title === originalTitle ? undefined : field.title,
}; };
@ -310,7 +310,7 @@ AssociationSelect.Designer = function Designer() {
}, },
name: 'default', name: 'default',
title: t('Default value'), title: t('Default value'),
default: fieldSchema.default || collectionField.defaultValue, default: fieldSchema.default || collectionField?.defaultValue,
'x-read-pretty': false, 'x-read-pretty': false,
'x-disabled': false, 'x-disabled': false,
}, },
@ -340,7 +340,7 @@ AssociationSelect.Designer = function Designer() {
value={fieldSchema['x-component']} value={fieldSchema['x-component']}
onChange={(type) => { onChange={(type) => {
const schema: ISchema = { const schema: ISchema = {
name: collectionField.name, name: collectionField?.name,
type: 'void', type: 'void',
required: fieldSchema['required'], required: fieldSchema['required'],
description: fieldSchema['description'], description: fieldSchema['description'],
@ -362,7 +362,7 @@ AssociationSelect.Designer = function Designer() {
block: 'Form', block: 'Form',
readPretty: field.readPretty, readPretty: field.readPretty,
action: tk ? 'get' : null, action: tk ? 'get' : null,
targetCollection: getCollection(collectionField.target), targetCollection: getCollection(collectionField?.target),
}); });
if (type === 'CollectionField') { if (type === 'CollectionField') {
@ -637,7 +637,7 @@ AssociationSelect.FilterDesigner = function FilterDesigner() {
const interfaceConfig = getInterface(collectionField?.interface); const interfaceConfig = getInterface(collectionField?.interface);
const validateSchema = interfaceConfig?.['validateSchema']?.(fieldSchema); const validateSchema = interfaceConfig?.['validateSchema']?.(fieldSchema);
const originalTitle = collectionField?.uiSchema?.title; const originalTitle = collectionField?.uiSchema?.title;
const targetFields = collectionField?.target ? getCollectionFields(collectionField.target) : []; const targetFields = collectionField?.target ? getCollectionFields(collectionField?.target) : [];
const initialValue = { const initialValue = {
title: field.title === originalTitle ? undefined : field.title, title: field.title === originalTitle ? undefined : field.title,
}; };
@ -812,11 +812,11 @@ AssociationSelect.FilterDesigner = function FilterDesigner() {
title: t('Set default value'), title: t('Set default value'),
properties: { properties: {
default: { default: {
...collectionField.uiSchema, ...collectionField?.uiSchema,
name: 'default', name: 'default',
title: t('Default value'), title: t('Default value'),
'x-decorator': 'FormItem', 'x-decorator': 'FormItem',
default: fieldSchema.default || collectionField.defaultValue, default: fieldSchema.default || collectionField?.defaultValue,
}, },
}, },
} as ISchema } as ISchema

View File

@ -357,7 +357,7 @@ FormItem.Designer = function Designer() {
'x-component-props': { 'x-component-props': {
...fieldSchema['x-component-props'], ...fieldSchema['x-component-props'],
component: component:
collectionField?.target && collectionField.interface !== 'chinaRegion' collectionField?.target && collectionField?.interface !== 'chinaRegion'
? 'AssociationSelect' ? 'AssociationSelect'
: undefined, : undefined,
service: { service: {
@ -572,7 +572,7 @@ FormItem.Designer = function Designer() {
field.componentProps = field.componentProps || {}; field.componentProps = field.componentProps || {};
field.componentProps.mode = mode; field.componentProps.mode = mode;
if (mode === 'Nester') { if (mode === 'Nester') {
const initValue = ['o2m', 'm2m'].includes(collectionField.interface) ? [] : {}; const initValue = ['o2m', 'm2m'].includes(collectionField?.interface) ? [] : {};
field.value = field.value || initValue; field.value = field.value || initValue;
} }
dn.emit('patch', { dn.emit('patch', {