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:
parent
72372f34e9
commit
7b371706ef
@ -33,7 +33,7 @@ export const formula: IField = {
|
|||||||
'x-component': 'Formula.Expression',
|
'x-component': 'Formula.Expression',
|
||||||
'x-decorator': 'FormItem',
|
'x-decorator': 'FormItem',
|
||||||
'x-component-props': {
|
'x-component-props': {
|
||||||
'supports': ['number', 'percent'],
|
'supports': ['number', 'percent', 'integer'],
|
||||||
'useCurrentFields': '{{ useCurrentFields }}'
|
'useCurrentFields': '{{ useCurrentFields }}'
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -20,22 +20,17 @@ const AntdCompute = (props) => {
|
|||||||
let result;
|
let result;
|
||||||
try {
|
try {
|
||||||
result = math.evaluate(expression, scope);
|
result = math.evaluate(expression, scope);
|
||||||
result = math.round(result, 9);
|
result = Number.isFinite(result) ? math.round(result, 9) : null;
|
||||||
} catch {}
|
} catch{}
|
||||||
if (onChange) {
|
if (onChange) {
|
||||||
onChange(result);
|
onChange(result);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
|
|
||||||
return (
|
return <InputNumber {...others} readOnly stringMode={true} />;
|
||||||
<InputNumber {...others} readOnly stringMode={true} />
|
};
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export const Compute = connect(
|
export const Compute = connect(AntdCompute, mapReadPretty(ReadPretty));
|
||||||
AntdCompute,
|
|
||||||
mapReadPretty(ReadPretty)
|
|
||||||
);
|
|
||||||
|
|
||||||
export default Compute;
|
export default Compute;
|
Loading…
Reference in New Issue
Block a user