|
|
@@ -122,7 +122,8 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
//切换检验方式
|
|
|
- changeModel(val) {
|
|
|
+ changeModel(val,flag) {
|
|
|
+ debugger
|
|
|
this.form.qualityMode = val;
|
|
|
//检验方式 全检
|
|
|
if (this.form.qualityMode == 1) {
|
|
|
@@ -136,52 +137,56 @@ export default {
|
|
|
this.getProSamList(this.packingList)
|
|
|
|
|
|
} else {
|
|
|
- this.sampleList = [];
|
|
|
+ if (!flag){
|
|
|
+ this.sampleList = [];
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
//根据类型判断样品清单现实列表数据
|
|
|
getProSamList(list) {
|
|
|
//生产检验
|
|
|
- if (this.qualityType == '2') {
|
|
|
- const ProductSampleList = [];
|
|
|
- console.log(list, 'list')
|
|
|
- list.forEach(oldItem => {
|
|
|
- const count = oldItem.measureQuantity;
|
|
|
- const newMeasureQuantity = oldItem.measureQuantity / count;
|
|
|
- const newWeight = parseFloat((oldItem.weight / count).toFixed(2))
|
|
|
+ if (this.qualityType == '2' ) {
|
|
|
+ if (this.form.qualityMode != null){
|
|
|
+ const ProductSampleList = [];
|
|
|
+ console.log(list, 'list')
|
|
|
+ list.forEach(oldItem => {
|
|
|
+ const count = oldItem.measureQuantity;
|
|
|
+ const newMeasureQuantity = oldItem.measureQuantity / count;
|
|
|
+ const newWeight = parseFloat((oldItem.weight / count).toFixed(2))
|
|
|
|
|
|
- console.log(typeof (oldItem.qualitySampleTemplateList), 'ssssss')
|
|
|
+ console.log(typeof (oldItem.qualitySampleTemplateList), 'ssssss')
|
|
|
|
|
|
- if (oldItem.qualitySampleTemplateList == undefined || oldItem.qualitySampleTemplateList == null) {
|
|
|
- oldItem.qualitySampleTemplateList = JSON.parse(JSON.stringify(this.schemeList))
|
|
|
- }
|
|
|
- console.log(oldItem, 'oldItem')
|
|
|
- console.log(count, newMeasureQuantity, newWeight)
|
|
|
- delete oldItem.id;
|
|
|
+ // 遍历新数组设置 qualityResults 默认值
|
|
|
+ this.schemeList.forEach(item => {
|
|
|
+ if (typeof item === 'object' && item !== null) {
|
|
|
+ item.qualityResults = 1; // 设置默认值
|
|
|
+ }
|
|
|
+ delete item.id;
|
|
|
+ });
|
|
|
|
|
|
- // 遍历新数组设置 qualityResults 默认值
|
|
|
- this.schemeList.forEach(item => {
|
|
|
- if (typeof item === 'object' && item !== null) {
|
|
|
- item.qualityResults = 1; // 设置默认值
|
|
|
+ console.log(oldItem, 'oldItem')
|
|
|
+ console.log(count, newMeasureQuantity, newWeight)
|
|
|
+ delete oldItem.id;
|
|
|
+
|
|
|
+ if (oldItem.qualitySampleTemplateList == undefined || oldItem.qualitySampleTemplateList == null || oldItem.qualitySampleTemplateList.length == 0) {
|
|
|
+ oldItem.qualitySampleTemplateList = JSON.parse(JSON.stringify(this.schemeList))
|
|
|
+ for (let i = 0; i < count; i++) {
|
|
|
+ ProductSampleList.push({
|
|
|
+ ...oldItem,
|
|
|
+ measureQuantity: newMeasureQuantity,
|
|
|
+ weight: newWeight,
|
|
|
+ qualitySampleTemplateList: JSON.parse(JSON.stringify(this.schemeList))
|
|
|
+ });
|
|
|
+ }
|
|
|
+ console.log(ProductSampleList, 'ProductSampleList')
|
|
|
+ this.sampleList = ProductSampleList;
|
|
|
+ const pNum = ProductSampleList.reduce((sum, item) => {
|
|
|
+ return sum + Number(item.weight || 0);
|
|
|
+ }, 0);
|
|
|
+ this.form.totalWeight = parseFloat(pNum.toFixed(2));
|
|
|
}
|
|
|
- delete item.id;
|
|
|
});
|
|
|
-
|
|
|
- for (let i = 0; i < count; i++) {
|
|
|
- ProductSampleList.push({
|
|
|
- ...oldItem,
|
|
|
- measureQuantity: newMeasureQuantity,
|
|
|
- weight: newWeight,
|
|
|
- // qualitySampleTemplateList: JSON.parse(JSON.stringify(this.schemeList))
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- console.log(ProductSampleList, 'ProductSampleList')
|
|
|
- this.sampleList = ProductSampleList;
|
|
|
- const pNum = ProductSampleList.reduce((sum, item) => {
|
|
|
- return sum + Number(item.weight || 0);
|
|
|
- }, 0);
|
|
|
- this.form.totalWeight = parseFloat(pNum.toFixed(2));
|
|
|
+ }
|
|
|
} else {
|
|
|
this.sampleList = list;
|
|
|
}
|
|
|
@@ -211,12 +216,19 @@ export default {
|
|
|
const newWeight = parseFloat((oldItem.weight / count).toFixed(2))
|
|
|
console.log(count, newMeasureQuantity, newWeight)
|
|
|
delete oldItem.id;
|
|
|
-
|
|
|
+ // 遍历新数组设置 qualityResults 默认值
|
|
|
+ this.schemeList.forEach(item => {
|
|
|
+ if (typeof item === 'object' && item !== null) {
|
|
|
+ item.qualityResults = 1; // 设置默认值
|
|
|
+ }
|
|
|
+ delete item.id;
|
|
|
+ });
|
|
|
for (let i = 0; i < val; i++) {
|
|
|
ProductSampleList.push({
|
|
|
...oldItem,
|
|
|
measureQuantity: newMeasureQuantity,
|
|
|
- weight: newWeight
|
|
|
+ weight: newWeight,
|
|
|
+ qualitySampleTemplateList: JSON.parse(JSON.stringify(this.schemeList))
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
@@ -347,7 +359,7 @@ export default {
|
|
|
console.log(addStatus, '样品清单12123123')
|
|
|
|
|
|
if (addStatus.length > 0) {
|
|
|
- this.getProSamList(addStatus)
|
|
|
+ this.sampleList = addStatus;
|
|
|
} else {
|
|
|
this.getProSamList(this.packingList)
|
|
|
}
|
|
|
@@ -512,13 +524,8 @@ export default {
|
|
|
item.qualityResults = 2;
|
|
|
}
|
|
|
else {
|
|
|
- if (item.qualitySampleTemplateList.some(child => child.qualityResults === 1)) {
|
|
|
- item.isValid = true;
|
|
|
- item.qualityResults = 1;
|
|
|
- } else {
|
|
|
- item.isValid = true;
|
|
|
- item.qualityResults = 3;
|
|
|
- }
|
|
|
+ item.isValid = true;
|
|
|
+ item.qualityResults = 1;
|
|
|
}
|
|
|
item.qualityStatus = 1;
|
|
|
})
|