|
|
@@ -205,6 +205,18 @@
|
|
|
}:{
|
|
|
width:1
|
|
|
},
|
|
|
+ this.dimension == "2"
|
|
|
+ ? {
|
|
|
+ prop: 'systemBatchNo',
|
|
|
+ label: '系统内部批次号',
|
|
|
+ align: 'center',
|
|
|
+ minWidth: 180,
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ formatter: (row) => row.systemBatchNo || '-'
|
|
|
+ }
|
|
|
+ : {
|
|
|
+ width: 1
|
|
|
+ },
|
|
|
{
|
|
|
prop: 'categoryModel',
|
|
|
label: '型号',
|
|
|
@@ -417,25 +429,49 @@
|
|
|
this.radio = '';
|
|
|
},
|
|
|
|
|
|
+ isSameStockRecord(source, target) {
|
|
|
+ if (source.batchStockId && target.id) {
|
|
|
+ return source.batchStockId == target.id;
|
|
|
+ }
|
|
|
+ const sourceProductId = source.productId || source.categoryId;
|
|
|
+ const targetProductId = target.categoryId || target.productId;
|
|
|
+ const sourceProductCode =
|
|
|
+ source.productCode || source.categoryCode || source.code;
|
|
|
+ const targetProductCode =
|
|
|
+ target.categoryCode || target.productCode || target.code;
|
|
|
+ const sameProduct =
|
|
|
+ sourceProductId && targetProductId
|
|
|
+ ? sourceProductId == targetProductId
|
|
|
+ : sourceProductCode == targetProductCode;
|
|
|
+ const sameWarehouse =
|
|
|
+ !source.warehouseId ||
|
|
|
+ !target.warehouseId ||
|
|
|
+ source.warehouseId == target.warehouseId;
|
|
|
+ return (
|
|
|
+ sameProduct &&
|
|
|
+ sameWarehouse &&
|
|
|
+ source.batchNo == target.batchNo &&
|
|
|
+ (source.systemBatchNo || '') == (target.systemBatchNo || '')
|
|
|
+ );
|
|
|
+ },
|
|
|
+
|
|
|
async selected() {
|
|
|
if (!this.current && !this.selection.length) {
|
|
|
return this.$message.warning('请至少选择一条数据');
|
|
|
}
|
|
|
if (this.currentIndex != -1) {
|
|
|
if (
|
|
|
- this.data
|
|
|
- .map((item) => item.productCode)
|
|
|
- .includes(this.current.code)
|
|
|
+ this.data.some((item) => this.isSameStockRecord(item, this.current))
|
|
|
) {
|
|
|
- return this.$message.error('选择的物品已经存在列表了');
|
|
|
+ return this.$message.error('选择的库存记录已经存在列表了');
|
|
|
}
|
|
|
} else {
|
|
|
if (
|
|
|
this.selection.some((item) =>
|
|
|
- this.data.some((i) => i.productCode == item.code)
|
|
|
+ this.data.some((source) => this.isSameStockRecord(source, item))
|
|
|
)
|
|
|
) {
|
|
|
- return this.$message.error('选择的物品已经存在列表了');
|
|
|
+ return this.$message.error('选择的库存记录已经存在列表了');
|
|
|
}
|
|
|
}
|
|
|
let list = this.currentIndex == -1 ? this.selection : [this.current];
|
|
|
@@ -476,8 +512,11 @@
|
|
|
//item.weightUnit = item.weightUnit;
|
|
|
// item.warehouseNum = item.measureQuantity;
|
|
|
item.productId = item.categoryId;
|
|
|
+ item.batchStockId = item.id;
|
|
|
item.id = '';
|
|
|
item.batchNo = this.dimension != 1 ? item.batchNo : '';
|
|
|
+ item.systemBatchNo =
|
|
|
+ this.dimension != 1 ? item.systemBatchNo || '' : '';
|
|
|
|
|
|
// item.specification = item.specification;
|
|
|
});
|