diff --git a/packages/core/client/src/collection-manager/interfaces/formula.ts b/packages/core/client/src/collection-manager/interfaces/formula.ts index 949c44d5e..99e41a26c 100644 --- a/packages/core/client/src/collection-manager/interfaces/formula.ts +++ b/packages/core/client/src/collection-manager/interfaces/formula.ts @@ -33,7 +33,7 @@ export const formula: IField = { 'x-component': 'Formula.Expression', 'x-decorator': 'FormItem', 'x-component-props': { - 'supports': ['number', 'percent'], + 'supports': ['number', 'percent', 'integer'], 'useCurrentFields': '{{ useCurrentFields }}' }, }, diff --git a/packages/core/client/src/schema-component/antd/formula-input/Compute.tsx b/packages/core/client/src/schema-component/antd/formula-input/Compute.tsx index b28feee10..e69293d7a 100644 --- a/packages/core/client/src/schema-component/antd/formula-input/Compute.tsx +++ b/packages/core/client/src/schema-component/antd/formula-input/Compute.tsx @@ -20,22 +20,17 @@ const AntdCompute = (props) => { let result; try { result = math.evaluate(expression, scope); - result = math.round(result, 9); - } catch {} + result = Number.isFinite(result) ? math.round(result, 9) : null; + } catch{} if (onChange) { onChange(result); } - }) - }) - - return ( - - ); -} + }); + }); -export const Compute = connect( - AntdCompute, - mapReadPretty(ReadPretty) -); + return ; +}; -export default Compute; \ No newline at end of file +export const Compute = connect(AntdCompute, mapReadPretty(ReadPretty)); + +export default Compute;