|
|
@@ -40,6 +40,7 @@
|
|
|
>
|
|
|
<template v-slot:reportQuantity="{ row }">
|
|
|
<div>
|
|
|
+ {{ reportQuantitymax(row) }}
|
|
|
<el-input-number
|
|
|
size="small"
|
|
|
v-model.number="row.reportQuantity"
|
|
|
@@ -209,7 +210,7 @@
|
|
|
// 1-物料本身
|
|
|
} else if (this.outputType == 2) {
|
|
|
// 2-在制品
|
|
|
- this.getCategoryAndLevelByCategoryId();
|
|
|
+ this.categoryInfoSetOutput();
|
|
|
} else {
|
|
|
// 3 BOM标准产出
|
|
|
this.setMaterialQuotaInfo();
|
|
|
@@ -236,6 +237,13 @@
|
|
|
this.$emit('update:pickDetails', this.localPickDetails);
|
|
|
this.$emit('update:outputDetails', this.localOutputDetails);
|
|
|
}
|
|
|
+ },
|
|
|
+ produceTaskId: {
|
|
|
+ handler() {
|
|
|
+ this.getMaterialQuotaInfo();
|
|
|
+ this.getCategoryAndLevelByCategoryId();
|
|
|
+ },
|
|
|
+ immediate: true
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
@@ -319,6 +327,16 @@
|
|
|
if (!this.materialQuotaInfo) {
|
|
|
return '0' + (row.unit || '');
|
|
|
}
|
|
|
+ // 当前行为在制品 和 BOM标准产出
|
|
|
+ const preOutputItem = this.localOutputDetails.find(
|
|
|
+ (item) => item.categoryCode === row.categoryCode
|
|
|
+ );
|
|
|
+
|
|
|
+ if (preOutputItem) {
|
|
|
+ return (preOutputItem.reportQuantity || 0) + (row.unit || '');
|
|
|
+ }
|
|
|
+
|
|
|
+ // 当前行为原材料
|
|
|
const materialItem = this.materialQuotaInfo.materialQuota.find(
|
|
|
(item) => item.categoryCode === row.categoryCode
|
|
|
);
|
|
|
@@ -348,31 +366,98 @@
|
|
|
const outputItem = this.localOutputDetails.find(
|
|
|
(item) => item.categoryCode == row.categoryCode
|
|
|
);
|
|
|
- if (!outputItem) {
|
|
|
- return row.sumReportQuantity + (row.unit || '');
|
|
|
+
|
|
|
+ // 查询其他工单sumOutputDetails中已产生的bom标准产出和在制品的累计消耗数量
|
|
|
+ let preCount = 0;
|
|
|
+ if (this.materialQuotaInfo) {
|
|
|
+ const materialQuotaItem =
|
|
|
+ this.materialQuotaInfo.materialQuota.find(
|
|
|
+ (item) => item.categoryCode === row.categoryCode
|
|
|
+ );
|
|
|
+
|
|
|
+ if (!materialQuotaItem) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 计算比例
|
|
|
+ const proportion =
|
|
|
+ materialQuotaItem.count / this.materialQuotaInfo.baseCount;
|
|
|
+
|
|
|
+ if (this.materialQuotaInfo.standardOutput) {
|
|
|
+ // BOM标准产出
|
|
|
+ const preItem = this.sumOutputDetails.find(
|
|
|
+ (item) =>
|
|
|
+ item.categoryCode ===
|
|
|
+ this.materialQuotaInfo.standardOutput.categoryCode
|
|
|
+ );
|
|
|
+ if (preItem) {
|
|
|
+ preCount += preItem.sumReportQuantity * proportion;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (this.categoryInfo) {
|
|
|
+ // 在制品
|
|
|
+ const preItem = this.sumOutputDetails.find(
|
|
|
+ (item) =>
|
|
|
+ item.categoryCode === this.categoryInfo.categoryCode
|
|
|
+ );
|
|
|
+ if (preItem) {
|
|
|
+ preCount += preItem.sumReportQuantity * proportion;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
let count = 0;
|
|
|
- if (this.executeStatus === 2) {
|
|
|
- // 已执行,处理重新一键报工时,sumReportQuantity包含了当前报工数量
|
|
|
- count =
|
|
|
- row.sumReportQuantity -
|
|
|
- (outputItem.reportQuantityCopy - outputItem.reportQuantity);
|
|
|
+ if (outputItem) {
|
|
|
+ if (this.executeStatus === 2) {
|
|
|
+ // 已执行,处理重新一键报工时,sumReportQuantity包含了当前报工数量
|
|
|
+ count =
|
|
|
+ row.sumReportQuantity -
|
|
|
+ (outputItem.reportQuantityCopy -
|
|
|
+ outputItem.reportQuantity);
|
|
|
+ } else {
|
|
|
+ count = row.sumReportQuantity + outputItem.reportQuantity;
|
|
|
+ }
|
|
|
} else {
|
|
|
- count = row.sumReportQuantity + outputItem.reportQuantity;
|
|
|
+ count = row.sumReportQuantity;
|
|
|
}
|
|
|
|
|
|
- return count + (row.unit || '');
|
|
|
+ return count + preCount + (row.unit || '');
|
|
|
} else {
|
|
|
+ // 当前行为在制品 和 BOM标准产出
|
|
|
+ const output = this.localOutputDetails.find(
|
|
|
+ (item) => item.categoryCode === row.categoryCode
|
|
|
+ );
|
|
|
+
|
|
|
+ if (output) {
|
|
|
+ // 区分已执行状态
|
|
|
+ if (this.executeStatus === 2) {
|
|
|
+ // 已执行,处理重新一键报工时,sumReportQuantity包含了当前报工数量
|
|
|
+ return (
|
|
|
+ output.sumReportQuantity -
|
|
|
+ (output.reportQuantityCopy - output.reportQuantity) +
|
|
|
+ (row.unit || '')
|
|
|
+ );
|
|
|
+ }
|
|
|
+ return (
|
|
|
+ (output.sumReportQuantity || 0) +
|
|
|
+ output.reportQuantity +
|
|
|
+ (row.unit || '')
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
// 产出为在制品 或 BOM标准产出 累计消耗数量
|
|
|
if (!this.materialQuotaInfo) {
|
|
|
return row.sumReportQuantity + (row.unit || '');
|
|
|
}
|
|
|
+
|
|
|
const materialItem = this.materialQuotaInfo.materialQuota.find(
|
|
|
(item) => item.categoryCode === row.categoryCode
|
|
|
);
|
|
|
if (!materialItem) {
|
|
|
return row.sumReportQuantity + (row.unit || '');
|
|
|
}
|
|
|
+ // 计算在制 标准产出消耗原材料
|
|
|
const outputItem = this.localOutputDetails[0];
|
|
|
if (!outputItem) {
|
|
|
return row.sumReportQuantity + (row.unit || '');
|
|
|
@@ -381,6 +466,38 @@
|
|
|
const proportion =
|
|
|
materialItem.count / this.materialQuotaInfo.baseCount;
|
|
|
|
|
|
+ // 查询其他工单sumOutputDetails中已产生的bom标准产出和在制品的累计消耗数量
|
|
|
+ let preCount = 0;
|
|
|
+ // 如果当前物料不是BOM标准产出,则需要加上BOM标准产出的消耗数量
|
|
|
+ if (
|
|
|
+ outputItem.categoryCode !=
|
|
|
+ this.materialQuotaInfo.standardOutput.categoryCode
|
|
|
+ ) {
|
|
|
+ // BOM标准产出
|
|
|
+ const preItem = this.sumOutputDetails.find(
|
|
|
+ (item) =>
|
|
|
+ item.categoryCode ===
|
|
|
+ this.materialQuotaInfo.standardOutput.categoryCode
|
|
|
+ );
|
|
|
+ if (preItem) {
|
|
|
+ preCount += preItem.sumReportQuantity * proportion;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 在制品
|
|
|
+ if (this.categoryInfo) {
|
|
|
+ if (
|
|
|
+ this.categoryInfo.categoryCode != outputItem.categoryCode
|
|
|
+ ) {
|
|
|
+ const preItem = this.sumOutputDetails.find(
|
|
|
+ (item) =>
|
|
|
+ item.categoryCode === this.categoryInfo.categoryCode
|
|
|
+ );
|
|
|
+ if (preItem) {
|
|
|
+ preCount += preItem.sumReportQuantity * proportion;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
let cumulativeOutputQuantity = 0;
|
|
|
|
|
|
if (this.executeStatus === 2) {
|
|
|
@@ -398,7 +515,9 @@
|
|
|
// const sumReportQuantity = row.sumReportQuantity * proportion;
|
|
|
const sumReportQuantity = row.sumReportQuantity;
|
|
|
|
|
|
- return needQuantity + sumReportQuantity + (row.unit || '');
|
|
|
+ return (
|
|
|
+ needQuantity + preCount + sumReportQuantity + (row.unit || '')
|
|
|
+ );
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -422,6 +541,8 @@
|
|
|
localOutputDetails: [],
|
|
|
// bom配置的 标准产出信息
|
|
|
materialQuotaInfo: null,
|
|
|
+ // 在制品信息
|
|
|
+ categoryInfo: null,
|
|
|
// 产出清单表头
|
|
|
outputDetailsColumns: [
|
|
|
{
|
|
|
@@ -519,11 +640,6 @@
|
|
|
]
|
|
|
};
|
|
|
},
|
|
|
- mounted() {
|
|
|
- if (this.bomCategoryId && this.produceTaskId) {
|
|
|
- this.getMaterialQuotaInfo();
|
|
|
- }
|
|
|
- },
|
|
|
methods: {
|
|
|
// 选择物料
|
|
|
openMaterialModal() {
|
|
|
@@ -582,6 +698,7 @@
|
|
|
|
|
|
this.$emit('update:pickDetails', this.localPickDetails);
|
|
|
},
|
|
|
+ // bom标准产出赋值
|
|
|
setMaterialQuotaInfo() {
|
|
|
console.log('this.materialQuotaInfo', this.materialQuotaInfo);
|
|
|
|
|
|
@@ -707,12 +824,17 @@
|
|
|
|
|
|
this.$emit('update:outputDetails', this.localOutputDetails);
|
|
|
},
|
|
|
- // getCategoryAndLevelByCategoryId 获取产品
|
|
|
+ // getCategoryAndLevelByCategoryId 获取产品 在制品信息
|
|
|
async getCategoryAndLevelByCategoryId() {
|
|
|
const data = await getCategoryAndLevelByCategoryId(this.categoryId);
|
|
|
- if (data) {
|
|
|
+ this.categoryInfo = data;
|
|
|
+ console.log('this.categoryInfo 在制品信息', this.categoryInfo);
|
|
|
+ },
|
|
|
+ // 在制品信息 设置产出物
|
|
|
+ categoryInfoSetOutput() {
|
|
|
+ if (this.categoryInfo) {
|
|
|
const sumItem = this.sumOutputDetails.find(
|
|
|
- (i) => i.categoryCode == data.categoryCode
|
|
|
+ (i) => i.categoryCode == this.categoryInfo.categoryCode
|
|
|
);
|
|
|
|
|
|
let sumQualifiedQuantity = 0;
|
|
|
@@ -727,7 +849,7 @@
|
|
|
|
|
|
this.localOutputDetails = [
|
|
|
{
|
|
|
- ...data,
|
|
|
+ ...this.categoryInfo,
|
|
|
id: null,
|
|
|
reportQuantity: 0,
|
|
|
reportQuantityCopy: 0,
|
|
|
@@ -750,7 +872,6 @@
|
|
|
this.$emit('update:outputDetails', this.localOutputDetails);
|
|
|
|
|
|
console.log('this.localOutputDetails', this.localOutputDetails);
|
|
|
- console.log('this.materialQuotaInfo', this.materialQuotaInfo);
|
|
|
},
|
|
|
// 计算报工数量最大值
|
|
|
reportQuantitymax(row) {
|
|
|
@@ -759,19 +880,75 @@
|
|
|
const pickItem = this.localPickDetails.find(
|
|
|
(item) => item.categoryCode === row.categoryCode
|
|
|
);
|
|
|
- // 物料本身 不能超过已报工数量减领料数量
|
|
|
+
|
|
|
+ // 查询其他工单sumOutputDetails中已产生的bom标准产出和在制品的累计消耗数量
|
|
|
+ let preCount = 0;
|
|
|
+ if (this.materialQuotaInfo) {
|
|
|
+ const materialQuotaItem = this.materialQuotaInfo.materialQuota.find(
|
|
|
+ (item) => item.categoryCode === row.categoryCode
|
|
|
+ );
|
|
|
+
|
|
|
+ if (materialQuotaItem) {
|
|
|
+ // 计算比例
|
|
|
+ const proportion =
|
|
|
+ materialQuotaItem.count / this.materialQuotaInfo.baseCount;
|
|
|
+
|
|
|
+ if (this.materialQuotaInfo.standardOutput) {
|
|
|
+ // BOM标准产出
|
|
|
+ const preItem = this.sumOutputDetails.find(
|
|
|
+ (item) =>
|
|
|
+ item.categoryCode ===
|
|
|
+ this.materialQuotaInfo.standardOutput.categoryCode
|
|
|
+ );
|
|
|
+ if (preItem) {
|
|
|
+ preCount += preItem.sumReportQuantity * proportion;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (this.categoryInfo) {
|
|
|
+ // 在制品
|
|
|
+ const preItem = this.sumOutputDetails.find(
|
|
|
+ (item) => item.categoryCode === this.categoryInfo.categoryCode
|
|
|
+ );
|
|
|
+ if (preItem) {
|
|
|
+ preCount += preItem.sumReportQuantity * proportion;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 未找到物料,则返回剩余数量
|
|
|
+ if (!pickItem) return pickItem.quantity - preCount;
|
|
|
|
|
|
// 已执行,处理重新一键报工时,sumReportQuantity包含了当前报工数量
|
|
|
if (this.executeStatus === 2) {
|
|
|
return (
|
|
|
pickItem.quantity -
|
|
|
- (pickItem.sumReportQuantity - row.reportQuantityCopy)
|
|
|
+ (pickItem.sumReportQuantity - row.reportQuantityCopy) -
|
|
|
+ preCount
|
|
|
);
|
|
|
} else {
|
|
|
- return pickItem.quantity - pickItem.sumReportQuantity;
|
|
|
+ return pickItem.quantity - pickItem.sumReportQuantity - preCount;
|
|
|
}
|
|
|
}
|
|
|
if (row.outputType == 2 || row.outputType == 3) {
|
|
|
+ // 当前行为在制品 和 BOM标准产出
|
|
|
+ const preOutputItem = this.preOutputDetails.find(
|
|
|
+ (item) => item.categoryCode === row.categoryCode
|
|
|
+ );
|
|
|
+
|
|
|
+ // 存在则当前row为在制品或BOM标准产出
|
|
|
+ if (preOutputItem) {
|
|
|
+ // 区分已执行状态
|
|
|
+ if (this.executeStatus === 2) {
|
|
|
+ return (
|
|
|
+ preOutputItem.quantity -
|
|
|
+ (row.sumReportQuantity - row.reportQuantityCopy)
|
|
|
+ );
|
|
|
+ }
|
|
|
+ return preOutputItem.quantity - row.sumReportQuantity;
|
|
|
+ }
|
|
|
+
|
|
|
// 基于物料配额限制最大可报工数量(兼容已缓存/已保存一次的编辑场景,并区分已执行状态)
|
|
|
if (!this.materialQuotaInfo) return Infinity;
|
|
|
const quota = this.materialQuotaInfo.materialQuota || [];
|
|
|
@@ -794,6 +971,41 @@
|
|
|
// 单位产出所需物料比例
|
|
|
const proportion = item.count / baseCount;
|
|
|
|
|
|
+ // 查询其他工单 sumOutputDetails 中已产生的 BOM 标准产出和在制品的累计消耗数量
|
|
|
+ let preOutputConsumedProportion = 0;
|
|
|
+
|
|
|
+ // BOM标准产出
|
|
|
+ if (
|
|
|
+ this.materialQuotaInfo &&
|
|
|
+ this.materialQuotaInfo.standardOutput &&
|
|
|
+ row.categoryCode !==
|
|
|
+ this.materialQuotaInfo.standardOutput.categoryCode
|
|
|
+ ) {
|
|
|
+ const preStd = this.sumOutputDetails.find(
|
|
|
+ (s) =>
|
|
|
+ s.categoryCode ===
|
|
|
+ this.materialQuotaInfo.standardOutput.categoryCode
|
|
|
+ );
|
|
|
+ if (preStd) {
|
|
|
+ preOutputConsumedProportion +=
|
|
|
+ preStd.sumReportQuantity * proportion;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 在制品
|
|
|
+ if (
|
|
|
+ this.categoryInfo &&
|
|
|
+ row.categoryCode !== this.categoryInfo.categoryCode
|
|
|
+ ) {
|
|
|
+ const preWip = this.sumOutputDetails.find(
|
|
|
+ (s) => s.categoryCode === this.categoryInfo.categoryCode
|
|
|
+ );
|
|
|
+ if (preWip) {
|
|
|
+ preOutputConsumedProportion +=
|
|
|
+ preWip.sumReportQuantity * proportion;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 已执行,处理重新一键报工时,sumReportQuantity包含了当前报工数量
|
|
|
let consumedQuantity = isExecuted
|
|
|
? row.sumReportQuantity - row.reportQuantityCopy
|
|
|
@@ -803,8 +1015,11 @@
|
|
|
const consumedProportion = consumedQuantity * proportion;
|
|
|
|
|
|
// 最大可报工数量
|
|
|
- const maxQuantity =
|
|
|
- (pickItem.quantity - consumedProportion) / proportion;
|
|
|
+ let maxQuantity =
|
|
|
+ (pickItem.quantity -
|
|
|
+ consumedProportion -
|
|
|
+ preOutputConsumedProportion) /
|
|
|
+ proportion;
|
|
|
|
|
|
// 向下取整
|
|
|
return Math.floor(maxQuantity);
|