|
|
@@ -38,8 +38,72 @@
|
|
|
@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="dataWork.id"
|
|
|
@@ -48,6 +112,7 @@
|
|
|
:scheme-list="schemeList"
|
|
|
:loading="loading"
|
|
|
:form="form"
|
|
|
+ :productId="productId"
|
|
|
:status="statusType"
|
|
|
@handleSelectionChange="handleSelectionChange1"
|
|
|
@batch-quality="batchQuality"
|
|
|
@@ -113,7 +178,21 @@
|
|
|
sampleDisposeDialog
|
|
|
},
|
|
|
mixins: [dictMixins],
|
|
|
-
|
|
|
+ computed: {
|
|
|
+ sampletypeVal() {
|
|
|
+ return (row) => {
|
|
|
+ if (row == 1) {
|
|
|
+ return '整样';
|
|
|
+ }
|
|
|
+ return '小样';
|
|
|
+ };
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // p:{
|
|
|
+ // sampletypeVal()=>{
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // },
|
|
|
data() {
|
|
|
const defaultForm = function () {
|
|
|
return {
|
|
|
@@ -185,17 +264,26 @@
|
|
|
dataWork: {}
|
|
|
};
|
|
|
},
|
|
|
- // watch: {
|
|
|
- // '$route.query.id': {
|
|
|
- // handler(id) {
|
|
|
- // if (id) {
|
|
|
- // this.getDetail();
|
|
|
- // } else {
|
|
|
- // this.form = { ...defaultForm() };
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- // },
|
|
|
+ watch: {
|
|
|
+ '$route.query.id': {
|
|
|
+ handler(id) {
|
|
|
+ if (id) {
|
|
|
+ this.getDetail();
|
|
|
+ } else {
|
|
|
+ this.form = { ...defaultForm() };
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 样品清单
|
|
|
+ sampleList: {
|
|
|
+ handler(newVal) {
|
|
|
+ // 计算重量跟数量
|
|
|
+ this.calculate(newVal);
|
|
|
+ },
|
|
|
+ deep: true,
|
|
|
+ immediate: true
|
|
|
+ }
|
|
|
+ },
|
|
|
|
|
|
created() {
|
|
|
// this.open();
|
|
|
@@ -204,10 +292,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(val, flag, '切换检验方式');
|
|
|
-
|
|
|
this.$refs.tabsRef.tableSelClear();
|
|
|
this.sampleList = [];
|
|
|
this.$refs.tabsRef.tabsChange('1');
|
|
|
@@ -231,14 +385,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) {
|
|
|
@@ -247,8 +398,6 @@
|
|
|
delete item.id;
|
|
|
});
|
|
|
|
|
|
- console.log(oldItem, 'oldItem');
|
|
|
- console.log(count, newMeasureQuantity, newWeight);
|
|
|
delete oldItem.id;
|
|
|
|
|
|
if (
|
|
|
@@ -270,7 +419,6 @@
|
|
|
)
|
|
|
});
|
|
|
}
|
|
|
- console.log(ProductSampleList, 'ProductSampleList');
|
|
|
this.sampleList = ProductSampleList;
|
|
|
const pNum = ProductSampleList.reduce((sum, item) => {
|
|
|
return sum + Number(item.weight || 0);
|
|
|
@@ -288,7 +436,6 @@
|
|
|
)
|
|
|
});
|
|
|
}
|
|
|
- console.log(ProductSampleList, 'ProductSampleList');
|
|
|
this.sampleList = ProductSampleList;
|
|
|
const pNum = ProductSampleList.reduce((sum, item) => {
|
|
|
return sum + Number(item.weight || 0);
|
|
|
@@ -305,18 +452,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) {
|
|
|
@@ -324,11 +466,7 @@
|
|
|
}
|
|
|
delete item.id;
|
|
|
});
|
|
|
-
|
|
|
- console.log(oldItem, 'oldItem');
|
|
|
- console.log(count, newMeasureQuantity, newWeight);
|
|
|
delete oldItem.id;
|
|
|
-
|
|
|
if (
|
|
|
oldItem.qualitySampleTemplateList == undefined ||
|
|
|
oldItem.qualitySampleTemplateList == null ||
|
|
|
@@ -348,7 +486,6 @@
|
|
|
)
|
|
|
});
|
|
|
}
|
|
|
- console.log(ProductSampleList, 'ProductSampleList');
|
|
|
this.sampleList = ProductSampleList;
|
|
|
const pNum = ProductSampleList.reduce((sum, item) => {
|
|
|
return sum + Number(item.weight || 0);
|
|
|
@@ -366,7 +503,6 @@
|
|
|
)
|
|
|
});
|
|
|
}
|
|
|
- console.log(ProductSampleList, 'ProductSampleList');
|
|
|
this.sampleList = ProductSampleList;
|
|
|
const pNum = ProductSampleList.reduce((sum, item) => {
|
|
|
return sum + Number(item.weight || 0);
|
|
|
@@ -416,8 +552,6 @@
|
|
|
// 切换检验方式为全检后生成样品
|
|
|
changeGetSampleList(list) {
|
|
|
this.$message('正在生成样品清单');
|
|
|
- console.log(list);
|
|
|
- console.log(this.form.total);
|
|
|
|
|
|
// 计量类型1是数量,2是重量
|
|
|
if (this.form.inspectionStandards == 1) {
|
|
|
@@ -452,7 +586,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) => {
|
|
|
@@ -554,24 +687,6 @@
|
|
|
this.qualityTimeStart = this.getNowTime();
|
|
|
}
|
|
|
}
|
|
|
- // this.type = this.$route.query.type;
|
|
|
- // this.qualityType = this.$route.query.qualityType;
|
|
|
-
|
|
|
- // this.title =
|
|
|
- // this.type == 'add' ? '新增' : this.type == 'edit' ? '报工' : '详情';
|
|
|
-
|
|
|
- // if (this.type == 'add') {
|
|
|
- // const code = await getCode('quality_work_order_code');
|
|
|
- // this.form.code = code;
|
|
|
- // } else {
|
|
|
- // if (
|
|
|
- // this.$route.query.qualityTimeStart != '' ||
|
|
|
- // this.$route.query.qualityTimeStart != null ||
|
|
|
- // this.$route.query.qualityTimeStart != undefined
|
|
|
- // ) {
|
|
|
- // this.qualityTimeStart = this.getNowTime();
|
|
|
- // }
|
|
|
- // }
|
|
|
},
|
|
|
getNowTime() {
|
|
|
const nowDate = this.getNowDate();
|
|
|
@@ -596,6 +711,7 @@
|
|
|
async getDetail(id) {
|
|
|
getById(id).then((res) => {
|
|
|
this.form = res.data;
|
|
|
+ this.productId = res.data.productId || '';
|
|
|
this.statusType = this.form.status == 1 ? true : false;
|
|
|
|
|
|
this.isReportProcessProduce =
|
|
|
@@ -734,8 +850,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('请先选择样品!');
|
|
|
@@ -744,28 +859,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';
|
|
|
|
|
|
@@ -775,6 +896,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');
|
|
|
@@ -782,7 +925,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;
|
|
|
@@ -894,7 +1036,7 @@
|
|
|
|
|
|
async queryQualitySamplContent() {
|
|
|
const res = await queryQualitySamplContent({
|
|
|
- qualityWorkerId: this.$route.query.id,
|
|
|
+ qualityWorkerId: this.dataWork.id,
|
|
|
size: 1000
|
|
|
});
|
|
|
let addStatus = res.list.map((item) => {
|
|
|
@@ -914,30 +1056,27 @@
|
|
|
this.addStatus = addStatus;
|
|
|
} else {
|
|
|
this.getProSamList(this.packingList);
|
|
|
- if (this.form.qualityMode == 1) {
|
|
|
- this.changeModel(this.form.qualityMode);
|
|
|
- }
|
|
|
+ // if (this.form.qualityMode == 1) {
|
|
|
+ // this.changeModel(this.form.qualityMode);
|
|
|
+ // }
|
|
|
}
|
|
|
},
|
|
|
async queryQualityTempleContent() {
|
|
|
const res = await queryQualityTempleContent({
|
|
|
- qualityWorkerId: this.$route.query.id
|
|
|
+ qualityWorkerId: this.dataWork.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) {
|
|
|
@@ -951,8 +1090,6 @@
|
|
|
|
|
|
delete this.form['qualityTimeEnd'];
|
|
|
|
|
|
- console.log(this.sampleList);
|
|
|
-
|
|
|
let params = {
|
|
|
...this.form,
|
|
|
sampleList: this.sampleList,
|
|
|
@@ -961,7 +1098,6 @@
|
|
|
// qualityInventoryList: this.$refs.tabsRef.$refs.sourceTable.getData()
|
|
|
qualityInventoryList: this.inventoryList
|
|
|
};
|
|
|
- console.log(params, 'params ----');
|
|
|
|
|
|
URL(params)
|
|
|
.then((msg) => {
|
|
|
@@ -998,6 +1134,10 @@
|
|
|
finishPageTab();
|
|
|
this.$router.go(-1);
|
|
|
},
|
|
|
+ setSchemeList(list) {
|
|
|
+ this.schemeList = list;
|
|
|
+ },
|
|
|
+
|
|
|
handleDetail(index, row, type) {
|
|
|
if (!this.sampleList[index] || !this.schemeList) {
|
|
|
return;
|
|
|
@@ -1005,6 +1145,8 @@
|
|
|
const selectedData = [];
|
|
|
selectedData.push(this.sampleList[index]);
|
|
|
|
|
|
+ console.log(selectedData, 'selectedData');
|
|
|
+
|
|
|
if (this.schemeList.length != 0) {
|
|
|
this.sampleList.forEach((item) => {
|
|
|
if (item.qualitySampleTemplateList.length == 0) {
|
|
|
@@ -1023,8 +1165,6 @@
|
|
|
);
|
|
|
},
|
|
|
inputWeight(row, index) {
|
|
|
- console.log(row, index, '输入重量');
|
|
|
-
|
|
|
// 计算所有样本的总重量
|
|
|
const pNum = this.sampleList.reduce((sum, item) => {
|
|
|
return sum + Number(item.weight || 0);
|
|
|
@@ -1032,7 +1172,6 @@
|
|
|
this.form.totalWeight = parseFloat(pNum.toFixed(2));
|
|
|
},
|
|
|
handleDispose(data) {
|
|
|
- console.log(data);
|
|
|
// return
|
|
|
this.rowData = data;
|
|
|
this.sampleDisposeVisble = true;
|
|
|
@@ -1090,8 +1229,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 = '';
|
|
|
// }
|
|
|
@@ -1103,14 +1240,12 @@
|
|
|
// qualityInventoryList: this.$refs.tabsRef.$refs.sourceTable.getData()
|
|
|
qualityInventoryList: this.inventoryList
|
|
|
};
|
|
|
- console.log(params, 'params');
|
|
|
|
|
|
exeReportWork(params)
|
|
|
.then((msg) => {
|
|
|
this.loading = false;
|
|
|
this.$message.success(msg);
|
|
|
- // this.cancel();
|
|
|
- this.visible = false;
|
|
|
+ this.cancel();
|
|
|
this.$emit('done');
|
|
|
})
|
|
|
.catch((e) => {
|
|
|
@@ -1120,9 +1255,6 @@
|
|
|
},
|
|
|
// 处理确认事件
|
|
|
handleDisposeConfirm(data, index) {
|
|
|
- console.log(data, index, '确认处置事件');
|
|
|
- console.log(this.sampleList);
|
|
|
-
|
|
|
if (index == undefined) {
|
|
|
this.sampleList.forEach((obj) => {
|
|
|
obj.disposeType = data.disposeType;
|
|
|
@@ -1137,13 +1269,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) {
|
|
|
@@ -1155,7 +1283,6 @@
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
- console.log(list, 'listlistlistlist');
|
|
|
list.forEach((item) => {
|
|
|
if (item.qualitySampleTemplateList.length == 1) {
|
|
|
if (
|
|
|
@@ -1195,20 +1322,25 @@
|
|
|
if (index != null) {
|
|
|
this.$set(this.sampleList, index, list[0]);
|
|
|
} else {
|
|
|
- this.$set(this.sampleList, null, list);
|
|
|
+ // this.$set(this.sampleList, null, list);
|
|
|
+ this.sampleList = list;
|
|
|
}
|
|
|
this.activeName = '2';
|
|
|
- console.log(this.sampleList, '222表');
|
|
|
// *** 选完批量质检调用
|
|
|
- this.countQualityResults();
|
|
|
- },
|
|
|
-
|
|
|
- setSchemeList(list) {
|
|
|
- this.schemeList = list;
|
|
|
- console.log(this.schemeList, 'this.schemeList');
|
|
|
+ // this.countQualityResults();
|
|
|
},
|
|
|
// 批量质检
|
|
|
batchQuality(index, row, type) {
|
|
|
+ // if (this.form.sampleList.qualitySampleTemplateList.length == 0) {
|
|
|
+ // this.form.sampleList.forEach((item, index) => {
|
|
|
+ // this.$set(
|
|
|
+ // this.form.sampleList[index],
|
|
|
+ // 'qualitySampleTemplateList',
|
|
|
+ // this.form.templateList
|
|
|
+ // );
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+
|
|
|
if (this.sampleList.length == 0) {
|
|
|
this.$message.error('样品清单不能为空');
|
|
|
return;
|
|
|
@@ -1221,6 +1353,7 @@
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
this.$refs.detailRef.openDia(
|
|
|
null,
|
|
|
null,
|
|
|
@@ -1289,7 +1422,12 @@
|
|
|
},
|
|
|
|
|
|
//从来源数组取样到目标数组
|
|
|
- async getNewFullSampleList(sampleCount, sampleQuantity, sampleUnit) {
|
|
|
+ async getNewFullSampleList(
|
|
|
+ sampleCount,
|
|
|
+ sampleQuantity,
|
|
|
+ sampleUnit,
|
|
|
+ specifications
|
|
|
+ ) {
|
|
|
const sourceArray = this.selectedList;
|
|
|
// 检查单位是否匹配
|
|
|
const isUnitMismatch =
|
|
|
@@ -1376,13 +1514,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) => {
|
|
|
@@ -1468,11 +1639,17 @@
|
|
|
this.$emit('done');
|
|
|
},
|
|
|
|
|
|
- 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(
|
|
|
@@ -1482,17 +1659,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
|
|
|
@@ -1537,7 +1711,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;
|
|
|
},
|
|
|
@@ -1546,7 +1734,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
|
|
|
@@ -1560,7 +1747,6 @@
|
|
|
? acc + Number(pro.measureQuantity)
|
|
|
: acc;
|
|
|
}, 0);
|
|
|
- console.log(noQualifiedNumber, 'noQualifiedNumber');
|
|
|
let qualifiedNumber = sampleNumber - noQualifiedNumber; //不合格数
|
|
|
let qualificationRate = (
|
|
|
(qualifiedNumber / sampleNumber) *
|