Skip to content

Commit

Permalink
fix: input-number 在大数输入下不处理精度 Closes baidu#6334 (baidu#9012)
Browse files Browse the repository at this point in the history
  • Loading branch information
吴多益 authored Dec 25, 2023
1 parent 71c3324 commit 082b0d6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/amis/src/renderers/Form/InputNumber.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export default class NumberControl extends React.Component<
this.handleChangeUnit = this.handleChangeUnit.bind(this);
const unit = this.getUnit();
const unitOptions = normalizeOptions(props.unitOptions);
const {formItem, setPrinstineValue, precision, step, value} = props;
const {formItem, setPrinstineValue, precision, step, value, big} = props;
const normalizedPrecision = NumberInput.normalizePrecision(
this.filterNum(precision),
this.filterNum(step)
Expand All @@ -201,7 +201,9 @@ export default class NumberControl extends React.Component<
formItem &&
value != null &&
normalizedPrecision != null &&
(!unit || unitOptions.length === 0)
(!unit || unitOptions.length === 0) &&
// 大数下不需要进行精度处理,因为输入输出都是字符串
big !== true
) {
const normalizedValue = parseFloat(
toFixed(value.toString(), '.', normalizedPrecision)
Expand Down

0 comments on commit 082b0d6

Please sign in to comment.