refactor(wms/report): 提取计算逻辑到公共模块并修复数据展示问题

将各报表页面的统计计算逻辑提取到公共模块calc.js中
修复损失列表数据展示错误问题
增加异常统计功能展示
统一各报表页面的计算逻辑
修复日期格式化错误
调整页面大小限制从999到9999
This commit is contained in:
砂糖
2026-02-26 15:09:14 +08:00
parent f580b66401
commit af97afcbcb
7 changed files with 136 additions and 255 deletions

View File

@@ -144,6 +144,7 @@ import CoilNo from "@/components/KLPService/Renderer/CoilNo.vue";
import MemoInput from "@/components/MemoInput";
import MutiSelect from "@/components/MutiSelect";
import WarehouseSelect from "@/components/KLPService/WarehouseSelect";
import { calcSummary, calcAbSummary } from "@/views/wms/report/js/calc";
export default {
components: {
@@ -161,7 +162,7 @@ export default {
// 获取当前日期(默认选中当天)
const now = new Date()
const currentDate = `${now.getFullYear()}-${addZero(now.getMonth() + 1)}}`
const currentDate = `${now.getFullYear()}-${addZero(now.getMonth() + 1)}`
/**
* 生成指定日期/月份的时间范围字符串
@@ -290,47 +291,7 @@ export default {
},
computed: {
summary() {
// 总钢卷数量、总重、均重
const outCount = this.list.length
const outTotalWeight = this.list.reduce((acc, cur) => acc + (parseFloat(cur.netWeight) || 0), 0) // 增加容错
const outAvgWeight = outCount > 0 ? (outTotalWeight / outCount)?.toFixed(2) : 0
// 损失钢卷数量、总重、均重
const lossCount = this.lossList.length
const lossTotalWeight = this.lossList.reduce((acc, cur) => acc + (parseFloat(cur.netWeight) || 0), 0) // 增加容错
const lossAvgWeight = lossCount > 0 ? (lossTotalWeight / lossCount)?.toFixed(2) : 0
// 合计数量、总重、均重
const totalCount = outCount + lossCount
const totalWeight = parseFloat((outTotalWeight + lossTotalWeight).toFixed(2))
const totalAvgWeight = totalCount > 0 ? (totalWeight / totalCount)?.toFixed(2) : 0
// 成品比率
const passRate = outCount > 0 ? (outCount / lossCount) : 0
// 损失比率
const lossRate = 1 - passRate
// 异常率,成品在warehouseId在'2019583656787259393',
// '2019583325311414274',
// '2019583429955104769',
// '2019583137616310273',这四个库中的占比
const abRate = this.list.filter(item => {
return item.warehouseId == '2019583656787259393' || item.warehouseId == '2019583325311414274' || item.warehouseId == '2019583429955104769' || item.warehouseId == '2019583137616310273'
}).length / totalCount
return {
outCount,
outTotalWeight: outTotalWeight.toFixed(2),
outAvgWeight,
lossCount,
lossTotalWeight: lossTotalWeight.toFixed(2),
lossAvgWeight,
totalCount,
totalWeight: totalWeight.toFixed(2),
totalAvgWeight,
passRate: passRate?.toFixed(2) * 100 + '%',
lossRate: lossRate?.toFixed(2) * 100 + '%',
abRate: (abRate?.toFixed(2) * 100) || 0 + '%',
}
return calcSummary(this.list)
}
},
methods: {
@@ -390,7 +351,7 @@ export default {
message: '暂无数据',
type: 'warning',
})
this.list = []
this.lossList = []
this.loading = false
return
}