From e45b3ce95ccdeafe7c70eed2defd48d166db8108 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A2=AB=E9=9B=A8=E6=B0=B4=E8=BF=87=E6=BB=A4=E7=9A=84?= =?UTF-8?q?=E7=A9=BA=E6=B0=94-Rairn?= <958414905@qq.com> Date: Wed, 26 Apr 2023 15:23:31 +0800 Subject: [PATCH] fix: hide default value for expression (#1765) --- .../src/schema-component/antd/form-item/FormItem.tsx | 2 -- .../core/client/src/schema-settings/SchemaSettings.tsx | 2 +- .../workflow/src/client/components/DynamicExpression.tsx | 9 ++++----- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/packages/core/client/src/schema-component/antd/form-item/FormItem.tsx b/packages/core/client/src/schema-component/antd/form-item/FormItem.tsx index f0cd8d6028..187da09dfe 100644 --- a/packages/core/client/src/schema-component/antd/form-item/FormItem.tsx +++ b/packages/core/client/src/schema-component/antd/form-item/FormItem.tsx @@ -440,8 +440,6 @@ FormItem.Designer = function Designer() { service: { resource: collectionField?.target, }, - // for DynamicExpression - sourceCollection: form?.values.sourceCollection, style: { width: '100%', verticalAlign: 'top', diff --git a/packages/core/client/src/schema-settings/SchemaSettings.tsx b/packages/core/client/src/schema-settings/SchemaSettings.tsx index 85a911a3cc..b25a772ba2 100644 --- a/packages/core/client/src/schema-settings/SchemaSettings.tsx +++ b/packages/core/client/src/schema-settings/SchemaSettings.tsx @@ -1132,7 +1132,7 @@ SchemaSettings.EnableChildCollections = function EnableChildCollections(props) { // 是否显示默认值配置项 export const isShowDefaultValue = (collectionField: CollectionFieldOptions, getInterface) => { return ( - !['o2o', 'oho', 'obo', 'o2m', 'attachment'].includes(collectionField?.interface) && + !['o2o', 'oho', 'obo', 'o2m', 'attachment', 'expression'].includes(collectionField?.interface) && !isSystemField(collectionField, getInterface) ); }; diff --git a/packages/plugins/workflow/src/client/components/DynamicExpression.tsx b/packages/plugins/workflow/src/client/components/DynamicExpression.tsx index f130201890..3603385dbc 100644 --- a/packages/plugins/workflow/src/client/components/DynamicExpression.tsx +++ b/packages/plugins/workflow/src/client/components/DynamicExpression.tsx @@ -10,7 +10,7 @@ import { NAMESPACE } from '../locale'; import { useCollectionFieldOptions } from '../variable'; const InternalExpression = observer((props: any) => { - const { onChange, sourceCollection } = props; + const { onChange } = props; const { values } = useForm(); 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 ; }); function Result(props) { - const { sourceCollection } = props; const { t } = useTranslation(); const values = useRecord(); const options = useMemo( - () => useCollectionFieldOptions({ collection: sourceCollection || values.sourceCollection }), - [values.sourceCollection, values.sourceCollection, sourceCollection], + () => useCollectionFieldOptions({ collection: values.sourceCollection }), + [values.sourceCollection, values.sourceCollection], ); return props.value ? (