fix(wms): 修复透视表数据展示和边料统计问题
修复透视表预览条件判断错误,将currentRow.summaryId改为liveData 修正边料统计接口调用错误,将listCoilTrimStatistics改为listMaterialCoil 添加可选链操作符处理可能为null的数据遍历
This commit is contained in:
@@ -92,8 +92,8 @@ export default {
|
|||||||
// 提取净边料所有原始宽度
|
// 提取净边料所有原始宽度
|
||||||
rawTrimmedWidths() {
|
rawTrimmedWidths() {
|
||||||
const widthSet = new Set();
|
const widthSet = new Set();
|
||||||
this.data.forEach(item => {
|
this.data?.forEach(item => {
|
||||||
item.trimmedList.forEach(trimmed => {
|
item.trimmedList?.forEach(trimmed => {
|
||||||
if (trimmed.width) widthSet.add(trimmed.width);
|
if (trimmed.width) widthSet.add(trimmed.width);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -108,8 +108,8 @@ export default {
|
|||||||
// 提取毛边料所有原始宽度
|
// 提取毛边料所有原始宽度
|
||||||
rawUntrimmedWidths() {
|
rawUntrimmedWidths() {
|
||||||
const widthSet = new Set();
|
const widthSet = new Set();
|
||||||
this.data.forEach(item => {
|
this.data?.forEach(item => {
|
||||||
item.untrimmedList.forEach(untrimmed => {
|
item.untrimmedList?.forEach(untrimmed => {
|
||||||
if (untrimmed.width) widthSet.add(untrimmed.width);
|
if (untrimmed.width) widthSet.add(untrimmed.width);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -132,25 +132,25 @@ export default {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 初始化净边料分组数据
|
// 初始化净边料分组数据
|
||||||
this.trimmedWidthGroups.forEach(group => {
|
this.trimmedWidthGroups?.forEach(group => {
|
||||||
row[`trimmed_${group.key}_count`] = 0;
|
row[`trimmed_${group.key}_count`] = 0;
|
||||||
row[`trimmed_${group.key}_weight`] = 0;
|
row[`trimmed_${group.key}_weight`] = 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
// 初始化毛边料分组数据
|
// 初始化毛边料分组数据
|
||||||
this.untrimmedWidthGroups.forEach(group => {
|
this.untrimmedWidthGroups?.forEach(group => {
|
||||||
row[`untrimmed_${group.key}_count`] = 0;
|
row[`untrimmed_${group.key}_count`] = 0;
|
||||||
row[`untrimmed_${group.key}_weight`] = 0;
|
row[`untrimmed_${group.key}_weight`] = 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
// 处理净边料数据(按分组求和)
|
// 处理净边料数据(按分组求和)
|
||||||
item.trimmedList.forEach(trimmed => {
|
item.trimmedList?.forEach(trimmed => {
|
||||||
const width = trimmed.width;
|
const width = trimmed.width;
|
||||||
const count = Number(trimmed.coilCount) || 0;
|
const count = Number(trimmed.coilCount) || 0;
|
||||||
const weight = Number(trimmed.totalWeight) || 0;
|
const weight = Number(trimmed.totalWeight) || 0;
|
||||||
|
|
||||||
// 找到宽度所属的分组并累加
|
// 找到宽度所属的分组并累加
|
||||||
this.trimmedWidthGroups.forEach(group => {
|
this.trimmedWidthGroups?.forEach(group => {
|
||||||
if (group.includesWidth(width)) {
|
if (group.includesWidth(width)) {
|
||||||
row[`trimmed_${group.key}_count`] += count;
|
row[`trimmed_${group.key}_count`] += count;
|
||||||
row[`trimmed_${group.key}_weight`] = (row[`trimmed_${group.key}_weight`] + weight).toFixed(3);
|
row[`trimmed_${group.key}_weight`] = (row[`trimmed_${group.key}_weight`] + weight).toFixed(3);
|
||||||
@@ -163,13 +163,13 @@ export default {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 处理毛边料数据(按分组求和)
|
// 处理毛边料数据(按分组求和)
|
||||||
item.untrimmedList.forEach(untrimmed => {
|
item.untrimmedList?.forEach(untrimmed => {
|
||||||
const width = untrimmed.width;
|
const width = untrimmed.width;
|
||||||
const count = Number(untrimmed.coilCount) || 0;
|
const count = Number(untrimmed.coilCount) || 0;
|
||||||
const weight = Number(untrimmed.totalWeight) || 0;
|
const weight = Number(untrimmed.totalWeight) || 0;
|
||||||
|
|
||||||
// 找到宽度所属的分组并累加
|
// 找到宽度所属的分组并累加
|
||||||
this.untrimmedWidthGroups.forEach(group => {
|
this.untrimmedWidthGroups?.forEach(group => {
|
||||||
if (group.includesWidth(width)) {
|
if (group.includesWidth(width)) {
|
||||||
row[`untrimmed_${group.key}_count`] += count;
|
row[`untrimmed_${group.key}_count`] += count;
|
||||||
row[`untrimmed_${group.key}_weight`] = (row[`untrimmed_${group.key}_weight`] + weight).toFixed(3);
|
row[`untrimmed_${group.key}_weight`] = (row[`untrimmed_${group.key}_weight`] + weight).toFixed(3);
|
||||||
@@ -202,7 +202,7 @@ export default {
|
|||||||
|
|
||||||
// 检查净边料分组列
|
// 检查净边料分组列
|
||||||
if (!hasNonZeroData) {
|
if (!hasNonZeroData) {
|
||||||
this.trimmedWidthGroups.forEach(group => {
|
this.trimmedWidthGroups?.forEach(group => {
|
||||||
if (Number(row[`trimmed_${group.key}_count`]) > 0 || Number(row[`trimmed_${group.key}_weight`]) > 0) {
|
if (Number(row[`trimmed_${group.key}_count`]) > 0 || Number(row[`trimmed_${group.key}_weight`]) > 0) {
|
||||||
hasNonZeroData = true;
|
hasNonZeroData = true;
|
||||||
}
|
}
|
||||||
@@ -211,7 +211,7 @@ export default {
|
|||||||
|
|
||||||
// 检查毛边料分组列
|
// 检查毛边料分组列
|
||||||
if (!hasNonZeroData) {
|
if (!hasNonZeroData) {
|
||||||
this.untrimmedWidthGroups.forEach(group => {
|
this.untrimmedWidthGroups?.forEach(group => {
|
||||||
if (Number(row[`untrimmed_${group.key}_count`]) > 0 || Number(row[`untrimmed_${group.key}_weight`]) > 0) {
|
if (Number(row[`untrimmed_${group.key}_count`]) > 0 || Number(row[`untrimmed_${group.key}_weight`]) > 0) {
|
||||||
hasNonZeroData = true;
|
hasNonZeroData = true;
|
||||||
}
|
}
|
||||||
@@ -229,7 +229,7 @@ export default {
|
|||||||
const usedWidths = new Set();
|
const usedWidths = new Set();
|
||||||
|
|
||||||
// 遍历分组规则,匹配原始宽度
|
// 遍历分组规则,匹配原始宽度
|
||||||
Object.entries(this.widthGroupRules).forEach(([groupLabel, widthList]) => {
|
Object.entries(this.widthGroupRules)?.forEach(([groupLabel, widthList]) => {
|
||||||
// 筛选出当前分组包含的原始宽度
|
// 筛选出当前分组包含的原始宽度
|
||||||
const matchedWidths = rawWidths.filter(width => widthList.includes(width));
|
const matchedWidths = rawWidths.filter(width => widthList.includes(width));
|
||||||
if (matchedWidths.length === 0) return;
|
if (matchedWidths.length === 0) return;
|
||||||
@@ -246,11 +246,11 @@ export default {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 标记已使用的宽度
|
// 标记已使用的宽度
|
||||||
matchedWidths.forEach(width => usedWidths.add(width));
|
matchedWidths?.forEach(width => usedWidths.add(width));
|
||||||
});
|
});
|
||||||
|
|
||||||
// 处理未匹配到分组的宽度(单独成组)
|
// 处理未匹配到分组的宽度(单独成组)
|
||||||
rawWidths.forEach(width => {
|
rawWidths?.forEach(width => {
|
||||||
if (!usedWidths.has(width)) {
|
if (!usedWidths.has(width)) {
|
||||||
const groupKey = width.replace(/[^a-zA-Z0-9]/g, '_');
|
const groupKey = width.replace(/[^a-zA-Z0-9]/g, '_');
|
||||||
groups.push({
|
groups.push({
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
label="orderBy">保存透视表时保存明细,勾选后在保存时会消耗更长的时间且会占用更多内存和存储</el-checkbox>
|
label="orderBy">保存透视表时保存明细,勾选后在保存时会消耗更长的时间且会占用更多内存和存储</el-checkbox>
|
||||||
</div>
|
</div>
|
||||||
<div style="height: calc(100vh - 300px); overflow-y: scroll; overflow-x: hidden;">
|
<div style="height: calc(100vh - 300px); overflow-y: scroll; overflow-x: hidden;">
|
||||||
<div v-if="currentRow.summaryId">
|
<div v-if="liveData">
|
||||||
<Preview :data="liveData" :statType="form.statType" />
|
<Preview :data="liveData" :statType="form.statType" />
|
||||||
</div>
|
</div>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
@@ -227,14 +227,14 @@ export default {
|
|||||||
itemName: '冷硬卷',
|
itemName: '冷硬卷',
|
||||||
itemType: 'raw_material',
|
itemType: 'raw_material',
|
||||||
})
|
})
|
||||||
const { rows: coils2 } = await listCoilTrimStatistics({
|
const { rows: coils2 } = await listMaterialCoil({
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
pageSize: 9999,
|
pageSize: 9999,
|
||||||
selectType: 'product',
|
selectType: 'product',
|
||||||
dataType: 1,
|
dataType: 1,
|
||||||
status: 0,
|
status: 0,
|
||||||
itemName: '冷硬卷',
|
itemName: '冷硬卷',
|
||||||
itemType: 'raw_material',
|
itemType: 'product',
|
||||||
})
|
})
|
||||||
coilIds = coils1.concat(coils2).map(item => item.coilId).join(',')
|
coilIds = coils1.concat(coils2).map(item => item.coilId).join(',')
|
||||||
} else if (this.form.statType == '汇总') {
|
} else if (this.form.statType == '汇总') {
|
||||||
|
|||||||
Reference in New Issue
Block a user