From 67207be4f2c0ee8fc5ed3a77ecfe7eb3353984bb Mon Sep 17 00:00:00 2001 From: gyq <875626088@qq.com> Date: Tue, 2 Jul 2024 09:36:47 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=BA=93=E5=AD=98?= =?UTF-8?q?=E7=9B=98=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 4 ++-- src/utils/index.js | 17 +++++++++++++++++ .../invoicing/components/addStockTakin.vue | 3 ++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/.env.development b/.env.development index e7c271e..138a850 100644 --- a/.env.development +++ b/.env.development @@ -5,12 +5,12 @@ ENV = 'development' # VUE_APP_BASE_API = 'http://192.168.2.42:8000' # VUE_APP_BASE_API = 'http://192.168.2.133:8000' # 测试 -# VUE_APP_BASE_API = 'https://admintestpapi.sxczgkj.cn' +VUE_APP_BASE_API = 'https://admintestpapi.sxczgkj.cn' # 生产 # VUE_APP_BASE_API = 'https://cashieradmin.sxczgkj.cn' # VUE_APP_BASE_API = 'http://192.168.2.96:8000' # 张松 -VUE_APP_BASE_API = 'http://192.168.2.147:8000/' +# VUE_APP_BASE_API = 'http://192.168.2.147:8000/' VUE_APP_WS_API = 'ws://192.168.2.128:8000' # 是否启用 babel-plugin-dynamic-import-node插 \ No newline at end of file diff --git a/src/utils/index.js b/src/utils/index.js index 7e3ee6b..09c2c79 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -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); +} diff --git a/src/views/invoicing/components/addStockTakin.vue b/src/views/invoicing/components/addStockTakin.vue index 58c0101..491b271 100644 --- a/src/views/invoicing/components/addStockTakin.vue +++ b/src/views/invoicing/components/addStockTakin.vue @@ -63,6 +63,7 @@