|
|
@@ -28,8 +28,65 @@
|
|
|
@changeNumber="changeNumber"
|
|
|
@changeInspectionStandardsModel="changeInspectionStandardsModel"
|
|
|
></base-info>
|
|
|
-
|
|
|
+ <header-title title="样品信息"></header-title>
|
|
|
+ <el-form label-width="110px">
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="6">
|
|
|
+ <el-form-item label="样品合格数:" prop="sampleQualifiedNumber">
|
|
|
+ <el-input
|
|
|
+ type="number"
|
|
|
+ :min="0"
|
|
|
+ disabled
|
|
|
+ v-model="form.sampleQualifiedNumber"
|
|
|
+ placeholder=""
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="6">
|
|
|
+ <el-form-item label="样品不合格数:" prop="sampleNoQualifiedNumber">
|
|
|
+ <el-input
|
|
|
+ type="number"
|
|
|
+ :min="0"
|
|
|
+ disabled
|
|
|
+ v-model="form.sampleNoQualifiedNumber"
|
|
|
+ placeholder=""
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="6">
|
|
|
+ <el-form-item label="样品合格率:" prop="sampleQualificationRate">
|
|
|
+ <el-input v-model="form.sampleQualificationRate" disabled />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="6">
|
|
|
+ <el-form-item
|
|
|
+ label="样品不合格率:"
|
|
|
+ prop="sampleNoQualificationRate"
|
|
|
+ >
|
|
|
+ <el-input v-model="form.sampleNoQualificationRate" disabled />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="6">
|
|
|
+ <el-form-item label="样品类型:" prop="samplesType">
|
|
|
+ <el-input disabled :value="sampletypeVal(form.conditionType)" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="6">
|
|
|
+ <el-form-item label="样品数量:" prop="sampleQuantity">
|
|
|
+ <el-input type="number" disabled v-model="form.sampleQuantity" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="6">
|
|
|
+ <el-form-item label="样品重量:" prop="sampleWeight">
|
|
|
+ <el-input type="number" disabled v-model="form.sampleWeight" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </el-form>
|
|
|
<quality-content-tabs
|
|
|
+ v-if="form.id"
|
|
|
ref="tabsRef"
|
|
|
:type="type"
|
|
|
:ids="this.$route.query.id"
|
|
|
@@ -38,6 +95,7 @@
|
|
|
:scheme-list="schemeList"
|
|
|
:loading="loading"
|
|
|
:form="form"
|
|
|
+ :productId="productId"
|
|
|
:status="statusType"
|
|
|
@handleSelectionChange="handleSelectionChange1"
|
|
|
@batch-quality="batchQuality"
|
|
|
@@ -102,7 +160,21 @@
|
|
|
sampleDisposeDialog
|
|
|
},
|
|
|
mixins: [dictMixins],
|
|
|
-
|
|
|
+ computed: {
|
|
|
+ sampletypeVal() {
|
|
|
+ return (row) => {
|
|
|
+ if (row == 1) {
|
|
|
+ return '整样';
|
|
|
+ }
|
|
|
+ return '小样';
|
|
|
+ };
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // p:{
|
|
|
+ // sampletypeVal()=>{
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // },
|
|
|
data() {
|
|
|
const defaultForm = function () {
|
|
|
return {
|
|
|
@@ -181,6 +253,15 @@
|
|
|
this.form = { ...defaultForm() };
|
|
|
}
|
|
|
}
|
|
|
+ },
|
|
|
+ // 样品清单
|
|
|
+ sampleList: {
|
|
|
+ handler(newVal) {
|
|
|
+ // 计算重量跟数量
|
|
|
+ this.calculate(newVal);
|
|
|
+ },
|
|
|
+ deep: true,
|
|
|
+ immediate: true
|
|
|
}
|
|
|
},
|
|
|
|
|
|
@@ -191,10 +272,76 @@
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ //
|
|
|
+ calculate(list) {
|
|
|
+ if (list.length == 0) {
|
|
|
+ this.form.sampleQuantity = 0;
|
|
|
+ this.form.sampleWeight = 0;
|
|
|
+ }
|
|
|
+ let sampleQuantity = 0; // 样品数量
|
|
|
+ let sampleWeight = 0; // 样品重量
|
|
|
+ let sampleQualifiedNumber = 0; // 样品合格数
|
|
|
+ let sampleNoQualifiedNumber = 0; // 样品不合格数
|
|
|
+ list.forEach((el) => {
|
|
|
+ sampleQuantity += el.measureQuantity - 0;
|
|
|
+ sampleWeight += el.weight - 0;
|
|
|
+ if (el.qualityResults != 2) {
|
|
|
+ sampleQualifiedNumber += el.measureQuantity - 0;
|
|
|
+ } else {
|
|
|
+ sampleNoQualifiedNumber += el.measureQuantity - 0;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // 计算合格率和不合格率(百分比形式)
|
|
|
+ let sampleQualificationRate = '';
|
|
|
+ let sampleNoQualificationRate = '';
|
|
|
+ if (sampleQualifiedNumber) {
|
|
|
+ sampleQualificationRate =
|
|
|
+ ((sampleQualifiedNumber / sampleQuantity) * 100).toFixed(2) || '';
|
|
|
+ sampleNoQualificationRate =
|
|
|
+ ((sampleNoQualifiedNumber / sampleQuantity) * 100).toFixed(2) || '';
|
|
|
+ }
|
|
|
+ if (sampleQualificationRate || sampleQualificationRate == '0.00') {
|
|
|
+ sampleQualificationRate = sampleQualificationRate + '%';
|
|
|
+ }
|
|
|
+ if (sampleNoQualificationRate || sampleNoQualificationRate == '0.00') {
|
|
|
+ sampleNoQualificationRate = sampleNoQualificationRate + '%';
|
|
|
+ }
|
|
|
+ let resultsTotal = this.form.total - sampleQuantity;
|
|
|
+ if (sampleQuantity == sampleQualifiedNumber) {
|
|
|
+ this.$set(this.form, 'qualifiedNumber', resultsTotal);
|
|
|
+ this.$set(this.form, 'noQualifiedNumber', 0);
|
|
|
+ this.$set(this.form, 'qualificationRate', '100%');
|
|
|
+ this.$set(this.form, 'noQualificationRate', '0');
|
|
|
+ this.$set(this.form, 'qualityResults', 1);
|
|
|
+ } else {
|
|
|
+ this.$set(this.form, 'noQualifiedNumber', resultsTotal);
|
|
|
+ this.$set(this.form, 'qualifiedNumber', 0);
|
|
|
+ this.$set(this.form, 'qualificationRate', '0');
|
|
|
+ this.$set(this.form, 'noQualificationRate', '100%');
|
|
|
+ this.$set(this.form, 'qualityResults', 2);
|
|
|
+ }
|
|
|
+ // this.$set(this.form, 'resultsTotal', resultsTotal);
|
|
|
+ this.$set(
|
|
|
+ this.form,
|
|
|
+ 'sampleQualificationRate',
|
|
|
+ sampleQualificationRate
|
|
|
+ );
|
|
|
+ this.$set(
|
|
|
+ this.form,
|
|
|
+ 'sampleNoQualificationRate',
|
|
|
+ sampleNoQualificationRate
|
|
|
+ );
|
|
|
+ this.$set(this.form, 'sampleQuantity', sampleQuantity);
|
|
|
+ this.$set(this.form, 'sampleWeight', sampleWeight);
|
|
|
+ this.$set(this.form, 'sampleQualifiedNumber', sampleQualifiedNumber);
|
|
|
+ this.$set(
|
|
|
+ this.form,
|
|
|
+ 'sampleNoQualifiedNumber',
|
|
|
+ sampleNoQualifiedNumber
|
|
|
+ );
|
|
|
+ },
|
|
|
//切换检验方式
|
|
|
changeModel(val, flag) {
|
|
|
- console.log('切换检验方式');
|
|
|
-
|
|
|
this.$refs.tabsRef.tableSelClear();
|
|
|
this.sampleList = [];
|
|
|
this.$refs.tabsRef.tabsChange('1');
|
|
|
@@ -218,14 +365,11 @@
|
|
|
if (this.qualityType == 2) {
|
|
|
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) {
|
|
|
@@ -234,8 +378,6 @@
|
|
|
delete item.id;
|
|
|
});
|
|
|
|
|
|
- console.log(oldItem, 'oldItem');
|
|
|
- console.log(count, newMeasureQuantity, newWeight);
|
|
|
delete oldItem.id;
|
|
|
|
|
|
if (
|
|
|
@@ -257,7 +399,6 @@
|
|
|
)
|
|
|
});
|
|
|
}
|
|
|
- console.log(ProductSampleList, 'ProductSampleList');
|
|
|
this.sampleList = ProductSampleList;
|
|
|
const pNum = ProductSampleList.reduce((sum, item) => {
|
|
|
return sum + Number(item.weight || 0);
|
|
|
@@ -275,7 +416,6 @@
|
|
|
)
|
|
|
});
|
|
|
}
|
|
|
- console.log(ProductSampleList, 'ProductSampleList');
|
|
|
this.sampleList = ProductSampleList;
|
|
|
const pNum = ProductSampleList.reduce((sum, item) => {
|
|
|
return sum + Number(item.weight || 0);
|
|
|
@@ -292,18 +432,13 @@
|
|
|
// 创建计量数量为1的样品清单函数,用于计数类型的
|
|
|
async createSampleList(list) {
|
|
|
if (this.form.qualityMode != null) {
|
|
|
- console.log('sssssjijdiajdia');
|
|
|
-
|
|
|
this.$message('正在生成样品清单');
|
|
|
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) {
|
|
|
@@ -311,11 +446,7 @@
|
|
|
}
|
|
|
delete item.id;
|
|
|
});
|
|
|
-
|
|
|
- console.log(oldItem, 'oldItem');
|
|
|
- console.log(count, newMeasureQuantity, newWeight);
|
|
|
delete oldItem.id;
|
|
|
-
|
|
|
if (
|
|
|
oldItem.qualitySampleTemplateList == undefined ||
|
|
|
oldItem.qualitySampleTemplateList == null ||
|
|
|
@@ -335,7 +466,6 @@
|
|
|
)
|
|
|
});
|
|
|
}
|
|
|
- console.log(ProductSampleList, 'ProductSampleList');
|
|
|
this.sampleList = ProductSampleList;
|
|
|
const pNum = ProductSampleList.reduce((sum, item) => {
|
|
|
return sum + Number(item.weight || 0);
|
|
|
@@ -353,7 +483,6 @@
|
|
|
)
|
|
|
});
|
|
|
}
|
|
|
- console.log(ProductSampleList, 'ProductSampleList');
|
|
|
this.sampleList = ProductSampleList;
|
|
|
const pNum = ProductSampleList.reduce((sum, item) => {
|
|
|
return sum + Number(item.weight || 0);
|
|
|
@@ -403,8 +532,6 @@
|
|
|
// 切换检验方式为全检后生成样品
|
|
|
changeGetSampleList(list) {
|
|
|
this.$message('正在生成样品清单');
|
|
|
- console.log(list);
|
|
|
- console.log(this.form.total);
|
|
|
|
|
|
// 计量类型1是数量,2是重量
|
|
|
if (this.form.inspectionStandards == 1) {
|
|
|
@@ -439,7 +566,6 @@
|
|
|
const count = oldItem.measureQuantity;
|
|
|
const newMeasureQuantity = oldItem.measureQuantity / count;
|
|
|
const newWeight = parseFloat((oldItem.weight / count).toFixed(2));
|
|
|
- console.log(count, newMeasureQuantity, newWeight);
|
|
|
delete oldItem.id;
|
|
|
// 遍历新数组设置 qualityResults 默认值
|
|
|
this.schemeList.forEach((item) => {
|
|
|
@@ -562,6 +688,7 @@
|
|
|
async getDetail() {
|
|
|
getById(this.$route.query.id).then((res) => {
|
|
|
this.form = res.data;
|
|
|
+ this.productId = res.data.productId || '';
|
|
|
this.statusType = this.form.status == 1 ? true : false;
|
|
|
|
|
|
this.isReportProcessProduce =
|
|
|
@@ -700,8 +827,7 @@
|
|
|
console.log(data, 'datadatadatadataxiaoyang');
|
|
|
}
|
|
|
},
|
|
|
- async handleSampleSubmit(data) {
|
|
|
- console.log(data, 'data123确认');
|
|
|
+ async handleSampleSubmit(data, specifications) {
|
|
|
this.sampleList = [];
|
|
|
if (!this.selectedList || this.selectedList.length == 0) {
|
|
|
this.$message.warning('请先选择样品!');
|
|
|
@@ -710,28 +836,34 @@
|
|
|
const measureQ = data.measureQ || 1;
|
|
|
const unit = data.sampleUnit;
|
|
|
const sampleCount = Number(data.portion);
|
|
|
- console.log(measureQ, '计量数量');
|
|
|
- console.log(unit, '所选单位');
|
|
|
- console.log(sampleCount, '数量');
|
|
|
try {
|
|
|
if (this.isStandard1OrWeightSample()) {
|
|
|
+ // 新增校验 数量 取整样 ***
|
|
|
+ if (this.form.conditionType == 1) {
|
|
|
+ let isFlag = this.validateSampleQuantity(
|
|
|
+ sampleCount,
|
|
|
+ specifications
|
|
|
+ );
|
|
|
+ if (!isFlag) return;
|
|
|
+ }
|
|
|
+ // ***
|
|
|
//抽检计量整样小样或者抽检计重小样
|
|
|
if (!this.validateMeasureQuantity(measureQ, unit, sampleCount))
|
|
|
return; //取样数量验证
|
|
|
if (unit === 'KG' && !this.validateWeight(measureQ, sampleCount))
|
|
|
return; // 若计量单位为重量,还需验证总重量是否足够
|
|
|
- console.log(1111111111111);
|
|
|
-
|
|
|
await this.getNewFullSampleList(
|
|
|
Math.ceil(sampleCount),
|
|
|
measureQ,
|
|
|
- unit
|
|
|
+ unit,
|
|
|
+ specifications
|
|
|
);
|
|
|
+ // 这里是取整样 非数量
|
|
|
} else if (this.isWeightStandardFullSample()) {
|
|
|
+ console.log('这里是取整样 吗');
|
|
|
//抽检取计重取整样
|
|
|
- if (!this.validateSampleCount(sampleCount)) return;
|
|
|
- console.log(222222222222222222);
|
|
|
- await this.handleWeightFullSample(sampleCount);
|
|
|
+ if (!this.validateSampleCount(sampleCount, specifications)) return;
|
|
|
+ await this.handleWeightFullSample(sampleCount, specifications);
|
|
|
}
|
|
|
this.activeName = '2';
|
|
|
|
|
|
@@ -741,6 +873,28 @@
|
|
|
this.$message.error('取样处理失败');
|
|
|
}
|
|
|
},
|
|
|
+ // 当计量类型 是数量的时候 取整样 校验
|
|
|
+ validateSampleQuantity(sampleCount, specifications) {
|
|
|
+ let packingUnit = this.selectedList[0].packingUnit.trim();
|
|
|
+ let totalS = 0;
|
|
|
+ let labelKey =
|
|
|
+ packingUnit == specifications.conversionUnit.trim()
|
|
|
+ ? 'packingQuantity'
|
|
|
+ : 'measureQuantity';
|
|
|
+ let labelName = labelKey == 'packingQuantity' ? '包装数量' : '计量数量';
|
|
|
+ totalS = this.selectedList.reduce(
|
|
|
+ (total, el) => total + el[labelKey],
|
|
|
+ 0
|
|
|
+ );
|
|
|
+
|
|
|
+ if (sampleCount > totalS) {
|
|
|
+ this.$message.info(
|
|
|
+ `所填的条目数量不能超过所选${labelName}总和${totalS}`
|
|
|
+ );
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ },
|
|
|
//获取样品编码
|
|
|
async getSampleCode() {
|
|
|
return await getCode('sample_code');
|
|
|
@@ -748,7 +902,6 @@
|
|
|
async getNewSampleList(measureQ, unit, nums) {
|
|
|
this.sampleList = [];
|
|
|
|
|
|
- console.log(this.selectedList, 'this.selectedList');
|
|
|
if (!this.selectedList || this.selectedList.length == 0) {
|
|
|
this.$message.warning('请先选择来源清单!');
|
|
|
return;
|
|
|
@@ -875,7 +1028,6 @@
|
|
|
...item
|
|
|
};
|
|
|
});
|
|
|
- console.log(addStatus, '样品清单12123123');
|
|
|
if (addStatus.length > 0) {
|
|
|
this.sampleList = addStatus;
|
|
|
this.addStatus = addStatus;
|
|
|
@@ -887,21 +1039,18 @@
|
|
|
const res = await queryQualityTempleContent({
|
|
|
qualityWorkerId: this.$route.query.id
|
|
|
});
|
|
|
- console.log(res, '质检方案');
|
|
|
this.schemeList = res.list;
|
|
|
},
|
|
|
// 取样
|
|
|
getConditionType(val) {
|
|
|
- console.log(val, '------取样的回调');
|
|
|
-
|
|
|
this.form.conditionType = val;
|
|
|
},
|
|
|
|
|
|
/* 保存编辑 */
|
|
|
save() {
|
|
|
// *** 新增判断
|
|
|
- let flag = this.$refs.baseInfoRefs.quantityCalculation();
|
|
|
- if (!flag) return;
|
|
|
+ // let flag = this.$refs.baseInfoRefs.quantityCalculation();
|
|
|
+ // if (!flag) return;
|
|
|
// ***
|
|
|
this.$refs.baseInfoRefs.$refs.form1.validate((valid) => {
|
|
|
if (!valid) {
|
|
|
@@ -915,8 +1064,6 @@
|
|
|
|
|
|
delete this.form['qualityTimeEnd'];
|
|
|
|
|
|
- console.log(this.sampleList);
|
|
|
-
|
|
|
let params = {
|
|
|
...this.form,
|
|
|
sampleList: this.sampleList,
|
|
|
@@ -925,7 +1072,6 @@
|
|
|
// qualityInventoryList: this.$refs.tabsRef.$refs.sourceTable.getData()
|
|
|
qualityInventoryList: this.inventoryList
|
|
|
};
|
|
|
- console.log(params, 'params ----');
|
|
|
|
|
|
URL(params)
|
|
|
.then((msg) => {
|
|
|
@@ -964,7 +1110,6 @@
|
|
|
},
|
|
|
setSchemeList(list) {
|
|
|
this.schemeList = list;
|
|
|
- console.log(this.schemeList, 'this.schemeList');
|
|
|
},
|
|
|
|
|
|
handleDetail(index, row, type) {
|
|
|
@@ -994,8 +1139,6 @@
|
|
|
);
|
|
|
},
|
|
|
inputWeight(row, index) {
|
|
|
- console.log(row, index, '输入重量');
|
|
|
-
|
|
|
// 计算所有样本的总重量
|
|
|
const pNum = this.sampleList.reduce((sum, item) => {
|
|
|
return sum + Number(item.weight || 0);
|
|
|
@@ -1003,7 +1146,6 @@
|
|
|
this.form.totalWeight = parseFloat(pNum.toFixed(2));
|
|
|
},
|
|
|
handleDispose(data) {
|
|
|
- console.log(data);
|
|
|
// return
|
|
|
this.rowData = data;
|
|
|
this.sampleDisposeVisble = true;
|
|
|
@@ -1061,8 +1203,6 @@
|
|
|
this.form.qualityTimeEnd = this.getNowTime();
|
|
|
this.form.qualityTimeStart = this.qualityTimeStart;
|
|
|
|
|
|
- console.log(this.form.qualityTimeStart, this.form.qualityTimeEnd);
|
|
|
-
|
|
|
// if (this.form.qualityMode == 1) {
|
|
|
// this.form.qualityResults = '';
|
|
|
// }
|
|
|
@@ -1074,7 +1214,6 @@
|
|
|
// qualityInventoryList: this.$refs.tabsRef.$refs.sourceTable.getData()
|
|
|
qualityInventoryList: this.inventoryList
|
|
|
};
|
|
|
- console.log(params, 'params');
|
|
|
|
|
|
exeReportWork(params)
|
|
|
.then((msg) => {
|
|
|
@@ -1090,9 +1229,6 @@
|
|
|
},
|
|
|
// 处理确认事件
|
|
|
handleDisposeConfirm(data, index) {
|
|
|
- console.log(data, index, '确认处置事件');
|
|
|
- console.log(this.sampleList);
|
|
|
-
|
|
|
if (index == undefined) {
|
|
|
this.sampleList.forEach((obj) => {
|
|
|
obj.disposeType = data.disposeType;
|
|
|
@@ -1107,13 +1243,9 @@
|
|
|
} else {
|
|
|
this.$set(this.sampleList, index, data);
|
|
|
}
|
|
|
-
|
|
|
- console.log(this.sampleList);
|
|
|
},
|
|
|
//确认质检
|
|
|
handleConfirm(list, index) {
|
|
|
- console.log(list);
|
|
|
-
|
|
|
// 检查有效性
|
|
|
// for (const item of list) {
|
|
|
// for (const child of item.qualitySampleTemplateList) {
|
|
|
@@ -1125,7 +1257,6 @@
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
- console.log(list, 'listlistlistlist');
|
|
|
list.forEach((item) => {
|
|
|
if (item.qualitySampleTemplateList.length == 1) {
|
|
|
if (
|
|
|
@@ -1168,14 +1299,11 @@
|
|
|
this.$set(this.sampleList, null, list);
|
|
|
}
|
|
|
this.activeName = '2';
|
|
|
- console.log(this.sampleList, '222表');
|
|
|
// *** 选完批量质检调用
|
|
|
- this.countQualityResults();
|
|
|
+ // this.countQualityResults();
|
|
|
},
|
|
|
// 批量质检
|
|
|
batchQuality(index, row, type) {
|
|
|
- console.log(this.form.templateList, 'this.form.templateList');
|
|
|
-
|
|
|
// if (this.form.sampleList.qualitySampleTemplateList.length == 0) {
|
|
|
// this.form.sampleList.forEach((item, index) => {
|
|
|
// this.$set(
|
|
|
@@ -1267,7 +1395,12 @@
|
|
|
},
|
|
|
|
|
|
//从来源数组取样到目标数组
|
|
|
- async getNewFullSampleList(sampleCount, sampleQuantity, sampleUnit) {
|
|
|
+ async getNewFullSampleList(
|
|
|
+ sampleCount,
|
|
|
+ sampleQuantity,
|
|
|
+ sampleUnit,
|
|
|
+ specifications
|
|
|
+ ) {
|
|
|
const sourceArray = this.selectedList;
|
|
|
// 检查单位是否匹配
|
|
|
const isUnitMismatch =
|
|
|
@@ -1354,13 +1487,46 @@
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // 判断是不是取整样
|
|
|
+ if (
|
|
|
+ this.form.conditionType == 1 &&
|
|
|
+ specifications &&
|
|
|
+ specifications.id
|
|
|
+ ) {
|
|
|
+ result.map((el) => {
|
|
|
+ el.measureQuantity =
|
|
|
+ el.measureQuantity * specifications.packageCellTotal;
|
|
|
+ el.weight = this.formatNumber(
|
|
|
+ el.measureQuantity,
|
|
|
+ el.weightProportion
|
|
|
+ );
|
|
|
+ });
|
|
|
+ }
|
|
|
this.sampleList = result;
|
|
|
if (this.sampleList.length > sampleCount) {
|
|
|
this.sampleList = this.sampleList.splice(0, sampleCount);
|
|
|
}
|
|
|
-
|
|
|
this.form.sampleNumber = this.sampleList.length;
|
|
|
},
|
|
|
+ // 小数点数据判断
|
|
|
+ formatNumber(a, b, maxDecimals = 4) {
|
|
|
+ if (a == 0 || b == 0 || !a || !b) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ // 计算乘积
|
|
|
+ const product = a * b;
|
|
|
+ // 转换为固定小数位数,然后转换为数字以去除末尾零
|
|
|
+ const rounded = Number(product.toFixed(maxDecimals));
|
|
|
+ // 转换为字符串检查是否需要显示小数部分
|
|
|
+ const str = rounded.toString();
|
|
|
+ // 如果包含小数点
|
|
|
+ if (str.indexOf('.') !== -1) {
|
|
|
+ // 移除末尾的零和小数点(如果后面没有数字了)
|
|
|
+ return str.replace(/\.?0+$/, '');
|
|
|
+ }
|
|
|
+ return str;
|
|
|
+ },
|
|
|
validateWeight(measureQ, sampleCount) {
|
|
|
let totalMaxPossible = 0;
|
|
|
this.selectedList.forEach((item) => {
|
|
|
@@ -1441,11 +1607,17 @@
|
|
|
);
|
|
|
},
|
|
|
|
|
|
- validateSampleCount(sampleCount) {
|
|
|
+ // 抽检取整样 校验
|
|
|
+ validateSampleCount(sampleCount, specifications) {
|
|
|
+ // 新增校验 ***
|
|
|
+ let isFlag = this.validateSampleQuantity(sampleCount, specifications);
|
|
|
+ if (!isFlag) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ // ***
|
|
|
const chooseNumber = this.selectedList.reduce((acc, pro) => {
|
|
|
return pro.measureQuantity ? acc + Number(pro.measureQuantity) : acc;
|
|
|
}, 0);
|
|
|
-
|
|
|
const invalidItem = chooseNumber < sampleCount;
|
|
|
// console.log(this.selectedList, 'this.selectedList');
|
|
|
// const invalidItem = this.selectedList.find(
|
|
|
@@ -1455,17 +1627,14 @@
|
|
|
this.$message.info('所选的条目计量数量小于取样计量数量');
|
|
|
return false;
|
|
|
}
|
|
|
+ // ***
|
|
|
return true;
|
|
|
},
|
|
|
|
|
|
- async handleWeightFullSample(sampleCount) {
|
|
|
- console.log(sampleCount);
|
|
|
-
|
|
|
+ async handleWeightFullSample(sampleCount, specifications) {
|
|
|
const dataList = [];
|
|
|
let currentNum = sampleCount - this.selectedList.length;
|
|
|
let currentNum1 = sampleCount;
|
|
|
- console.log(this.selectedList);
|
|
|
-
|
|
|
for (const item of this.selectedList) {
|
|
|
const qualitySampleTemplateList = item.qualitySampleTemplateList
|
|
|
?.length
|
|
|
@@ -1510,7 +1679,21 @@
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
+ // 更改 从新计算 样品清单 取整样 数据
|
|
|
+ if (specifications && specifications.id) {
|
|
|
+ // let proportion = (obj.weight / obj.measureQuantity).toFixed(2);
|
|
|
+ console.log(dataList, 'dataList 这里是重量');
|
|
|
+ console.log(specifications, 'specifications ===');
|
|
|
+ dataList.map((el) => {
|
|
|
+ el.measureQuantity =
|
|
|
+ el.measureQuantity * specifications.packageCellTotal;
|
|
|
+ el.weight = this.formatNumber(
|
|
|
+ el.measureQuantity,
|
|
|
+ el.weightProportion
|
|
|
+ );
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 更改
|
|
|
this.sampleList = dataList;
|
|
|
this.sampleNumber = this.sampleList.length;
|
|
|
},
|
|
|
@@ -1519,7 +1702,6 @@
|
|
|
countQualityResults() {
|
|
|
let sampleList = this.sampleList; //样品清单
|
|
|
let sampleNumber = this.form.total; //样品总数
|
|
|
- console.log(sampleList, sampleNumber, '=====');
|
|
|
// let qualifiedNumber = sampleList.filter(item => item.qualityResults == 1 || item.qualityResults == 3).length;
|
|
|
// let noQualifiedNumber = sampleList.filter(
|
|
|
// (item) => item.qualityResults == 2
|
|
|
@@ -1533,7 +1715,6 @@
|
|
|
? acc + Number(pro.measureQuantity)
|
|
|
: acc;
|
|
|
}, 0);
|
|
|
- console.log(noQualifiedNumber, 'noQualifiedNumber');
|
|
|
let qualifiedNumber = sampleNumber - noQualifiedNumber; //不合格数
|
|
|
let qualificationRate = (
|
|
|
(qualifiedNumber / sampleNumber) *
|