|
@@ -193,28 +193,17 @@
|
|
|
//切换检验方式
|
|
//切换检验方式
|
|
|
changeModel(val, flag) {
|
|
changeModel(val, flag) {
|
|
|
console.log('切换检验方式');
|
|
console.log('切换检验方式');
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
this.$refs.tabsRef.tableSelClear();
|
|
this.$refs.tabsRef.tableSelClear();
|
|
|
this.sampleList = [];
|
|
this.sampleList = [];
|
|
|
this.$refs.tabsRef.tabsChange('1');
|
|
this.$refs.tabsRef.tabsChange('1');
|
|
|
this.$refs.tabsRef.tabsConditionType(null);
|
|
this.$refs.tabsRef.tabsConditionType(null);
|
|
|
-
|
|
|
|
|
this.form.qualityMode = val;
|
|
this.form.qualityMode = val;
|
|
|
//检验方式 全检
|
|
//检验方式 全检
|
|
|
if (this.form.qualityMode == 1) {
|
|
if (this.form.qualityMode == 1) {
|
|
|
this.activeName = '2';
|
|
this.activeName = '2';
|
|
|
this.form.sampleNumber = '';
|
|
this.form.sampleNumber = '';
|
|
|
- const sData = this.$refs.tabsRef.$refs.sourceTable.getData();
|
|
|
|
|
- if (sData.length == 0) {
|
|
|
|
|
- for (let i = 0; i < sData.length; i++) {
|
|
|
|
|
- this.$set(sData[i], 'qualityStatus', 2);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- console.log(
|
|
|
|
|
- this.$refs.tabsRef.$refs.sourceTable.getData(),
|
|
|
|
|
- 'packingList'
|
|
|
|
|
- );
|
|
|
|
|
- this.getProSamList(sData);
|
|
|
|
|
|
|
+ this.changeGetSampleList(this.inventoryList);
|
|
|
} else {
|
|
} else {
|
|
|
this.activeName = '1';
|
|
this.activeName = '1';
|
|
|
if (!flag) {
|
|
if (!flag) {
|
|
@@ -299,6 +288,129 @@
|
|
|
this.sampleList = this.addStatus;
|
|
this.sampleList = this.addStatus;
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
+ // 创建计量数量为1的样品清单函数,用于计数类型的
|
|
|
|
|
+ async createSampleList(list) {
|
|
|
|
|
+ if (this.form.qualityMode != null) {
|
|
|
|
|
+ const ProductSampleList = [];
|
|
|
|
|
+ console.log(list, 'list');
|
|
|
|
|
+ for (const oldItem of list) {
|
|
|
|
|
+ const count = oldItem.measureQuantity;
|
|
|
|
|
+ const newMeasureQuantity = oldItem.measureQuantity / count;
|
|
|
|
|
+ const newWeight = parseFloat((oldItem.weight / count).toFixed(2));
|
|
|
|
|
+
|
|
|
|
|
+ console.log(typeof oldItem.qualitySampleTemplateList, 'ssssss');
|
|
|
|
|
+
|
|
|
|
|
+ // 遍历新数组设置 qualityResults 默认值
|
|
|
|
|
+ this.schemeList.forEach((item) => {
|
|
|
|
|
+ if (typeof item === 'object' && item !== null) {
|
|
|
|
|
+ item.qualityResults = 1; // 设置默认值
|
|
|
|
|
+ }
|
|
|
|
|
+ delete item.id;
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ 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,
|
|
|
|
|
+ sampleCode: await this.getSampleCode(),
|
|
|
|
|
+ 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 {
|
|
|
|
|
+ for (let i = 0; i < count; i++) {
|
|
|
|
|
+ ProductSampleList.push({
|
|
|
|
|
+ ...oldItem,
|
|
|
|
|
+ measureQuantity: newMeasureQuantity,
|
|
|
|
|
+ weight: newWeight,
|
|
|
|
|
+ sampleCode: await this.getSampleCode(),
|
|
|
|
|
+ qualitySampleTemplateList: JSON.parse(
|
|
|
|
|
+ JSON.stringify(oldItem.qualitySampleTemplateList)
|
|
|
|
|
+ )
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ 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));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ // 全检计量计重的样品清单函数
|
|
|
|
|
+ async updatePackingList(list, sampleCount) {
|
|
|
|
|
+ // for (let i = 0; i < list.length; i++) {
|
|
|
|
|
+ // list[i].sampleCode = await this.getSampleCode();
|
|
|
|
|
+ // }
|
|
|
|
|
+
|
|
|
|
|
+ const dataList = [];
|
|
|
|
|
+ let currentNum = sampleCount - list.length;
|
|
|
|
|
+ let currentNum1 = sampleCount;
|
|
|
|
|
+ // console.log(this.selectedList);
|
|
|
|
|
+
|
|
|
|
|
+ for (const item of list) {
|
|
|
|
|
+ const qualitySampleTemplateList = item.qualitySampleTemplateList
|
|
|
|
|
+ ?.length
|
|
|
|
|
+ ? JSON.parse(JSON.stringify(item.qualitySampleTemplateList))
|
|
|
|
|
+ : JSON.parse(
|
|
|
|
|
+ JSON.stringify(
|
|
|
|
|
+ this.schemeList.map((item) => {
|
|
|
|
|
+ item['qualityResults'] = 1;
|
|
|
|
|
+ return item;
|
|
|
|
|
+ })
|
|
|
|
|
+ )
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ if (sampleCount >= list.length) {
|
|
|
|
|
+ dataList.push({
|
|
|
|
|
+ ...item,
|
|
|
|
|
+ measureQuantity: item.measureQuantity, //作为计量数量
|
|
|
|
|
+ sampleCode: await this.getSampleCode(),
|
|
|
|
|
+ qualitySampleTemplateList
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ this.sampleList = dataList;
|
|
|
|
|
+ this.sampleNumber = this.sampleList.length;
|
|
|
|
|
+ },
|
|
|
|
|
+ // 切换检验方式为全检后生成样品
|
|
|
|
|
+ changeGetSampleList(list) {
|
|
|
|
|
+ console.log(list);
|
|
|
|
|
+ console.log(this.form.total);
|
|
|
|
|
+
|
|
|
|
|
+ // 计量类型1是数量,2是重量
|
|
|
|
|
+ if (this.form.inspectionStandards == 1) {
|
|
|
|
|
+ this.createSampleList(list);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (this.form.inspectionStandards == 2) {
|
|
|
|
|
+ this.updatePackingList(list, this.form.total);
|
|
|
|
|
+ // this.handleWeightFullSample(this.form.total);
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
//输入取样数量
|
|
//输入取样数量
|
|
|
changeNumber(val) {
|
|
changeNumber(val) {
|
|
|
if (this.form.qualityMode !== 2) {
|
|
if (this.form.qualityMode !== 2) {
|
|
@@ -470,6 +582,7 @@
|
|
|
// await this.queryQualityInventory()
|
|
// await this.queryQualityInventory()
|
|
|
// 质检方案
|
|
// 质检方案
|
|
|
await this.queryQualityTempleContent();
|
|
await this.queryQualityTempleContent();
|
|
|
|
|
+ // 样品清单
|
|
|
await this.queryQualitySamplContent();
|
|
await this.queryQualitySamplContent();
|
|
|
// 来源清单
|
|
// 来源清单
|
|
|
await this.getQueryQualityInventory();
|
|
await this.getQueryQualityInventory();
|
|
@@ -615,7 +728,7 @@
|
|
|
console.log(222222222222222222);
|
|
console.log(222222222222222222);
|
|
|
await this.handleWeightFullSample(sampleCount);
|
|
await this.handleWeightFullSample(sampleCount);
|
|
|
}
|
|
}
|
|
|
- this.activeName = '2';
|
|
|
|
|
|
|
+ this.activeName = '2';
|
|
|
|
|
|
|
|
this.$refs.tabsRef.tabsChange('2');
|
|
this.$refs.tabsRef.tabsChange('2');
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
@@ -798,8 +911,7 @@
|
|
|
delete this.form['qualityTimeEnd'];
|
|
delete this.form['qualityTimeEnd'];
|
|
|
|
|
|
|
|
console.log(this.sampleList);
|
|
console.log(this.sampleList);
|
|
|
- // return
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
let params = {
|
|
let params = {
|
|
|
...this.form,
|
|
...this.form,
|
|
@@ -810,6 +922,7 @@
|
|
|
qualityInventoryList: this.inventoryList
|
|
qualityInventoryList: this.inventoryList
|
|
|
};
|
|
};
|
|
|
console.log(params, 'params ----');
|
|
console.log(params, 'params ----');
|
|
|
|
|
+
|
|
|
URL(params)
|
|
URL(params)
|
|
|
.then((msg) => {
|
|
.then((msg) => {
|
|
|
this.loading = false;
|
|
this.loading = false;
|
|
@@ -1301,9 +1414,13 @@
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
async handleWeightFullSample(sampleCount) {
|
|
async handleWeightFullSample(sampleCount) {
|
|
|
|
|
+ console.log(sampleCount);
|
|
|
|
|
+
|
|
|
const dataList = [];
|
|
const dataList = [];
|
|
|
let currentNum = sampleCount - this.selectedList.length;
|
|
let currentNum = sampleCount - this.selectedList.length;
|
|
|
let currentNum1 = sampleCount;
|
|
let currentNum1 = sampleCount;
|
|
|
|
|
+ console.log(this.selectedList);
|
|
|
|
|
+
|
|
|
for (const item of this.selectedList) {
|
|
for (const item of this.selectedList) {
|
|
|
const qualitySampleTemplateList = item.qualitySampleTemplateList
|
|
const qualitySampleTemplateList = item.qualitySampleTemplateList
|
|
|
?.length
|
|
?.length
|