优化库存盘点
This commit is contained in:
@@ -416,3 +416,20 @@ export function isPcBowser() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保留小数n位,不进行四舍五入
|
||||
* num你传递过来的数字,
|
||||
* decimal你保留的几位,默认保留小数后两位
|
||||
*/
|
||||
export function formatDecimal(num, decimal = 2) {
|
||||
num = num.toString();
|
||||
const index = num.indexOf(".");
|
||||
if (index !== -1) {
|
||||
num = num.substring(0, decimal + index + 1);
|
||||
} else {
|
||||
num = num.substring(0);
|
||||
}
|
||||
//截取后保留两位小数
|
||||
return parseFloat(num).toFixed(decimal);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user