From 54f993f327f420ee8718bcd9ae92eba8cf44736e Mon Sep 17 00:00:00 2001 From: Neal <543741870@qq.com> Date: Sat, 23 Jul 2022 18:19:07 +0800 Subject: [PATCH] fix: Fix calendar change field error (#626) (#671) * fix: calendar change field throw error * fix: calendar change field throw error * fix: calendar change field throw error * Update Calendar.Designer.tsx Co-authored-by: up_young Co-authored-by: yangpeng Co-authored-by: chenos --- .../antd/calendar/Calendar.Designer.tsx | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/packages/core/client/src/schema-component/antd/calendar/Calendar.Designer.tsx b/packages/core/client/src/schema-component/antd/calendar/Calendar.Designer.tsx index 4d3d5c74d..4247e6032 100644 --- a/packages/core/client/src/schema-component/antd/calendar/Calendar.Designer.tsx +++ b/packages/core/client/src/schema-component/antd/calendar/Calendar.Designer.tsx @@ -8,10 +8,12 @@ import { useCollectionFilterOptions } from '../../../collection-manager/action-h import { GeneralSchemaDesigner, SchemaSettings } from '../../../schema-settings'; import { useSchemaTemplate } from '../../../schema-templates'; -const useOptions = () => { +const useOptions = (type = 'string') => { const compile = useCompile(); const { fields } = useCollection(); - const options = fields?.map((field) => { + const options = fields + ?.filter((field) => field.type === type) + ?.map((field) => { return { value: field.name, label: compile(field?.uiSchema?.title), @@ -31,7 +33,6 @@ export const CalendarDesigner = () => { const { t } = useTranslation(); const template = useSchemaTemplate(); const defaultFilter = fieldSchema?.['x-decorator-props']?.params?.filter || {}; - const options = useOptions(); const fieldNames = fieldSchema?.['x-decorator-props']?.['fieldNames'] || {}; const defaultResource = fieldSchema?.['x-decorator-props']?.resource; return ( @@ -40,12 +41,14 @@ export const CalendarDesigner = () => { { const fieldNames = field.decoratorProps.fieldNames || {}; fieldNames['title'] = title; field.decoratorProps.params = fieldNames; fieldSchema['x-decorator-props']['params'] = fieldNames; + // Select切换option后value未按照预期切换,固增加以下代码 + fieldSchema['x-decorator-props']['fieldNames'] = fieldNames; service.refresh(); dn.emit('patch', { schema: { @@ -59,12 +62,12 @@ export const CalendarDesigner = () => { { const fieldNames = field.decoratorProps.fieldNames || {}; fieldNames['start'] = start; - field.decoratorProps.params = fieldNames; - fieldSchema['x-decorator-props']['params'] = fieldNames; + field.decoratorProps.fieldNames = fieldNames; + fieldSchema['x-decorator-props']['fieldNames'] = fieldNames; service.refresh(); dn.emit('patch', { schema: { @@ -78,12 +81,12 @@ export const CalendarDesigner = () => { { const fieldNames = field.decoratorProps.fieldNames || {}; fieldNames['end'] = end; - field.decoratorProps.params = fieldNames; - fieldSchema['x-decorator-props']['params'] = fieldNames; + field.decoratorProps.fieldNames = fieldNames; + fieldSchema['x-decorator-props']['fieldNames'] = fieldNames; service.refresh(); dn.emit('patch', { schema: {