refactor: collectionFieldInterfaceSelect

This commit is contained in:
katherinehhh 2024-02-04 20:13:54 +08:00
parent 8c33dfed9c
commit 0d55576fff

View File

@ -1,5 +1,5 @@
import { observer, useForm, useField } from '@formily/react';
import { Select } from 'antd';
import { Select, Tag } from 'antd';
import React, { useState } from 'react';
import { useCompile, useCollectionManager, useRecord, useFieldInterfaceOptions } from '@nocobase/client';
@ -27,9 +27,10 @@ export const CollectionFieldInterfaceSelect = observer(
const form = useForm();
const field = useField();
const [options, setOptions] = useState(data);
return (
return ['oho', 'obo', 'o2m', 'm2o', 'm2m'].includes(record.interface) ? (
<Tag key={value}>{options.find((v) => v.value === value)['label']}</Tag>
) : (
<Select
disabled={['oho', 'obo', 'o2m', 'm2o', 'm2m'].includes(record.interface)}
defaultValue={value}
style={{ width: '100%' }}
popupMatchSelectWidth={false}