|
|
@@ -4,10 +4,11 @@
|
|
|
<ele-pro-table
|
|
|
ref="table"
|
|
|
:columns="columns"
|
|
|
- :datasource="poList"
|
|
|
+ :datasource="poList.filter((item) => item.disposalStatus != 2)"
|
|
|
:selection.sync="selection"
|
|
|
:needPage="false"
|
|
|
row-key="id"
|
|
|
+
|
|
|
>
|
|
|
<!-- 操作列 -->
|
|
|
<template v-slot:toolbar v-if="showBtn">
|
|
|
@@ -284,7 +285,7 @@
|
|
|
<el-input-number
|
|
|
v-model="singleQuantity"
|
|
|
:min="0"
|
|
|
- :max="total"
|
|
|
+ :max="availableTotal"
|
|
|
style="width: 120px"
|
|
|
></el-input-number>
|
|
|
</template>
|
|
|
@@ -449,7 +450,11 @@
|
|
|
sampleList: [],
|
|
|
inventoryList: [],
|
|
|
oldList: [],
|
|
|
- addSelection: []
|
|
|
+ addSelection: [],
|
|
|
+ retainedSampleQuantity: 0,
|
|
|
+ retainedSampleUnqualified: 0,
|
|
|
+ lossNumber: 0,
|
|
|
+ lossNumberUnqualified: 0
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
|
@@ -471,6 +476,14 @@
|
|
|
return this.allList;
|
|
|
}
|
|
|
},
|
|
|
+ // 可用总数 = 总数 - 留样数 - 消耗数
|
|
|
+ availableTotal() {
|
|
|
+ if (!this.sampleList.length) return this.total;
|
|
|
+ const usedQuantity = this.sampleList
|
|
|
+ .filter((item) => item.disposeType == 6 || item.disposeType == 7)
|
|
|
+ .reduce((sum, item) => sum + (item.measureQuantity || 0), 0);
|
|
|
+ return this.total - usedQuantity;
|
|
|
+ },
|
|
|
// 表格列配置
|
|
|
columns() {
|
|
|
const arr = [
|
|
|
@@ -662,19 +675,20 @@
|
|
|
setQualifiedNumber() {
|
|
|
let isQualifiedNumber = true;
|
|
|
let noQualifiedNumber = this.poList
|
|
|
- .filter((item) => item.disposeType != 5)
|
|
|
+ .filter((item) => item.disposeType != 5 && item.disposalStatus != 2)
|
|
|
.reduce((acc, cur) => acc + cur.measureQuantity, 0);
|
|
|
|
|
|
if (
|
|
|
this.poList
|
|
|
.filter((item) => item.disposeType == 5)
|
|
|
- .reduce((acc, cur) => acc + cur.measureQuantity, 0) == this.total
|
|
|
+ .reduce((acc, cur) => acc + cur.measureQuantity, 0) ==
|
|
|
+ this.availableTotal
|
|
|
) {
|
|
|
isQualifiedNumber = false;
|
|
|
}
|
|
|
this.$emit('setQualifiedNumber', {
|
|
|
noQualifiedNumber,
|
|
|
- qualifiedNumber: this.total - noQualifiedNumber,
|
|
|
+ qualifiedNumber: this.availableTotal - noQualifiedNumber,
|
|
|
isQualifiedNumber
|
|
|
});
|
|
|
},
|
|
|
@@ -682,21 +696,39 @@
|
|
|
if (qualityResults == 1) {
|
|
|
this.poList = JSON.parse(JSON.stringify(this.oldList));
|
|
|
this.poList = this.poList.map((item) => {
|
|
|
- item.disposalStatus = 1;
|
|
|
- item.disposeType = 5;
|
|
|
+ if (item.disposalStatus != 2) {
|
|
|
+ item.disposalStatus = 1;
|
|
|
+ item.disposeType = 5;
|
|
|
+ }
|
|
|
return item;
|
|
|
});
|
|
|
}
|
|
|
if (qualityResults == 4) {
|
|
|
- this.poList = JSON.parse(JSON.stringify(this.inventoryList));
|
|
|
+ this.poList = [
|
|
|
+ ...JSON.parse(JSON.stringify(this.inventoryList)),
|
|
|
+ ...JSON.parse(
|
|
|
+ JSON.stringify(
|
|
|
+ this.oldList.filter((item) => item.disposalStatus == 2)
|
|
|
+ )
|
|
|
+ )
|
|
|
+ ];
|
|
|
this.poList = this.poList.map((item) => {
|
|
|
- item.disposalStatus = 1;
|
|
|
- item.disposeType = 5;
|
|
|
+ if (item.disposalStatus != 2) {
|
|
|
+ item.disposalStatus = 1;
|
|
|
+ item.disposeType = 5;
|
|
|
+ }
|
|
|
return item;
|
|
|
});
|
|
|
}
|
|
|
if (qualityResults == 2) {
|
|
|
- this.poList = JSON.parse(JSON.stringify(this.inventoryList));
|
|
|
+ this.poList = [
|
|
|
+ ...JSON.parse(JSON.stringify(this.inventoryList)),
|
|
|
+ ...JSON.parse(
|
|
|
+ JSON.stringify(
|
|
|
+ this.oldList.filter((item) => item.disposalStatus == 2)
|
|
|
+ )
|
|
|
+ )
|
|
|
+ ];
|
|
|
}
|
|
|
if (qualityResults == 3) {
|
|
|
this.poList = JSON.parse(JSON.stringify(this.oldList));
|
|
|
@@ -732,7 +764,7 @@
|
|
|
0
|
|
|
);
|
|
|
}
|
|
|
- if (poListTotal + selectedTotal > this.total) {
|
|
|
+ if (poListTotal + selectedTotal > this.availableTotal) {
|
|
|
this.$message.error('选中的计量数量之和加上已有数量不能超过总数');
|
|
|
return;
|
|
|
}
|
|
|
@@ -759,6 +791,7 @@
|
|
|
const arr = await getById(this.id);
|
|
|
this.oldList = JSON.parse(JSON.stringify(arr.poList));
|
|
|
this.poList = arr.poList;
|
|
|
+ this.setQualifiedNumber();
|
|
|
},
|
|
|
|
|
|
// async getRefluxTask() {
|
|
|
@@ -802,6 +835,7 @@
|
|
|
if (res.list.length > 0) {
|
|
|
this.inventoryList = res.list;
|
|
|
}
|
|
|
+ return;
|
|
|
},
|
|
|
|
|
|
async queryQualitySamplContent() {
|
|
|
@@ -810,6 +844,57 @@
|
|
|
size: 1000
|
|
|
});
|
|
|
this.sampleList = res.list;
|
|
|
+ [
|
|
|
+ 'retainedSampleQuantity',
|
|
|
+ 'retainedSampleUnqualified',
|
|
|
+ 'lossNumber',
|
|
|
+ 'lossNumberUnqualified'
|
|
|
+ ].forEach((key) => {
|
|
|
+ this[key] = 0;
|
|
|
+ });
|
|
|
+ if (this.sampleList.length > 0 && this.inventoryList.length > 0) {
|
|
|
+ const processedList = this.sampleList.filter(
|
|
|
+ (item) => item.disposeType == 6 || item.disposeType == 7
|
|
|
+ );
|
|
|
+ console.log(processedList.filter((item) => item.disposeType == 6),'qwewqe')
|
|
|
+ console.log(processedList.filter((item) => item.disposeType == 7),'123123')
|
|
|
+ processedList.forEach((sampleItem) => {
|
|
|
+ if (sampleItem.disposeType == 6) {
|
|
|
+ sampleItem.qualityResults == 2
|
|
|
+ ? (this.retainedSampleUnqualified += sampleItem.measureQuantity)
|
|
|
+ : (this.retainedSampleQuantity +=
|
|
|
+ sampleItem.measureQuantity);
|
|
|
+ } else {
|
|
|
+ sampleItem.qualityResults == 2
|
|
|
+ ? (this.lossNumberUnqualified += sampleItem.measureQuantity)
|
|
|
+ : (this.lossNumber += sampleItem.measureQuantity);
|
|
|
+ }
|
|
|
+ const inventoryItem = this.inventoryList.find(
|
|
|
+ (item) => item.sourceId === sampleItem.sourceId
|
|
|
+ );
|
|
|
+ if (inventoryItem) {
|
|
|
+ inventoryItem.measureQuantity = Math.max(
|
|
|
+ 0,
|
|
|
+ (inventoryItem.measureQuantity || 0) -
|
|
|
+ (sampleItem.measureQuantity || 0)
|
|
|
+ );
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ this.$emit('setLossNumber', {
|
|
|
+ lossNumber: this.lossNumber,
|
|
|
+ lossNumberUnqualified: this.lossNumberUnqualified,
|
|
|
+ retainedSampleQuantity: this.retainedSampleQuantity,
|
|
|
+ retainedSampleUnqualified: this.retainedSampleUnqualified
|
|
|
+ });
|
|
|
+ if (this.inventoryList.length == 1 && !this.inventoryList[0].sourceId) {
|
|
|
+ this.inventoryList[0].measureQuantity =
|
|
|
+ this.inventoryList[0].measureQuantity -
|
|
|
+ this.lossNumber -
|
|
|
+ this.lossNumberUnqualified -
|
|
|
+ this.retainedSampleQuantity -
|
|
|
+ this.retainedSampleUnqualified;
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
async handleDispose() {
|