|
|
@@ -9,10 +9,12 @@ export function getDecimalsNum(val: any, decimal = 2, maxCount = 6) {
|
|
|
let result = val
|
|
|
if (typeof val === 'number') {
|
|
|
const str = val.toString();
|
|
|
- const num = str.indexOf('.') + 1;
|
|
|
- const count = str.length - num;
|
|
|
- if (count > maxCount) {
|
|
|
- result = val.toFixed(decimal)
|
|
|
+ if (str.includes('.')) {
|
|
|
+ const num = str.indexOf('.') + 1;
|
|
|
+ const count = str.length - num;
|
|
|
+ if (count > maxCount) {
|
|
|
+ result = val.toFixed(decimal)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
return result
|