From 2a457fc0768f3b1174fc35096eb2af0ad3451e17 Mon Sep 17 00:00:00 2001 From: chenghuan Date: Tue, 3 Feb 2026 16:38:45 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8A=A5=E8=A1=A8):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=85=A8=E5=B9=B4=E6=97=A5=E5=8E=86=E6=8A=A5=E8=A1=A8=E4=B8=AD?= =?UTF-8?q?=E9=87=91=E9=A2=9D=E8=AE=A1=E7=AE=97=E9=80=BB=E8=BE=91=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复 getAmount 函数中 d.val 为 "other" 时的匹配逻辑,正确结果为支付方式为空或为"其他"的和。 --- .../reportList/FullYearCalendarCoin.vue | 34 ++++++++++++------- static/config/index.js | 2 +- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/views/modules/reportList/FullYearCalendarCoin.vue b/src/views/modules/reportList/FullYearCalendarCoin.vue index 369a305..4a2f304 100644 --- a/src/views/modules/reportList/FullYearCalendarCoin.vue +++ b/src/views/modules/reportList/FullYearCalendarCoin.vue @@ -212,25 +212,36 @@ export default { }, methods: { getAmount(d, index, month) { - - // 定义所有可能的匹配规则 + if (!month || !month.total || !Array.isArray(month.total)) { + return "0"; + } + + if (d.val === "other") { + const list = month.total.filter(item => { + return ( + item.type === d.realTitle && + (item.payMethod === "" || item.payMethod === "其他") + ); + }); + + if (!list.length) { + return "0"; + } + + return list.reduce((sum, item) => { + const val = Number(item.amount || 0); + return sum + (isNaN(val) ? 0 : val); + }, 0); + } + const matchRules = [ - item => { - // 例如:当类型是特定值时,启用特殊匹配 - if (d.val == "other" && item.payMethod == "") { - return `${item.type}` === d.realTitle; - } - return false; - }, item => item.type === d.title, item => item.type === d.realTitle, item => `${item.payMethod}${item.type}` === d.realTitle, item => `${item.type}${item.payMethod}` === d.realTitle, item => `${item.type}${item.goodsType}` === d.realTitle - // 更复杂的条件组合 ]; - // 依次检查每个规则,返回第一个匹配项 for (const rule of matchRules) { const matchedItem = month.total.find(rule); if (matchedItem) { @@ -238,7 +249,6 @@ export default { } } - // 没有匹配项时返回空字符串 return "0"; }, async handleExportAll() { diff --git a/static/config/index.js b/static/config/index.js index 493669f..274f935 100644 --- a/static/config/index.js +++ b/static/config/index.js @@ -6,7 +6,7 @@ // api接口请求地址 // window.SITE_CONFIG['baseUrl'] = 'https://api.nuttyreading.com'; // 线上正式环境 - window.SITE_CONFIG['baseUrl'] = 'http://192.168.110.100:9200/pb'; //川 + window.SITE_CONFIG['baseUrl'] = 'http://192.168.110.100:9200/pb'; // 川 // cdn地址 = 域名 + 版本号 window.SITE_CONFIG['domain'] = './'; // 域名