From 5829bd1890ad5ac607e3de26069207c2b4e7865b Mon Sep 17 00:00:00 2001 From: MerCry Date: Sun, 8 Feb 2026 16:37:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DepartmentStatisticsDataController.java | 4 ++- .../views/wecom/customerStatistics/index.vue | 32 +++++++++++++++---- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wocom/DepartmentStatisticsDataController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wocom/DepartmentStatisticsDataController.java index 14028f4..9d428d2 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wocom/DepartmentStatisticsDataController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wocom/DepartmentStatisticsDataController.java @@ -92,7 +92,9 @@ public class DepartmentStatisticsDataController extends BaseController { if(totalIns.equals(BigDecimal.ZERO)) { map.put("penetrationRate",null); } else { - map.put("penetrationRate",totalOrders.multiply(new BigDecimal(100)).divide(totalIns).setScale(2, RoundingMode.HALF_UP)); + map.put("penetrationRate",totalOrders.multiply(new BigDecimal(100)) + .divide(totalIns,2, RoundingMode.HALF_UP) + .setScale(2, RoundingMode.HALF_UP)); } return success(map); } diff --git a/ruoyi-ui/src/views/wecom/customerStatistics/index.vue b/ruoyi-ui/src/views/wecom/customerStatistics/index.vue index 149fee9..f67f7b2 100644 --- a/ruoyi-ui/src/views/wecom/customerStatistics/index.vue +++ b/ruoyi-ui/src/views/wecom/customerStatistics/index.vue @@ -313,14 +313,32 @@ export default { }, `客户统计数据_${new Date().getTime()}.xlsx`) }, /** 处理成本更新 */ - handleUpdateCost(date,cost,attr) { + handleUpdateCost(date, cost, attr) { + // 校验 cost 是否为有效数字 + if (cost === '' || cost === null || cost === undefined) { + this.$modal.msgWarning("请输入成本金额"); + return; + } + + const numCost = Number(cost); + if (isNaN(numCost)) { + this.$modal.msgWarning("成本金额必须为数字"); + return; + } + + // 可选: 校验是否为负数 + if (numCost < 0) { + this.$modal.msgWarning("成本金额不能为负数"); + return; + } + const formattedDate = this.parseTime(date, '{y}-{m}-{d}'); - updateCustomerStatistics(formattedDate,cost,attr).then(response => { - this.$modal.msgSuccess("修改成功"); - this.getList(); - }).catch(() => { - this.getList(); // 失败时刷新数据以还原修改 - }); + updateCustomerStatistics(formattedDate, numCost, attr).then(response => { + this.$modal.msgSuccess("修改成功"); + this.getList(); + }).catch(() => { + this.getList(); // 失败时刷新数据以还原修改 + }); } } }