diff --git a/packages/core/client/src/schema-component/antd/form-v2/utils.tsx b/packages/core/client/src/schema-component/antd/form-v2/utils.tsx index 6669d7ed7..734fe432a 100644 --- a/packages/core/client/src/schema-component/antd/form-v2/utils.tsx +++ b/packages/core/client/src/schema-component/antd/form-v2/utils.tsx @@ -62,7 +62,9 @@ export const linkageMergeAction = ({ operator, value }, field, condition, values try { const result = evaluate(value.result || value.value, { ...scope, now: () => new Date().toString() }); valueResult.push(result); - } catch (error) {} + } catch (error) { + console.log(error); + } } else if (value?.mode === 'constant') { valueResult.push(value?.value || value); } else { diff --git a/packages/core/client/src/schema-component/common/utils/uitls.tsx b/packages/core/client/src/schema-component/common/utils/uitls.tsx index ea241c152..bf9288f80 100644 --- a/packages/core/client/src/schema-component/common/utils/uitls.tsx +++ b/packages/core/client/src/schema-component/common/utils/uitls.tsx @@ -61,7 +61,7 @@ const getValue = (str: string, values) => { const regex = /{{(.*?)}}/; const matches = str?.match?.(regex); if (matches) { - return getVariableValue(str, values); + return getVariableValue(str, flat(values)); } else { return str; } diff --git a/packages/core/client/src/schema-settings/LinkageRules/FilterDynamicComponent.tsx b/packages/core/client/src/schema-settings/LinkageRules/FilterDynamicComponent.tsx index 4b354ee08..00dc390ad 100644 --- a/packages/core/client/src/schema-settings/LinkageRules/FilterDynamicComponent.tsx +++ b/packages/core/client/src/schema-settings/LinkageRules/FilterDynamicComponent.tsx @@ -11,7 +11,7 @@ type Props = { export function FilterDynamicComponent(props: Props) { const { value, onChange, renderSchemaComponent, collectionName } = props; - const scope = useVariableOptions(collectionName); + const scope = useVariableOptions(collectionName, ['o2m', 'm2m']); return ( {renderSchemaComponent()} diff --git a/packages/core/client/src/schema-settings/LinkageRules/Variables.tsx b/packages/core/client/src/schema-settings/LinkageRules/Variables.tsx index db9a79c5f..d095814e2 100644 --- a/packages/core/client/src/schema-settings/LinkageRules/Variables.tsx +++ b/packages/core/client/src/schema-settings/LinkageRules/Variables.tsx @@ -2,6 +2,7 @@ import { useCompile } from '../../schema-component'; import { useCollectionManager, useCollection } from '../../collection-manager'; const supportsType = [ + 'id', 'checkbox', 'number', 'percent', @@ -24,7 +25,7 @@ const supportsType = [ 'o2m', 'm2m', ]; -const useVariableTypes = (currentCollection) => { +const useVariableTypes = (currentCollection, excludes = []) => { const { getCollectionFields, getInterface, getCollection } = useCollectionManager(); const collection = getCollection(currentCollection); const fields = getCollectionFields(currentCollection); @@ -34,7 +35,7 @@ const useVariableTypes = (currentCollection) => { value: currentCollection, options() { const field2option = (field, depth) => { - if (!field.interface || !supportsType.includes(field.interface)) { + if (!field.interface || !supportsType.filter((v) => !excludes.includes(v)).includes(field.interface)) { return; } const fieldInterface = getInterface(field.interface); @@ -92,9 +93,9 @@ const useVariableTypes = (currentCollection) => { ]; }; -export function useVariableOptions(collectionName) { +export function useVariableOptions(collectionName, excludes?) { const compile = useCompile(); - const options = useVariableTypes(collectionName).map((item) => { + const options = useVariableTypes(collectionName, excludes).map((item) => { const options = typeof item.options === 'function' ? item.options() : item.options; return { label: compile(item.title),