|
@@ -45,7 +45,7 @@
|
|
|
controls-position="right"
|
|
controls-position="right"
|
|
|
:min="0"
|
|
:min="0"
|
|
|
:max="reportQuantitymax(row)"
|
|
:max="reportQuantitymax(row)"
|
|
|
- @change="$emit('update:outputDetails', localOutputDetails)"
|
|
|
|
|
|
|
+ @change="reportQuantityChange(row)"
|
|
|
></el-input-number>
|
|
></el-input-number>
|
|
|
</template>
|
|
</template>
|
|
|
<template v-slot:qualifiedQuantity="{ row }">
|
|
<template v-slot:qualifiedQuantity="{ row }">
|
|
@@ -65,7 +65,7 @@
|
|
|
controls-position="right"
|
|
controls-position="right"
|
|
|
:min="0"
|
|
:min="0"
|
|
|
:max="noQualifiedQuantityMax(row)"
|
|
:max="noQualifiedQuantityMax(row)"
|
|
|
- @change="$emit('update:outputDetails', localOutputDetails)"
|
|
|
|
|
|
|
+ @change="noQualifiedQuantityChange(row)"
|
|
|
></el-input-number>
|
|
></el-input-number>
|
|
|
</template>
|
|
</template>
|
|
|
<template v-slot:msg="{ row }">
|
|
<template v-slot:msg="{ row }">
|
|
@@ -110,6 +110,10 @@
|
|
|
type: Array,
|
|
type: Array,
|
|
|
default: () => []
|
|
default: () => []
|
|
|
},
|
|
},
|
|
|
|
|
+ sumOutputDetails: {
|
|
|
|
|
+ type: Array,
|
|
|
|
|
+ default: () => []
|
|
|
|
|
+ },
|
|
|
// 工单id
|
|
// 工单id
|
|
|
workOrderId: {
|
|
workOrderId: {
|
|
|
type: [String, Number],
|
|
type: [String, Number],
|
|
@@ -149,6 +153,11 @@
|
|
|
categoryId: {
|
|
categoryId: {
|
|
|
type: [String, Number],
|
|
type: [String, Number],
|
|
|
required: false
|
|
required: false
|
|
|
|
|
+ },
|
|
|
|
|
+ // recordId 是否保存过数据
|
|
|
|
|
+ recordId: {
|
|
|
|
|
+ type: [String, Number],
|
|
|
|
|
+ default: ''
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
watch: {
|
|
watch: {
|
|
@@ -201,7 +210,7 @@
|
|
|
this.getCategoryAndLevelByCategoryId();
|
|
this.getCategoryAndLevelByCategoryId();
|
|
|
} else {
|
|
} else {
|
|
|
// 3 BOM标准产出
|
|
// 3 BOM标准产出
|
|
|
- this.getMaterialQuotaInfo();
|
|
|
|
|
|
|
+ this.setMaterialQuotaInfo();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
@@ -292,13 +301,40 @@
|
|
|
prop: '',
|
|
prop: '',
|
|
|
minWidth: 120,
|
|
minWidth: 120,
|
|
|
formatter: (row) => {
|
|
formatter: (row) => {
|
|
|
- // 取值产出清单
|
|
|
|
|
- const outputItem = this.localOutputDetails.find(
|
|
|
|
|
- (item) => item.categoryId === row.categoryId
|
|
|
|
|
- );
|
|
|
|
|
- return (
|
|
|
|
|
- (outputItem ? outputItem.reportQuantity : 0) + (row.unit || '')
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ // 产出为物料
|
|
|
|
|
+ if (this.outputType == 1) {
|
|
|
|
|
+ // 取值产出清单
|
|
|
|
|
+ const outputItem = this.localOutputDetails.find(
|
|
|
|
|
+ (item) => item.categoryId === row.categoryId
|
|
|
|
|
+ );
|
|
|
|
|
+ return (
|
|
|
|
|
+ (outputItem ? outputItem.reportQuantity : 0) +
|
|
|
|
|
+ (row.unit || '')
|
|
|
|
|
+ );
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 产出为在制品 或 BOM标准产出
|
|
|
|
|
+ // 查询基数
|
|
|
|
|
+ if (!this.materialQuotaInfo) {
|
|
|
|
|
+ return '0' + (row.unit || '');
|
|
|
|
|
+ }
|
|
|
|
|
+ const materialItem = this.materialQuotaInfo.materialQuota.find(
|
|
|
|
|
+ (item) => item.id === row.categoryId
|
|
|
|
|
+ );
|
|
|
|
|
+ if (!materialItem) {
|
|
|
|
|
+ return '0' + (row.unit || '');
|
|
|
|
|
+ }
|
|
|
|
|
+ // 需要的物料数量比例
|
|
|
|
|
+ let count =
|
|
|
|
|
+ materialItem.count / this.materialQuotaInfo.baseCount;
|
|
|
|
|
+ // 产出清单的报工数量 当次报工+累计报工
|
|
|
|
|
+ const outputItem = this.localOutputDetails[0];
|
|
|
|
|
+ if (!outputItem) {
|
|
|
|
|
+ return '0' + (row.unit || '');
|
|
|
|
|
+ }
|
|
|
|
|
+ // 当次消耗
|
|
|
|
|
+ let needQuantity = outputItem.reportQuantity * count;
|
|
|
|
|
+ return needQuantity + (row.unit || '');
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
@@ -306,15 +342,60 @@
|
|
|
prop: '',
|
|
prop: '',
|
|
|
minWidth: 120,
|
|
minWidth: 120,
|
|
|
formatter: (row) => {
|
|
formatter: (row) => {
|
|
|
- const outputItem = this.localOutputDetails.find(
|
|
|
|
|
- (item) => item.categoryId === row.categoryId
|
|
|
|
|
- );
|
|
|
|
|
- if (!outputItem) {
|
|
|
|
|
- return '0' + (row.unit || '');
|
|
|
|
|
|
|
+ if (this.outputType == 1) {
|
|
|
|
|
+ const outputItem = this.localOutputDetails.find(
|
|
|
|
|
+ (item) => item.categoryId === row.categoryId
|
|
|
|
|
+ );
|
|
|
|
|
+ if (!outputItem) {
|
|
|
|
|
+ return '0' + (row.unit || '');
|
|
|
|
|
+ }
|
|
|
|
|
+ if (this.recordId) {
|
|
|
|
|
+ let count =
|
|
|
|
|
+ outputItem.sumReportQuantity +
|
|
|
|
|
+ outputItem.reportQuantity -
|
|
|
|
|
+ outputItem.reportQuantityCopy;
|
|
|
|
|
+ return count + (row.unit || '');
|
|
|
|
|
+ } else {
|
|
|
|
|
+ let count =
|
|
|
|
|
+ outputItem.sumReportQuantity + outputItem.reportQuantity;
|
|
|
|
|
+ return count + (row.unit || '');
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 产出为在制品 或 BOM标准产出
|
|
|
|
|
+ // 查询基数
|
|
|
|
|
+ if (!this.materialQuotaInfo) {
|
|
|
|
|
+ return '0' + (row.unit || '');
|
|
|
|
|
+ }
|
|
|
|
|
+ const materialItem = this.materialQuotaInfo.materialQuota.find(
|
|
|
|
|
+ (item) => item.id === row.categoryId
|
|
|
|
|
+ );
|
|
|
|
|
+ if (!materialItem) {
|
|
|
|
|
+ return '0' + (row.unit || '');
|
|
|
|
|
+ }
|
|
|
|
|
+ // 需要的物料数量比例
|
|
|
|
|
+ let count =
|
|
|
|
|
+ materialItem.count / this.materialQuotaInfo.baseCount;
|
|
|
|
|
+ // 产出清单的报工数量 当次报工+累计报工
|
|
|
|
|
+ const outputItem = this.localOutputDetails[0];
|
|
|
|
|
+ if (!outputItem) {
|
|
|
|
|
+ return '0' + (row.unit || '');
|
|
|
|
|
+ }
|
|
|
|
|
+ if (this.recordId) {
|
|
|
|
|
+ // 累计消耗
|
|
|
|
|
+ let needQuantity =
|
|
|
|
|
+ (outputItem.sumReportQuantity +
|
|
|
|
|
+ outputItem.reportQuantity -
|
|
|
|
|
+ outputItem.reportQuantityCopy) *
|
|
|
|
|
+ count;
|
|
|
|
|
+ return needQuantity + (row.unit || '');
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 累计消耗
|
|
|
|
|
+ let needQuantity =
|
|
|
|
|
+ (outputItem.sumReportQuantity + outputItem.reportQuantity) *
|
|
|
|
|
+ count;
|
|
|
|
|
+ return needQuantity + (row.unit || '');
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- let count =
|
|
|
|
|
- outputItem.sumReportQuantity + outputItem.reportQuantity;
|
|
|
|
|
- return count + (row.unit || '');
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
];
|
|
];
|
|
@@ -434,7 +515,11 @@
|
|
|
]
|
|
]
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
|
- mounted() {},
|
|
|
|
|
|
|
+ mounted() {
|
|
|
|
|
+ if (this.bomCategoryId && this.produceTaskId) {
|
|
|
|
|
+ this.getMaterialQuotaInfo();
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
methods: {
|
|
methods: {
|
|
|
// 选择物料
|
|
// 选择物料
|
|
|
openMaterialModal() {
|
|
openMaterialModal() {
|
|
@@ -461,9 +546,20 @@
|
|
|
// 存在则替换数量
|
|
// 存在则替换数量
|
|
|
this.localPickDetails[index].quantity = newItem.quantity;
|
|
this.localPickDetails[index].quantity = newItem.quantity;
|
|
|
} else {
|
|
} else {
|
|
|
|
|
+ const sumItem = this.sumOutputDetails.find(
|
|
|
|
|
+ (i) => i.categoryId === i.categoryId
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ let reportQuantity = newItem.reportQuantity || 0;
|
|
|
|
|
+
|
|
|
|
|
+ if (sumItem) {
|
|
|
|
|
+ reportQuantity = sumItem.reportQuantity;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 不存在则添加
|
|
// 不存在则添加
|
|
|
this.localPickDetails.push({
|
|
this.localPickDetails.push({
|
|
|
...newItem,
|
|
...newItem,
|
|
|
|
|
+ reportQuantity,
|
|
|
ruleId: this.ruleId,
|
|
ruleId: this.ruleId,
|
|
|
bomCategoryId: this.bomCategoryId,
|
|
bomCategoryId: this.bomCategoryId,
|
|
|
produceTaskId: this.produceTaskId,
|
|
produceTaskId: this.produceTaskId,
|
|
@@ -476,6 +572,43 @@
|
|
|
|
|
|
|
|
this.$emit('update:pickDetails', this.localPickDetails);
|
|
this.$emit('update:pickDetails', this.localPickDetails);
|
|
|
},
|
|
},
|
|
|
|
|
+ setMaterialQuotaInfo() {
|
|
|
|
|
+ console.log('this.materialQuotaInfo', this.materialQuotaInfo);
|
|
|
|
|
+ if (this.materialQuotaInfo && this.materialQuotaInfo.standardOutput) {
|
|
|
|
|
+ const sumItem = this.sumOutputDetails.find(
|
|
|
|
|
+ (i) =>
|
|
|
|
|
+ i.categoryId === this.materialQuotaInfo.standardOutput.categoryId
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ let reportQuantity = 0;
|
|
|
|
|
+
|
|
|
|
|
+ if (sumItem) {
|
|
|
|
|
+ reportQuantity = sumItem.reportQuantity;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 赋值产出
|
|
|
|
|
+ this.localOutputDetails = [
|
|
|
|
|
+ {
|
|
|
|
|
+ ...this.materialQuotaInfo.standardOutput,
|
|
|
|
|
+ id: null,
|
|
|
|
|
+ reportQuantity,
|
|
|
|
|
+ qualifiedQuantity: 0,
|
|
|
|
|
+ noQualifiedQuantity: 0,
|
|
|
|
|
+ msg: '',
|
|
|
|
|
+ sumReportQuantity: 0,
|
|
|
|
|
+ sumQualifiedQuantity: 0,
|
|
|
|
|
+ sumNoQualifiedQuantity: 0,
|
|
|
|
|
+ ruleId: this.ruleId,
|
|
|
|
|
+ outputType: this.outputType,
|
|
|
|
|
+ produceTaskId: this.produceTaskId,
|
|
|
|
|
+ produceTaskInstanceId: this.produceTaskInstanceId,
|
|
|
|
|
+ produceTaskName: this.produceTaskName,
|
|
|
|
|
+ workOrderId: this.workOrderId
|
|
|
|
|
+ }
|
|
|
|
|
+ ];
|
|
|
|
|
+ this.$emit('update:outputDetails', this.localOutputDetails);
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
// 获取bom的产出清单
|
|
// 获取bom的产出清单
|
|
|
async getMaterialQuotaInfo() {
|
|
async getMaterialQuotaInfo() {
|
|
|
if (this.bomCategoryId && this.produceTaskId) {
|
|
if (this.bomCategoryId && this.produceTaskId) {
|
|
@@ -485,32 +618,6 @@
|
|
|
);
|
|
);
|
|
|
console.log('this.materialQuotaInfo', data);
|
|
console.log('this.materialQuotaInfo', data);
|
|
|
this.materialQuotaInfo = data;
|
|
this.materialQuotaInfo = data;
|
|
|
- //
|
|
|
|
|
- if (data && data.standardOutput) {
|
|
|
|
|
- // 赋值产出
|
|
|
|
|
- this.localOutputDetails = [
|
|
|
|
|
- {
|
|
|
|
|
- ...data.standardOutput,
|
|
|
|
|
- id: null,
|
|
|
|
|
- reportQuantity: 0,
|
|
|
|
|
- qualifiedQuantity: 0,
|
|
|
|
|
- noQualifiedQuantity: 0,
|
|
|
|
|
- msg: '',
|
|
|
|
|
- sumReportQuantity: 0,
|
|
|
|
|
- sumQualifiedQuantity: 0,
|
|
|
|
|
- sumNoQualifiedQuantity: 0,
|
|
|
|
|
- ruleId: this.ruleId,
|
|
|
|
|
- outputType: this.outputType,
|
|
|
|
|
- produceTaskId: this.produceTaskId,
|
|
|
|
|
- produceTaskInstanceId: this.produceTaskInstanceId,
|
|
|
|
|
- produceTaskName: this.produceTaskName,
|
|
|
|
|
- workOrderId: this.workOrderId
|
|
|
|
|
- }
|
|
|
|
|
- ];
|
|
|
|
|
- this.$emit('update:outputDetails', this.localOutputDetails);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- console.log('this.localOutputDetails', this.localOutputDetails);
|
|
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
// qualifiedQuantityMax 最大合格数量
|
|
// qualifiedQuantityMax 最大合格数量
|
|
@@ -518,7 +625,7 @@
|
|
|
return row.reportQuantity;
|
|
return row.reportQuantity;
|
|
|
},
|
|
},
|
|
|
noQualifiedQuantityMax(row) {
|
|
noQualifiedQuantityMax(row) {
|
|
|
- return row.reportQuantity - row.qualifiedQuantity;
|
|
|
|
|
|
|
+ return row.reportQuantity;
|
|
|
},
|
|
},
|
|
|
selectedChange(row) {
|
|
selectedChange(row) {
|
|
|
console.log('row', row);
|
|
console.log('row', row);
|
|
@@ -568,11 +675,21 @@
|
|
|
async getCategoryAndLevelByCategoryId() {
|
|
async getCategoryAndLevelByCategoryId() {
|
|
|
const data = await getCategoryAndLevelByCategoryId(this.categoryId);
|
|
const data = await getCategoryAndLevelByCategoryId(this.categoryId);
|
|
|
if (data) {
|
|
if (data) {
|
|
|
|
|
+ const sumItem = this.sumOutputDetails.find(
|
|
|
|
|
+ (i) => i.categoryId == data.categoryId
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ let reportQuantity = 0;
|
|
|
|
|
+
|
|
|
|
|
+ if (sumItem) {
|
|
|
|
|
+ reportQuantity = sumItem.reportQuantity;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
this.localOutputDetails = [
|
|
this.localOutputDetails = [
|
|
|
{
|
|
{
|
|
|
...data,
|
|
...data,
|
|
|
id: null,
|
|
id: null,
|
|
|
- reportQuantity: 0,
|
|
|
|
|
|
|
+ reportQuantity,
|
|
|
qualifiedQuantity: 0,
|
|
qualifiedQuantity: 0,
|
|
|
noQualifiedQuantity: 0,
|
|
noQualifiedQuantity: 0,
|
|
|
msg: '',
|
|
msg: '',
|
|
@@ -591,11 +708,6 @@
|
|
|
|
|
|
|
|
this.$emit('update:outputDetails', this.localOutputDetails);
|
|
this.$emit('update:outputDetails', this.localOutputDetails);
|
|
|
|
|
|
|
|
- const bomInfo = await getMaterialQuotaInfo(
|
|
|
|
|
- this.bomCategoryId,
|
|
|
|
|
- this.produceTaskId
|
|
|
|
|
- );
|
|
|
|
|
- this.materialQuotaInfo = bomInfo;
|
|
|
|
|
console.log('this.localOutputDetails', this.localOutputDetails);
|
|
console.log('this.localOutputDetails', this.localOutputDetails);
|
|
|
console.log('this.materialQuotaInfo', this.materialQuotaInfo);
|
|
console.log('this.materialQuotaInfo', this.materialQuotaInfo);
|
|
|
},
|
|
},
|
|
@@ -673,18 +785,11 @@
|
|
|
let val = true;
|
|
let val = true;
|
|
|
|
|
|
|
|
if (!this.materialQuotaInfo) {
|
|
if (!this.materialQuotaInfo) {
|
|
|
- this.materialQuotaInfo = await getMaterialQuotaInfo(
|
|
|
|
|
- this.bomCategoryId,
|
|
|
|
|
- this.produceTaskId
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ await this.getMaterialQuotaInfo();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 没有配置产出清单 、没有原材料 不检查
|
|
// 没有配置产出清单 、没有原材料 不检查
|
|
|
- if (
|
|
|
|
|
- !this.materialQuotaInfo ||
|
|
|
|
|
- !this.materialQuotaInfo.standardOutput ||
|
|
|
|
|
- this.localPickDetails.length == 0
|
|
|
|
|
- ) {
|
|
|
|
|
|
|
+ if (!this.materialQuotaInfo || this.localPickDetails.length == 0) {
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -769,18 +874,31 @@
|
|
|
|
|
|
|
|
return true;
|
|
return true;
|
|
|
},
|
|
},
|
|
|
|
|
+ // 当次报工修改
|
|
|
|
|
+ reportQuantityChange(row) {
|
|
|
|
|
+ // 同步当前合格数量 和 不合格数量为0
|
|
|
|
|
+ // 默认全部合格
|
|
|
|
|
+ row.qualifiedQuantity = row.reportQuantity;
|
|
|
|
|
+ row.noQualifiedQuantity = 0;
|
|
|
|
|
+ this.$emit('update:outputDetails', this.localOutputDetails);
|
|
|
|
|
+ },
|
|
|
// qualifiedQuantityChange 当次合格数量变化 计算 noQualifiedQuantity不合格数量
|
|
// qualifiedQuantityChange 当次合格数量变化 计算 noQualifiedQuantity不合格数量
|
|
|
qualifiedQuantityChange(row) {
|
|
qualifiedQuantityChange(row) {
|
|
|
row.noQualifiedQuantity = row.reportQuantity - row.qualifiedQuantity;
|
|
row.noQualifiedQuantity = row.reportQuantity - row.qualifiedQuantity;
|
|
|
this.$emit('update:outputDetails', this.localOutputDetails);
|
|
this.$emit('update:outputDetails', this.localOutputDetails);
|
|
|
},
|
|
},
|
|
|
|
|
+ // 不合格数量变化
|
|
|
|
|
+ noQualifiedQuantityChange(row) {
|
|
|
|
|
+ row.qualifiedQuantity = row.reportQuantity - row.noQualifiedQuantity;
|
|
|
|
|
+ this.$emit('update:outputDetails', this.localOutputDetails);
|
|
|
|
|
+ },
|
|
|
localOutputDetailsRefresh() {
|
|
localOutputDetailsRefresh() {
|
|
|
if (this.outputType == 1) {
|
|
if (this.outputType == 1) {
|
|
|
this.$emit('refresh', 'output');
|
|
this.$emit('refresh', 'output');
|
|
|
} else if (this.outputType == 2) {
|
|
} else if (this.outputType == 2) {
|
|
|
this.getCategoryAndLevelByCategoryId();
|
|
this.getCategoryAndLevelByCategoryId();
|
|
|
} else {
|
|
} else {
|
|
|
- this.getMaterialQuotaInfo();
|
|
|
|
|
|
|
+ this.setMaterialQuotaInfo();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|