|
@@ -640,11 +640,11 @@
|
|
|
handler(newVal) {
|
|
handler(newVal) {
|
|
|
// 计算重量跟数量
|
|
// 计算重量跟数量
|
|
|
this.calculate(newVal);
|
|
this.calculate(newVal);
|
|
|
- newVal.map(async(el)=>{
|
|
|
|
|
- if(!el.sampleCode){
|
|
|
|
|
- el.sampleCode = await this.getSampleCode();
|
|
|
|
|
|
|
+ newVal.map(async (el) => {
|
|
|
|
|
+ if (!el.sampleCode) {
|
|
|
|
|
+ el.sampleCode = await this.getSampleCode();
|
|
|
}
|
|
}
|
|
|
- })
|
|
|
|
|
|
|
+ });
|
|
|
},
|
|
},
|
|
|
deep: true,
|
|
deep: true,
|
|
|
immediate: true
|
|
immediate: true
|
|
@@ -2148,12 +2148,14 @@
|
|
|
: item['measureQuantity'], // 剩余可取样数量
|
|
: item['measureQuantity'], // 剩余可取样数量
|
|
|
maxPossible: item['measureQuantity'] / sampleQuantity // 最大取样次数
|
|
maxPossible: item['measureQuantity'] / sampleQuantity // 最大取样次数
|
|
|
}));
|
|
}));
|
|
|
-
|
|
|
|
|
|
|
+ console.log(items, 'items items items');
|
|
|
|
|
+ console.log(sampleQuantity, 'sampleQuantity sampleQuantity [[[]]]');
|
|
|
const result = [];
|
|
const result = [];
|
|
|
let remainingCount = sampleCount;
|
|
let remainingCount = sampleCount;
|
|
|
-
|
|
|
|
|
|
|
+ console.log(remainingCount, 'remainingCount ========');
|
|
|
// 尽可能均匀地从各条目取样
|
|
// 尽可能均匀地从各条目取样
|
|
|
while (remainingCount > 0) {
|
|
while (remainingCount > 0) {
|
|
|
|
|
+
|
|
|
// 按剩余可取样比例排序
|
|
// 按剩余可取样比例排序
|
|
|
items.sort(
|
|
items.sort(
|
|
|
(a, b) =>
|
|
(a, b) =>
|
|
@@ -2164,6 +2166,9 @@
|
|
|
let distributed = false;
|
|
let distributed = false;
|
|
|
|
|
|
|
|
for (const item of items) {
|
|
for (const item of items) {
|
|
|
|
|
+ let values = remainingCount > 1 ? 1 : remainingCount;
|
|
|
|
|
+ // sampleQuantity = remainingCount > 1 ? 1 : remainingCount;
|
|
|
|
|
+ console.log(sampleQuantity, 'sampleQuantity ----');
|
|
|
if (
|
|
if (
|
|
|
(!isUnitMismatch && remainingCount > 0) ||
|
|
(!isUnitMismatch && remainingCount > 0) ||
|
|
|
(item.remainingQuantity >= sampleQuantity && remainingCount > 0)
|
|
(item.remainingQuantity >= sampleQuantity && remainingCount > 0)
|
|
@@ -2175,12 +2180,14 @@
|
|
|
this.conditionType == 1 &&
|
|
this.conditionType == 1 &&
|
|
|
this.baseForm.inspectionStandards == 1
|
|
this.baseForm.inspectionStandards == 1
|
|
|
) {
|
|
) {
|
|
|
- result.push({ ...item, measureQuantity: 1, sampleCode });
|
|
|
|
|
|
|
+ console.log('进来1')
|
|
|
|
|
+ result.push({ ...item, measureQuantity: values, sampleCode });
|
|
|
} else if (
|
|
} else if (
|
|
|
this.conditionType == 2 &&
|
|
this.conditionType == 2 &&
|
|
|
(this.baseForm.inspectionStandards == 1 ||
|
|
(this.baseForm.inspectionStandards == 1 ||
|
|
|
this.baseForm.inspectionStandards == 2)
|
|
this.baseForm.inspectionStandards == 2)
|
|
|
) {
|
|
) {
|
|
|
|
|
+ console.log('进来2')
|
|
|
let weight = (item.weight / item.maxPossible).toFixed(2);
|
|
let weight = (item.weight / item.maxPossible).toFixed(2);
|
|
|
result.push({
|
|
result.push({
|
|
|
...item,
|
|
...item,
|
|
@@ -2695,6 +2702,8 @@
|
|
|
this.baseForm.sampleMeasureUnit = this.formData.sampleUnit;
|
|
this.baseForm.sampleMeasureUnit = this.formData.sampleUnit;
|
|
|
this.sampleList = [];
|
|
this.sampleList = [];
|
|
|
const sampleCount = Number(this.formData.portion);
|
|
const sampleCount = Number(this.formData.portion);
|
|
|
|
|
+ console.log(sampleCount, 'sampleCount sampleCount == p');
|
|
|
|
|
+ console.log(this.formData, 'this.formData 000');
|
|
|
const measureQ = this.formData.number || 1;
|
|
const measureQ = this.formData.number || 1;
|
|
|
const unit = this.formData.sampleUnit;
|
|
const unit = this.formData.sampleUnit;
|
|
|
let specifications = this.packingSpecificationOption.find(
|
|
let specifications = this.packingSpecificationOption.find(
|
|
@@ -2716,16 +2725,19 @@
|
|
|
}
|
|
}
|
|
|
// ***
|
|
// ***
|
|
|
//抽检计量整样小样或者抽检计重小样
|
|
//抽检计量整样小样或者抽检计重小样
|
|
|
- if (!this.validateMeasureQuantity(measureQ, unit, sampleCount))
|
|
|
|
|
- return;
|
|
|
|
|
|
|
+ // if (!this.validateMeasureQuantity(measureQ, unit, sampleCount))
|
|
|
|
|
+ // return;
|
|
|
if (unit === 'KG' && !this.validateWeight(measureQ, sampleCount))
|
|
if (unit === 'KG' && !this.validateWeight(measureQ, sampleCount))
|
|
|
return; // 若计量单位为重量,还需验证总重量是否足够
|
|
return; // 若计量单位为重量,还需验证总重量是否足够
|
|
|
console.log('getNewFullSampleList');
|
|
console.log('getNewFullSampleList');
|
|
|
if (this.conditionType == '1' && this.baseForm.type == '3') {
|
|
if (this.conditionType == '1' && this.baseForm.type == '3') {
|
|
|
|
|
+ console.log(1111111111111111111);
|
|
|
await this.handleWeightFullSample(sampleCount, specifications);
|
|
await this.handleWeightFullSample(sampleCount, specifications);
|
|
|
} else {
|
|
} else {
|
|
|
|
|
+ console.log('2222222222222 --', Math.ceil(sampleCount));
|
|
|
await this.getNewFullSampleList(
|
|
await this.getNewFullSampleList(
|
|
|
- Math.ceil(sampleCount),
|
|
|
|
|
|
|
+ // Math.ceil(sampleCount),
|
|
|
|
|
+ sampleCount,
|
|
|
measureQ,
|
|
measureQ,
|
|
|
unit,
|
|
unit,
|
|
|
specifications
|
|
specifications
|
|
@@ -2791,31 +2803,32 @@
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
validateMeasureQuantity(measureQ, unit, sampleCount) {
|
|
validateMeasureQuantity(measureQ, unit, sampleCount) {
|
|
|
- if (this.conditionType == 2 && measureQ <= 0) {
|
|
|
|
|
- this.$message.info('取样计量数量必须大于0');
|
|
|
|
|
- return false;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- const totalQuantity = this.selectedList.reduce(
|
|
|
|
|
- (sum, item) => sum + item.measureQuantity,
|
|
|
|
|
- 0
|
|
|
|
|
- );
|
|
|
|
|
- if (
|
|
|
|
|
- (this.selectedList[0].measureUnit === unit ||
|
|
|
|
|
- this.conditionType == 1) &&
|
|
|
|
|
- measureQ * sampleCount > totalQuantity
|
|
|
|
|
- ) {
|
|
|
|
|
- this.$message.info('取样计量数量不能大于总计量数量');
|
|
|
|
|
- return false;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // if (this.conditionType == 2 && measureQ <= 0) {
|
|
|
|
|
+ // this.$message.info('取样计量数量必须大于0');
|
|
|
|
|
+ // return false;
|
|
|
|
|
+ // }
|
|
|
|
|
|
|
|
- const invalidItem = this.selectedList.find(
|
|
|
|
|
- (item) => item.measureQuantity < measureQ
|
|
|
|
|
- );
|
|
|
|
|
- if (invalidItem) {
|
|
|
|
|
- this.$message.info('条目计量数量小于取样计量数量');
|
|
|
|
|
- return false;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // const totalQuantity = this.selectedList.reduce(
|
|
|
|
|
+ // (sum, item) => sum + item.measureQuantity,
|
|
|
|
|
+ // 0
|
|
|
|
|
+ // );
|
|
|
|
|
+ // if (
|
|
|
|
|
+ // (this.selectedList[0].measureUnit === unit ||
|
|
|
|
|
+ // this.conditionType == 1) &&
|
|
|
|
|
+ // measureQ * sampleCount > totalQuantity
|
|
|
|
|
+ // ) {
|
|
|
|
|
+ // this.$message.info('取样计量数量不能大于总计量数量');
|
|
|
|
|
+ // return false;
|
|
|
|
|
+ // }
|
|
|
|
|
+ // console.log(this.selectedList,'33333333333')
|
|
|
|
|
+ // console.log(measureQ,'measureQ 0000')
|
|
|
|
|
+ // const invalidItem = this.selectedList.find(
|
|
|
|
|
+ // (item) => item.measureQuantity < measureQ
|
|
|
|
|
+ // );
|
|
|
|
|
+ // if (invalidItem) {
|
|
|
|
|
+ // this.$message.info('条目计量数量小于取样计量数量');
|
|
|
|
|
+ // return false;
|
|
|
|
|
+ // }
|
|
|
|
|
|
|
|
return true;
|
|
return true;
|
|
|
},
|
|
},
|