fix(formula): support integer and fix NaN error (#879)

* fix(formula): support integer and fix NaN error

* style(formula-input): remove debugger

(cherry picked from commit 86f24a35ec25d415b5319aba4de7b509774683fd)
This commit is contained in:
lyf-coder 2022-10-10 15:54:57 +08:00 committed by chenos
parent 72372f34e9
commit 7b371706ef
2 changed files with 10 additions and 15 deletions

View File

@ -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 }}'
},
},

View File

@ -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 (
<InputNumber {...others} readOnly stringMode={true} />
);
}
});
});
export const Compute = connect(
AntdCompute,
mapReadPretty(ReadPretty)
);
return <InputNumber {...others} readOnly stringMode={true} />;
};
export default Compute;
export const Compute = connect(AntdCompute, mapReadPretty(ReadPretty));
export default Compute;