diff --git a/packages/core/client/src/collection-manager/Configuration/EditFieldAction.tsx b/packages/core/client/src/collection-manager/Configuration/EditFieldAction.tsx index 9f9da6498a..4c6fb4fedd 100644 --- a/packages/core/client/src/collection-manager/Configuration/EditFieldAction.tsx +++ b/packages/core/client/src/collection-manager/Configuration/EditFieldAction.tsx @@ -175,12 +175,13 @@ export const EditFieldAction = (props) => { const compile = useCompile(); const [data, setData] = useState({}); const { isDialect } = useDialect(); + const scopeKeyOptions = useMemo(() => { return ( record?.fields || getCollection(record.collectionName) .options.fields.filter((v) => { - return v.interface === 'select'; + return ['string', 'bigInt', 'integer'].includes(v.type); }) .map((k) => { return { diff --git a/packages/core/client/src/collection-manager/interfaces/sort.ts b/packages/core/client/src/collection-manager/interfaces/sort.ts index cac751488c..dca4567e62 100644 --- a/packages/core/client/src/collection-manager/interfaces/sort.ts +++ b/packages/core/client/src/collection-manager/interfaces/sort.ts @@ -22,7 +22,7 @@ export class SortFieldInterface extends CollectionFieldInterface { 'x-validator': 'integer', }, }; - availableTypes = ['bigInt', 'integer', 'sort']; + availableTypes = ['sort']; hasDefaultValue = false; properties = { ...defaultProps, diff --git a/packages/plugins/@nocobase/plugin-data-source-manager/src/client/component/CollectionsManager/EditFieldAction.tsx b/packages/plugins/@nocobase/plugin-data-source-manager/src/client/component/CollectionsManager/EditFieldAction.tsx index 00be79b6ca..b461b29e2c 100644 --- a/packages/plugins/@nocobase/plugin-data-source-manager/src/client/component/CollectionsManager/EditFieldAction.tsx +++ b/packages/plugins/@nocobase/plugin-data-source-manager/src/client/component/CollectionsManager/EditFieldAction.tsx @@ -191,6 +191,7 @@ const EditFieldAction = (props) => { const compile = useCompile(); const { name } = useParams(); const isDialect = (dialect: string) => currentDatabase?.dialect === dialect; + const fields = record?.fields || getCollection(record.collectionName, name)?.options?.fields; const currentCollections = useMemo(() => { return collections.map((v) => { return { @@ -204,7 +205,7 @@ const EditFieldAction = (props) => { record?.fields || getCollection(record.collectionName, name) ?.options?.fields.filter((v) => { - return v.interface === 'select'; + return ['string', 'bigInt', 'integer'].includes(v.type); }) .map((k) => { return { @@ -213,7 +214,7 @@ const EditFieldAction = (props) => { }; }) ); - }, [record.name]); + }, [record.name, fields]); return ( diff --git a/packages/plugins/@nocobase/plugin-data-source-manager/src/client/component/CollectionsManager/components/CollectionFieldInterfaceSelect.tsx b/packages/plugins/@nocobase/plugin-data-source-manager/src/client/component/CollectionsManager/components/CollectionFieldInterfaceSelect.tsx index db5321525c..9699e66499 100644 --- a/packages/plugins/@nocobase/plugin-data-source-manager/src/client/component/CollectionsManager/components/CollectionFieldInterfaceSelect.tsx +++ b/packages/plugins/@nocobase/plugin-data-source-manager/src/client/component/CollectionsManager/components/CollectionFieldInterfaceSelect.tsx @@ -20,7 +20,9 @@ const getInterfaceOptions = (data, type) => { return v.children.length > 0; }); }; - +const isValueInOptions = (value, options) => { + return options?.some((option) => option.children?.some?.((child) => child.name === value)); +}; export const CollectionFieldInterfaceSelect = observer( (props: any) => { const { value, handleFieldChange } = props; @@ -51,6 +53,19 @@ export const CollectionFieldInterfaceSelect = observer( ); setSelectValue(targetValue); } + //选中的值不在选项中切换为第一个 + } else if (selectValue && !isValueInOptions(selectValue, options)) { + const targetValue = options[0]?.children?.[0]?.name; + const interfaceConfig = getInterface(targetValue); + handleFieldChange( + { + interface: targetValue, + uiSchema: { title: record?.uiSchema?.title, ...interfaceConfig?.default?.uiSchema }, + }, + record.name, + false, + ); + setSelectValue(targetValue); } }, [options]);