|
|
@@ -128,7 +128,7 @@
|
|
|
:selection.sync="selection"
|
|
|
>
|
|
|
<template v-slot:toolbar>
|
|
|
- 累计取样数量:{{ workSampleQuantity }}{{ form.unit }}
|
|
|
+ 累计取样数量:{{ workSampleQuantity }}{{form.conditionType == '1' ? form.measureUnit : form.unit}}
|
|
|
</template>
|
|
|
</ele-pro-table>
|
|
|
<header-title title="请样信息"> </header-title>
|
|
|
@@ -147,7 +147,7 @@
|
|
|
<el-form-item label="请样数量:" prop="pleaseQuantity">
|
|
|
<el-input v-model="form.pleaseQuantity" placeholder="请输入">
|
|
|
<template slot="append">
|
|
|
- {{ form.pleaseUnit }}
|
|
|
+ {{ form.measureUnit }}
|
|
|
</template>
|
|
|
</el-input>
|
|
|
</el-form-item>
|
|
|
@@ -319,7 +319,7 @@
|
|
|
>确认</el-button
|
|
|
>
|
|
|
|
|
|
- <el-button @click="cancel">关闭 {{ form.processInstanceId }}</el-button>
|
|
|
+ <el-button @click="cancel">关闭</el-button>
|
|
|
</template>
|
|
|
<inspectionWorkDialog
|
|
|
ref="inspectionWorkDialog"
|
|
|
@@ -657,8 +657,10 @@
|
|
|
} else {
|
|
|
this.$set(this.form, 'unit', data?.list[0].unit);
|
|
|
}
|
|
|
- this.datasource(data?.list[0]?.unit);
|
|
|
- this.queryQualityTempleContent(!data?.list.length&&row.qualityMode==1);
|
|
|
+ await this.datasource(data?.list[0]?.unit);
|
|
|
+ await this.queryQualityTempleContent(
|
|
|
+ !data?.list.length && row.qualityMode == 1
|
|
|
+ );
|
|
|
}
|
|
|
},
|
|
|
getById(id) {
|
|
|
@@ -682,16 +684,19 @@
|
|
|
this.form = { ...res, ...res.qualityWorkOrderVO };
|
|
|
this.datasource(this.form.unit);
|
|
|
this.queryQualityTempleContent();
|
|
|
- if (res.qualityWorkOrderVO.conditionType == 1) {
|
|
|
- // if (this.form.unit == res.qualityWorkOrderVO.measureUnit) {
|
|
|
- // this.$set(this.form, 'packingUnit', '111');
|
|
|
- // } else {
|
|
|
- // this.$set(this.form, 'packingUnit', '222');
|
|
|
- // }
|
|
|
- this.$set(this.form, 'portion', res.quantity);
|
|
|
- this.$set(this.form, 'quantity', 0);
|
|
|
- } else {
|
|
|
- this.$set(this.form, 'portion', res.copies);
|
|
|
+ if (this.form.qualityMode == 2) {
|
|
|
+ if (res.qualityWorkOrderVO.conditionType == 1) {
|
|
|
+ // if (res.unit != res.qualitySampleList[0].measureUnit) {
|
|
|
+ // this.$set(this.form, 'portion', res.qualitySampleList.length);
|
|
|
+ // } else {
|
|
|
+
|
|
|
+ // }
|
|
|
+ this.$set(this.form, 'portion', res.quantity);
|
|
|
+ this.$set(this.form, 'quantity', 0);
|
|
|
+ } else {
|
|
|
+ this.$set(this.form, 'portion', res.copies);
|
|
|
+ // this.$set(this.form, 'quantity', res.quantity / res.copies);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
this.sampleList = res.qualitySampleList;
|
|
|
@@ -705,8 +710,8 @@
|
|
|
size: 10000
|
|
|
});
|
|
|
this.schemeList = res.list;
|
|
|
- if(is){
|
|
|
- this.updatePackingList()
|
|
|
+ if (is) {
|
|
|
+ this.updatePackingList();
|
|
|
}
|
|
|
},
|
|
|
cancel() {
|
|
|
@@ -791,21 +796,8 @@
|
|
|
const unit = data.sampleUnit;
|
|
|
const sampleCount = Number(data.portion);
|
|
|
try {
|
|
|
- if (
|
|
|
- this.form.inspectionStandards === 1 ||
|
|
|
- ([2, 3, 4, 5].includes(this.form.inspectionStandards) &&
|
|
|
- this.form.conditionType == 2)
|
|
|
- ) {
|
|
|
- // 新增校验 数量 取整样 ***
|
|
|
- if (this.form.conditionType == 1) {
|
|
|
- let isFlag = this.validateSampleQuantity(
|
|
|
- sampleCount,
|
|
|
- specifications
|
|
|
- );
|
|
|
- if (!isFlag) return;
|
|
|
- }
|
|
|
- // ***
|
|
|
- //抽检计量整样小样或者抽检计重小样
|
|
|
+ // 2 取小样
|
|
|
+ if (this.form.conditionType == 2) {
|
|
|
if (!this.validateMeasureQuantity(quantity, unit, sampleCount))
|
|
|
return; //取样数量验证
|
|
|
if (unit === 'KG' && !this.validateWeight(quantity, sampleCount))
|
|
|
@@ -817,15 +809,22 @@
|
|
|
unit,
|
|
|
specifications
|
|
|
);
|
|
|
- // 这里是取整样 非数量
|
|
|
- } else if (
|
|
|
- [2, 3, 4, 5].includes(this.form.inspectionStandards) &&
|
|
|
- this.form.conditionType == 1
|
|
|
- ) {
|
|
|
- console.log('这里是取整样 吗');
|
|
|
- //抽检取计重取整样
|
|
|
- if (!this.validateSampleCount(sampleCount, specifications)) return;
|
|
|
- await this.handleWeightFullSample(sampleCount, specifications);
|
|
|
+ } else {
|
|
|
+ let isFlag = this.validateSampleQuantity(
|
|
|
+ sampleCount,
|
|
|
+ specifications
|
|
|
+ );
|
|
|
+ if (!isFlag) return;
|
|
|
+ if (this.form.inspectionStandards == 1) {
|
|
|
+ await this.getNewFullSampleList(
|
|
|
+ Math.ceil(sampleCount),
|
|
|
+ quantity,
|
|
|
+ unit,
|
|
|
+ specifications
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ await this.handleWeightFullSample(sampleCount, specifications);
|
|
|
+ }
|
|
|
}
|
|
|
} catch (error) {
|
|
|
console.error('取样处理失败:', error);
|
|
|
@@ -839,7 +838,6 @@
|
|
|
});
|
|
|
|
|
|
if (totalMaxPossible < sampleCount) {
|
|
|
- // this.form.portion = totalMaxPossible;
|
|
|
this.$message.info(`最大取样条数为${totalMaxPossible}`);
|
|
|
return false;
|
|
|
}
|
|
|
@@ -871,7 +869,7 @@
|
|
|
},
|
|
|
|
|
|
validateMeasureQuantity(quantity, unit, sampleCount) {
|
|
|
- if (this.form.conditionType == 2 && quantity <= 0) {
|
|
|
+ if (quantity <= 0) {
|
|
|
this.$message.info('取样计量数量必须大于0');
|
|
|
return false;
|
|
|
}
|
|
|
@@ -881,8 +879,7 @@
|
|
|
this.workSampleQuantity;
|
|
|
|
|
|
if (
|
|
|
- (this.selection[0].measureUnit === unit ||
|
|
|
- this.form.conditionType == 1) &&
|
|
|
+ this.selection[0].measureUnit === unit &&
|
|
|
quantity * sampleCount > totalQuantity
|
|
|
) {
|
|
|
this.$message.info('取样计量数量不能大于总计量数量');
|
|
|
@@ -896,32 +893,6 @@
|
|
|
this.$message.info('条目计量数量小于取样计量数量');
|
|
|
return false;
|
|
|
}
|
|
|
-
|
|
|
- return true;
|
|
|
- },
|
|
|
-
|
|
|
- // 抽检取整样 校验
|
|
|
- validateSampleCount(sampleCount, specifications) {
|
|
|
- // 新增校验 ***
|
|
|
- let isFlag = this.validateSampleQuantity(sampleCount, specifications);
|
|
|
- if (!isFlag) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- // ***
|
|
|
- const chooseNumber = this.selection.reduce((acc, pro) => {
|
|
|
- return pro.measureQuantity ? acc + Number(pro.measureQuantity) : acc;
|
|
|
- }, 0);
|
|
|
- const invalidItem =
|
|
|
- chooseNumber < sampleCount + this.workSampleQuantity;
|
|
|
- // console.log(this.selection, 'this.selection');
|
|
|
- // const invalidItem = this.selection.find(
|
|
|
- // (item) => item.measureQuantity < sampleCount
|
|
|
- // );
|
|
|
- if (invalidItem) {
|
|
|
- this.$message.info('所选的条目计量数量小于取样计量数量');
|
|
|
- return false;
|
|
|
- }
|
|
|
- // ***
|
|
|
return true;
|
|
|
},
|
|
|
|
|
|
@@ -1128,6 +1099,7 @@
|
|
|
validateSampleQuantity(sampleCount, specifications) {
|
|
|
let packingUnit = this.selection[0].packingUnit?.trim() || '';
|
|
|
let totalS = 0;
|
|
|
+ let measureQuantityCount = 0;
|
|
|
let labelKey =
|
|
|
packingUnit == specifications.conversionUnit.trim()
|
|
|
? 'packingQuantity'
|
|
|
@@ -1135,7 +1107,7 @@
|
|
|
let labelName = labelKey == 'packingQuantity' ? '包装数量' : '计量数量';
|
|
|
totalS = this.selection.reduce((total, el) => total + el[labelKey], 0);
|
|
|
let formTotalS = this.tableList.reduce(
|
|
|
- (total, el) => total + el[labelKey],
|
|
|
+ (total, el) => total + el.measureQuantity,
|
|
|
0
|
|
|
);
|
|
|
if (sampleCount > totalS) {
|
|
|
@@ -1144,9 +1116,17 @@
|
|
|
);
|
|
|
return false;
|
|
|
}
|
|
|
- if (sampleCount > formTotalS - this.workSampleQuantity) {
|
|
|
+ if (labelKey == 'packingQuantity') {
|
|
|
+ measureQuantityCount =
|
|
|
+ sampleCount * this.selection[0].measureQuantity;
|
|
|
+ } else {
|
|
|
+ measureQuantityCount = sampleCount;
|
|
|
+ }
|
|
|
+ if (measureQuantityCount > formTotalS - this.workSampleQuantity) {
|
|
|
this.$message.info(
|
|
|
- `取样数量不能大于${formTotalS - this.workSampleQuantity}`
|
|
|
+ `取样数量不能大于${formTotalS - this.workSampleQuantity} ${
|
|
|
+ this.selection[0].measureUnit
|
|
|
+ }`
|
|
|
);
|
|
|
return false;
|
|
|
}
|
|
|
@@ -1184,28 +1164,27 @@
|
|
|
)
|
|
|
);
|
|
|
|
|
|
- if (sampleCount >= list.length) {
|
|
|
- dataList.push({
|
|
|
- ...item,
|
|
|
- measureQuantity: item.measureQuantity, //作为计量数量
|
|
|
- sampleCode: codeList[index],
|
|
|
- qualitySampleTemplateList
|
|
|
- });
|
|
|
- }
|
|
|
+ // if (sampleCount >= list.length) {
|
|
|
+ dataList.push({
|
|
|
+ ...item,
|
|
|
+ measureQuantity: item.measureQuantity, //作为计量数量
|
|
|
+ sampleCode: codeList[index],
|
|
|
+ qualitySampleTemplateList
|
|
|
+ });
|
|
|
+ // }
|
|
|
}
|
|
|
+ console.log(dataList, 'dataList');
|
|
|
|
|
|
this.sampleList = dataList;
|
|
|
this.getTotal();
|
|
|
},
|
|
|
getTotal() {
|
|
|
- this.form.sampleQuantity = this.sampleList.reduce(
|
|
|
- (total, el) => total + Number(el.measureQuantity),
|
|
|
- 0
|
|
|
- );
|
|
|
- this.form.sampleWeight = this.sampleList.reduce(
|
|
|
- (total, el) => total + Number(el.weight),
|
|
|
- 0
|
|
|
- );
|
|
|
+ this.form.sampleQuantity = this.sampleList
|
|
|
+ .reduce((total, el) => total + Number(el.measureQuantity), 0)
|
|
|
+ .toFixed(2);
|
|
|
+ this.form.sampleWeight = this.sampleList
|
|
|
+ .reduce((total, el) => total + Number(el.weight), 0)
|
|
|
+ .toFixed(2);
|
|
|
},
|
|
|
async batchCodes(count) {
|
|
|
if (count <= 0) return;
|
|
|
@@ -1229,9 +1208,8 @@
|
|
|
delete this.form[key];
|
|
|
});
|
|
|
}
|
|
|
- if (this.form.conditionType == 1) {
|
|
|
- this.form.quantity = this.form.portion;
|
|
|
- }
|
|
|
+ let data = JSON.parse(JSON.stringify(this.form));
|
|
|
+
|
|
|
let api =
|
|
|
this.type == 'add' ? samplingrecordSave : samplingrecordUpdate;
|
|
|
this.$refs.form.validate((valid) => {
|
|
|
@@ -1240,10 +1218,29 @@
|
|
|
this.$message.error('样品清单不能为空!');
|
|
|
return;
|
|
|
}
|
|
|
+ //抽检
|
|
|
+ if (data.qualityMode == 2) {
|
|
|
+ //取整样
|
|
|
+ if (data.conditionType == 1) {
|
|
|
+ data.quantity = data.portion;
|
|
|
+ // if (data.unit != data.measureUnit) {
|
|
|
+ // data.quantity = this.sampleList.reduce(
|
|
|
+ // (total, el) => total + Number(el.measureQuantity),
|
|
|
+ // 0
|
|
|
+ // );
|
|
|
+ // } else {
|
|
|
+ // data.quantity = this.form.portion;
|
|
|
+ // }
|
|
|
+ } else {
|
|
|
+ data.measureUnit = data.unit;
|
|
|
+ data.copies = data.portion;
|
|
|
+ // data.quantity = data.quantity * data.copies;
|
|
|
+ }
|
|
|
+ }
|
|
|
this.loading = true;
|
|
|
|
|
|
api({
|
|
|
- ...this.form,
|
|
|
+ ...data,
|
|
|
sampleList: this.sampleList
|
|
|
})
|
|
|
.then((res) => {
|