From 1bb073dc44340e6d2976308e1053feb008ce414c Mon Sep 17 00:00:00 2001
From: gyq <875626088@qq.com>
Date: Fri, 5 Jul 2024 15:22:07 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=80=97=E6=9D=90?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/utils/index.js | 9 +++++++--
src/views/invoicing/components/consumableList.vue | 4 +++-
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/src/utils/index.js b/src/utils/index.js
index 202a363..759b913 100644
--- a/src/utils/index.js
+++ b/src/utils/index.js
@@ -421,8 +421,9 @@ export function isPcBowser() {
* 保留小数n位,不进行四舍五入
* num你传递过来的数字,
* decimal你保留的几位,默认保留小数后两位
+ * isInt 是否保留0
*/
-export function formatDecimal(num, decimal = 2) {
+export function formatDecimal(num, decimal = 2, isInt = false) {
num = num.toFixed(3).toString();
const index = num.indexOf(".");
if (index !== -1) {
@@ -431,5 +432,9 @@ export function formatDecimal(num, decimal = 2) {
num = num.substring(0);
}
//截取后保留两位小数
- return parseFloat(num).toFixed(decimal);
+ if (isInt) {
+ return parseFloat(num);
+ } else {
+ return parseFloat(num).toFixed(decimal);
+ }
}
diff --git a/src/views/invoicing/components/consumableList.vue b/src/views/invoicing/components/consumableList.vue
index e5bd15a..9bf2ac2 100644
--- a/src/views/invoicing/components/consumableList.vue
+++ b/src/views/invoicing/components/consumableList.vue
@@ -26,7 +26,7 @@
- {{ scope.row.stockNumber - scope.row.stockConsume }}
+ {{ formatDecimal(scope.row.stockNumber - scope.row.stockConsume, 2, true) }}
@@ -43,10 +43,12 @@