fix(报表): 修复全年日历报表中金额计算逻辑错误
修复 getAmount 函数中 d.val 为 "other" 时的匹配逻辑,正确结果为支付方式为空或为"其他"的和。
This commit is contained in:
@@ -212,25 +212,36 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getAmount(d, index, month) {
|
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 = [
|
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.title,
|
||||||
item => item.type === d.realTitle,
|
item => item.type === d.realTitle,
|
||||||
item => `${item.payMethod}${item.type}` === d.realTitle,
|
item => `${item.payMethod}${item.type}` === d.realTitle,
|
||||||
item => `${item.type}${item.payMethod}` === d.realTitle,
|
item => `${item.type}${item.payMethod}` === d.realTitle,
|
||||||
item => `${item.type}${item.goodsType}` === d.realTitle
|
item => `${item.type}${item.goodsType}` === d.realTitle
|
||||||
// 更复杂的条件组合
|
|
||||||
];
|
];
|
||||||
|
|
||||||
// 依次检查每个规则,返回第一个匹配项
|
|
||||||
for (const rule of matchRules) {
|
for (const rule of matchRules) {
|
||||||
const matchedItem = month.total.find(rule);
|
const matchedItem = month.total.find(rule);
|
||||||
if (matchedItem) {
|
if (matchedItem) {
|
||||||
@@ -238,7 +249,6 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 没有匹配项时返回空字符串
|
|
||||||
return "0";
|
return "0";
|
||||||
},
|
},
|
||||||
async handleExportAll() {
|
async handleExportAll() {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
// api接口请求地址
|
// api接口请求地址
|
||||||
// window.SITE_CONFIG['baseUrl'] = 'https://api.nuttyreading.com'; // 线上正式环境
|
// 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地址 = 域名 + 版本号
|
// cdn地址 = 域名 + 版本号
|
||||||
window.SITE_CONFIG['domain'] = './'; // 域名
|
window.SITE_CONFIG['domain'] = './'; // 域名
|
||||||
|
|||||||
Reference in New Issue
Block a user