diff --git a/packages/plugins/@hera/plugin-core/src/client/index.tsx b/packages/plugins/@hera/plugin-core/src/client/index.tsx index 06ef60820..541cc033a 100644 --- a/packages/plugins/@hera/plugin-core/src/client/index.tsx +++ b/packages/plugins/@hera/plugin-core/src/client/index.tsx @@ -1,5 +1,12 @@ import React from 'react'; -import { Menu, Plugin, RemoteSchemaTemplateManagerProvider, EditTitleField, useCollection } from '@nocobase/client'; +import { + Menu, + Plugin, + RemoteSchemaTemplateManagerProvider, + EditTitleField, + useCollection, + SchemaSettingsDateFormat, +} from '@nocobase/client'; import { remove } from 'lodash'; import { useFieldSchema } from '@formily/react'; import { isValid } from '@formily/shared'; @@ -65,6 +72,7 @@ import { sheetBlockSettings, } from './schema-initializer/blocks/SheetBlockInitializer'; import AssociationCascader from './schema-components/association-cascader/AssociationCascader'; +import { SchemaSettingsDatePickerType } from './schema-settings/SchemaSettingsDatePickerType'; export { usePDFViewerRef } from './schema-initializer'; export * from './components/custom-components/custom-components'; @@ -89,6 +97,10 @@ export class PluginCoreClient extends Plugin { Component: EditDefaultValue, }); + this.schemaSettingsManager.addItem('fieldSettings:component:DatePicker', 'datePickerType', { + Component: SchemaSettingsDatePickerType, + }); + this.schemaSettingsManager.addItem('FormItemSettings', 'hera-divider', { type: 'divider', useVisible() { diff --git a/packages/plugins/@hera/plugin-core/src/client/schema-settings/SchemaSettingsDatePickerType.tsx b/packages/plugins/@hera/plugin-core/src/client/schema-settings/SchemaSettingsDatePickerType.tsx new file mode 100644 index 000000000..6dcce8505 --- /dev/null +++ b/packages/plugins/@hera/plugin-core/src/client/schema-settings/SchemaSettingsDatePickerType.tsx @@ -0,0 +1,84 @@ +import React from 'react'; +import { ISchema, useField, useFieldSchema } from '@formily/react'; +import { SchemaSettingsModalItem, useCollectionManager, useDesignable } from '@nocobase/client'; +import { tval, useTranslation } from '../locale'; + +export const SchemaSettingsDatePickerType: React.FC = () => { + const fieldSchema = useFieldSchema(); + const field = useField(); + const { dn } = useDesignable(); + const { t } = useTranslation(); + const cm = useCollectionManager(); + const collectionField = cm.getCollectionField(fieldSchema?.['x-collection-field']) || {}; + const defaultPicker = + fieldSchema?.['x-component-props']?.picker || collectionField?.uiSchema?.['x-component-props']?.picker || ''; + return ( + { + const schema = { + ['x-uid']: fieldSchema['x-uid'], + }; + schema['x-component-props'] = fieldSchema['x-component-props'] || {}; + fieldSchema['x-component-props'] = { + ...(fieldSchema['x-component-props'] || {}), + ...data, + }; + schema['x-component-props'] = fieldSchema['x-component-props']; + field.componentProps = fieldSchema['x-component-props']; + //子表格/表格区块 + const parts = (field.path.entire as string).split('.'); + parts.pop(); + const modifiedString = parts.join('.'); + field.query(`${modifiedString}.*[0:].${fieldSchema.name}`).forEach((f) => { + if (f.props.name === fieldSchema.name) { + f.setComponentProps({ ...data }); + } + }); + dn.emit('patch', { + schema, + }); + dn.refresh(); + }} + /> + ); +}; + +SchemaSettingsDatePickerType.displayName = 'SchemaSettingsDatePickerType';