fix: hide default value for expression (#1765)

This commit is contained in:
被雨水过滤的空气-Rairn 2023-04-26 15:23:31 +08:00 committed by GitHub
parent 07d1c7ccc0
commit e45b3ce95c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 8 deletions

View File

@ -440,8 +440,6 @@ FormItem.Designer = function Designer() {
service: { service: {
resource: collectionField?.target, resource: collectionField?.target,
}, },
// for DynamicExpression
sourceCollection: form?.values.sourceCollection,
style: { style: {
width: '100%', width: '100%',
verticalAlign: 'top', verticalAlign: 'top',

View File

@ -1132,7 +1132,7 @@ SchemaSettings.EnableChildCollections = function EnableChildCollections(props) {
// 是否显示默认值配置项 // 是否显示默认值配置项
export const isShowDefaultValue = (collectionField: CollectionFieldOptions, getInterface) => { export const isShowDefaultValue = (collectionField: CollectionFieldOptions, getInterface) => {
return ( return (
!['o2o', 'oho', 'obo', 'o2m', 'attachment'].includes(collectionField?.interface) && !['o2o', 'oho', 'obo', 'o2m', 'attachment', 'expression'].includes(collectionField?.interface) &&
!isSystemField(collectionField, getInterface) !isSystemField(collectionField, getInterface)
); );
}; };

View File

@ -10,7 +10,7 @@ import { NAMESPACE } from '../locale';
import { useCollectionFieldOptions } from '../variable'; import { useCollectionFieldOptions } from '../variable';
const InternalExpression = observer((props: any) => { const InternalExpression = observer((props: any) => {
const { onChange, sourceCollection } = props; const { onChange } = props;
const { values } = useForm(); const { values } = useForm();
const [collection, setCollection] = useState(values?.sourceCollection); const [collection, setCollection] = useState(values?.sourceCollection);
@ -24,18 +24,17 @@ const InternalExpression = observer((props: any) => {
}); });
}); });
const options = useCollectionFieldOptions({ collection: sourceCollection || collection }); const options = useCollectionFieldOptions({ collection: collection });
return <Variable.TextArea {...props} scope={options} />; return <Variable.TextArea {...props} scope={options} />;
}); });
function Result(props) { function Result(props) {
const { sourceCollection } = props;
const { t } = useTranslation(); const { t } = useTranslation();
const values = useRecord(); const values = useRecord();
const options = useMemo( const options = useMemo(
() => useCollectionFieldOptions({ collection: sourceCollection || values.sourceCollection }), () => useCollectionFieldOptions({ collection: values.sourceCollection }),
[values.sourceCollection, values.sourceCollection, sourceCollection], [values.sourceCollection, values.sourceCollection],
); );
return props.value ? ( return props.value ? (
<Variable.TextArea {...props} scope={options} /> <Variable.TextArea {...props} scope={options} />