|
@@ -109,8 +109,9 @@
|
|
|
<el-option
|
|
<el-option
|
|
|
v-for="item in scope.row.batchNoList || []"
|
|
v-for="item in scope.row.batchNoList || []"
|
|
|
:key="item.id"
|
|
:key="item.id"
|
|
|
- :label="item.batchNo"
|
|
|
|
|
|
|
+ :label="item.id == 999 ? `${item.batchNo}(无匹配可发库存)` : item.batchNo"
|
|
|
:value="item.id"
|
|
:value="item.id"
|
|
|
|
|
+ :disabled="item.id == 999"
|
|
|
>
|
|
>
|
|
|
</el-option>
|
|
</el-option>
|
|
|
</el-select>
|
|
</el-select>
|
|
@@ -630,6 +631,7 @@
|
|
|
form: {
|
|
form: {
|
|
|
datasource: []
|
|
datasource: []
|
|
|
},
|
|
},
|
|
|
|
|
+ batchLookupPending: 0,
|
|
|
rules: {},
|
|
rules: {},
|
|
|
columnsVersion: 1
|
|
columnsVersion: 1
|
|
|
};
|
|
};
|
|
@@ -1202,19 +1204,30 @@
|
|
|
this.setWarehouseOutStock(index, {});
|
|
this.setWarehouseOutStock(index, {});
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- const stockInfo = await getWarehouseOutStockInfo({
|
|
|
|
|
|
|
+ const query = {
|
|
|
warehouseId: row.warehouseId,
|
|
warehouseId: row.warehouseId,
|
|
|
code: row.productCode,
|
|
code: row.productCode,
|
|
|
batchNo: row.batchNo,
|
|
batchNo: row.batchNo,
|
|
|
systemBatchNo: row.systemBatchNo,
|
|
systemBatchNo: row.systemBatchNo,
|
|
|
colorKey: row.colorKey,
|
|
colorKey: row.colorKey,
|
|
|
modelType: row.modelType
|
|
modelType: row.modelType
|
|
|
- });
|
|
|
|
|
- this.setWarehouseOutStock(index, stockInfo);
|
|
|
|
|
|
|
+ };
|
|
|
|
|
+ const stockInfo = await getWarehouseOutStockInfo(query);
|
|
|
|
|
+ if (this.form.datasource[index] === row &&
|
|
|
|
|
+ row.warehouseId == query.warehouseId &&
|
|
|
|
|
+ row.batchNo == query.batchNo &&
|
|
|
|
|
+ row.systemBatchNo == query.systemBatchNo &&
|
|
|
|
|
+ row.colorKey == query.colorKey &&
|
|
|
|
|
+ row.modelType == query.modelType) {
|
|
|
|
|
+ this.setWarehouseOutStock(index, stockInfo);
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
async warehouseChange(index, row, isReset = false) {
|
|
async warehouseChange(index, row, isReset = false) {
|
|
|
console.log('warehouseChange', index, row.warehouseId, isReset);
|
|
console.log('warehouseChange', index, row.warehouseId, isReset);
|
|
|
|
|
+ const warehouseId = row.warehouseId;
|
|
|
|
|
+ const colorKey = row.colorKey;
|
|
|
|
|
+ const modelType = row.modelType;
|
|
|
const data = row.warehouseList.find(
|
|
const data = row.warehouseList.find(
|
|
|
(item) => item.warehouseId == row.warehouseId
|
|
(item) => item.warehouseId == row.warehouseId
|
|
|
);
|
|
);
|
|
@@ -1232,23 +1245,27 @@
|
|
|
data?.warehouseCode || 0
|
|
data?.warehouseCode || 0
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
|
|
+ if (isReset) {
|
|
|
|
|
+ this.$set(row, 'batchStockId', '');
|
|
|
|
|
+ this.$set(row, 'batchNo', '');
|
|
|
|
|
+ this.$set(row, 'systemBatchNo', '');
|
|
|
|
|
+ }
|
|
|
|
|
+ const batchStockId = row.batchStockId;
|
|
|
const tempBatchNoList = await getBatchList({
|
|
const tempBatchNoList = await getBatchList({
|
|
|
warehouseId: data?.warehouseId || '',
|
|
warehouseId: data?.warehouseId || '',
|
|
|
categoryCode: row.productCode,
|
|
categoryCode: row.productCode,
|
|
|
colorKey: row.colorKey,
|
|
colorKey: row.colorKey,
|
|
|
modelType: row.modelType,
|
|
modelType: row.modelType,
|
|
|
});
|
|
});
|
|
|
|
|
+ if (this.form.datasource[index] !== row || row.warehouseId != warehouseId ||
|
|
|
|
|
+ row.colorKey != colorKey || row.modelType != modelType ||
|
|
|
|
|
+ row.batchStockId != batchStockId) return;
|
|
|
this.$set(
|
|
this.$set(
|
|
|
this.form.datasource[index],
|
|
this.form.datasource[index],
|
|
|
'batchNoList',
|
|
'batchNoList',
|
|
|
this.dedupeBatchNoList(tempBatchNoList?.list)
|
|
this.dedupeBatchNoList(tempBatchNoList?.list)
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
- if (isReset) {
|
|
|
|
|
- this.$set(this.form.datasource[index], 'batchStockId', '');
|
|
|
|
|
- this.$set(this.form.datasource[index], 'batchNo', '');
|
|
|
|
|
- this.$set(this.form.datasource[index], 'systemBatchNo', '');
|
|
|
|
|
- }
|
|
|
|
|
await this.refreshWarehouseOutStock(index, this.form.datasource[index]);
|
|
await this.refreshWarehouseOutStock(index, this.form.datasource[index]);
|
|
|
},
|
|
},
|
|
|
|
|
|
|
@@ -1460,6 +1477,8 @@
|
|
|
console.log(obj, 'obj');
|
|
console.log(obj, 'obj');
|
|
|
obj.forEach((item) => {
|
|
obj.forEach((item) => {
|
|
|
item.orderTotalCount = item.totalCount;
|
|
item.orderTotalCount = item.totalCount;
|
|
|
|
|
+ // 清空选入行ID前保留订单来源,避免换成同一批次后误合并额度。
|
|
|
|
|
+ item.orderProductId = item.orderProductId || item.id;
|
|
|
item.id = '';
|
|
item.id = '';
|
|
|
});
|
|
});
|
|
|
this.putTableValue(copyObj(obj));
|
|
this.putTableValue(copyObj(obj));
|
|
@@ -1755,17 +1774,44 @@
|
|
|
);
|
|
);
|
|
|
// console.log(this.form.datasource[index]);
|
|
// console.log(this.form.datasource[index]);
|
|
|
} else {
|
|
} else {
|
|
|
- this.setBatchAndWarehouse(item, index);
|
|
|
|
|
|
|
+ this.batchLookupPending++;
|
|
|
|
|
+ this.setBatchAndWarehouse(item, index).then(
|
|
|
|
|
+ () => { this.batchLookupPending--; },
|
|
|
|
|
+ () => {
|
|
|
|
|
+ this.batchLookupPending--;
|
|
|
|
|
+ if (this.form.datasource[index] === item) {
|
|
|
|
|
+ this.$set(item, 'batchStockId', 999);
|
|
|
|
|
+ this.$set(item, 'batchNoList', [{ id: 999, batchNo: item.batchNo }]);
|
|
|
|
|
+ this.$message.error('批次库存查询失败,请重新打开后重试');
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ );
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
async setBatchAndWarehouse(item, index) {
|
|
async setBatchAndWarehouse(item, index) {
|
|
|
console.log('333~~~~', index);
|
|
console.log('333~~~~', index);
|
|
|
|
|
+ let warehouseId = item.warehouseId;
|
|
|
|
|
+ const batchNo = item.batchNo;
|
|
|
|
|
+ const systemBatchNo = item.systemBatchNo;
|
|
|
|
|
+ const batchStockId = item.batchStockId;
|
|
|
|
|
+ const colorKey = item.colorKey;
|
|
|
|
|
+ const modelType = item.modelType;
|
|
|
|
|
+ const productId = item.productId;
|
|
|
|
|
+ const isCurrent = () => this.form.datasource[index] === item &&
|
|
|
|
|
+ item.warehouseId == warehouseId && item.batchNo == batchNo &&
|
|
|
|
|
+ item.systemBatchNo == systemBatchNo && item.batchStockId == batchStockId &&
|
|
|
|
|
+ item.colorKey == colorKey && item.modelType == modelType &&
|
|
|
|
|
+ item.productId == productId;
|
|
|
// 通过产品编码查仓库
|
|
// 通过产品编码查仓库
|
|
|
- const tempWarehouse = await getIdWarehouseList({
|
|
|
|
|
|
|
+ const tempWarehouse = (await getIdWarehouseList({
|
|
|
categoryId: item.productId
|
|
categoryId: item.productId
|
|
|
- });
|
|
|
|
|
|
|
+ })) || [];
|
|
|
|
|
+ if (!isCurrent()) return;
|
|
|
|
|
+ if (warehouseId && !tempWarehouse.some((warehouse) => warehouse.warehouseId == warehouseId)) {
|
|
|
|
|
+ tempWarehouse.push({ warehouseId, warehouseName: item.warehouseName || warehouseId });
|
|
|
|
|
+ }
|
|
|
// 有仓库列表
|
|
// 有仓库列表
|
|
|
if (tempWarehouse?.length) {
|
|
if (tempWarehouse?.length) {
|
|
|
console.log('666~~~~', index, tempWarehouse);
|
|
console.log('666~~~~', index, tempWarehouse);
|
|
@@ -1781,7 +1827,10 @@
|
|
|
'warehouseId',
|
|
'warehouseId',
|
|
|
this.form.datasource[index]?.warehouseList[0].warehouseId
|
|
this.form.datasource[index]?.warehouseList[0].warehouseId
|
|
|
);
|
|
);
|
|
|
|
|
+ const selectedWarehouseId = item.warehouseId;
|
|
|
await this.warehouseChange(index, this.form.datasource[index]);
|
|
await this.warehouseChange(index, this.form.datasource[index]);
|
|
|
|
|
+ if (item.warehouseId != selectedWarehouseId) return;
|
|
|
|
|
+ warehouseId = selectedWarehouseId;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1792,18 +1841,22 @@
|
|
|
modelType: item.modelType,
|
|
modelType: item.modelType,
|
|
|
size: -1
|
|
size: -1
|
|
|
});
|
|
});
|
|
|
|
|
+ if (!isCurrent()) return;
|
|
|
|
|
|
|
|
let tempBatchNoList = this.dedupeBatchNoList(templist1?.list);
|
|
let tempBatchNoList = this.dedupeBatchNoList(templist1?.list);
|
|
|
console.log('888~~~~', index, item.batchNo);
|
|
console.log('888~~~~', index, item.batchNo);
|
|
|
|
|
|
|
|
// 优先按批次明细ID匹配,无ID时按系统批次和业务批次兼容匹配
|
|
// 优先按批次明细ID匹配,无ID时按系统批次和业务批次兼容匹配
|
|
|
- const batchNoObj = tempBatchNoList.find(
|
|
|
|
|
|
|
+ const matchingBatches = tempBatchNoList.filter(
|
|
|
(i) =>
|
|
(i) =>
|
|
|
- (item.batchStockId && i.id == item.batchStockId) ||
|
|
|
|
|
- (!item.batchStockId &&
|
|
|
|
|
- i.batchNo == item.batchNo &&
|
|
|
|
|
- (!item.systemBatchNo || i.systemBatchNo == item.systemBatchNo))
|
|
|
|
|
|
|
+ i.categoryId == item.productId &&
|
|
|
|
|
+ i.warehouseId == item.warehouseId &&
|
|
|
|
|
+ (i.colorKey || '') == (item.colorKey || '') &&
|
|
|
|
|
+ i.batchNo == item.batchNo &&
|
|
|
|
|
+ (!item.systemBatchNo || i.systemBatchNo == item.systemBatchNo) &&
|
|
|
|
|
+ (!item.batchStockId || i.id == item.batchStockId)
|
|
|
);
|
|
);
|
|
|
|
|
+ const batchNoObj = matchingBatches.length == 1 ? matchingBatches[0] : null;
|
|
|
|
|
|
|
|
if (batchNoObj) {
|
|
if (batchNoObj) {
|
|
|
this.$set(
|
|
this.$set(
|
|
@@ -1825,6 +1878,7 @@
|
|
|
// 批次列表添加不存在的批次号对象
|
|
// 批次列表添加不存在的批次号对象
|
|
|
tempBatchNoList.push({
|
|
tempBatchNoList.push({
|
|
|
batchNo: item.batchNo,
|
|
batchNo: item.batchNo,
|
|
|
|
|
+ systemBatchNo: item.systemBatchNo,
|
|
|
id: 999,
|
|
id: 999,
|
|
|
measureQuantity: 0
|
|
measureQuantity: 0
|
|
|
});
|
|
});
|
|
@@ -1834,7 +1888,6 @@
|
|
|
this.$set(this.form.datasource[index], 'warehouseNum', '');
|
|
this.$set(this.form.datasource[index], 'warehouseNum', '');
|
|
|
this.$set(this.form.datasource[index], 'stockCountBase', '');
|
|
this.$set(this.form.datasource[index], 'stockCountBase', '');
|
|
|
this.$set(this.form.datasource[index], 'availableCountBase', '');
|
|
this.$set(this.form.datasource[index], 'availableCountBase', '');
|
|
|
- this.$set(this.form.datasource[index], 'warehouseId', '');
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// // 批次号
|
|
// // 批次号
|
|
@@ -1848,6 +1901,7 @@
|
|
|
const tempBatchNoList = [
|
|
const tempBatchNoList = [
|
|
|
{
|
|
{
|
|
|
batchNo: item.batchNo,
|
|
batchNo: item.batchNo,
|
|
|
|
|
+ systemBatchNo: item.systemBatchNo,
|
|
|
id: 999,
|
|
id: 999,
|
|
|
measureQuantity: 0
|
|
measureQuantity: 0
|
|
|
}
|
|
}
|
|
@@ -1919,8 +1973,18 @@
|
|
|
this.$refs.selectStockLedgerDialogRef.open();
|
|
this.$refs.selectStockLedgerDialogRef.open();
|
|
|
},
|
|
},
|
|
|
validateForm(callback) {
|
|
validateForm(callback) {
|
|
|
|
|
+ if (this.batchLookupPending) {
|
|
|
|
|
+ this.$message.warning('批次库存查询中,请稍后重试');
|
|
|
|
|
+ callback(false);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
//开始表单校验
|
|
//开始表单校验
|
|
|
this.$refs.form.validate((valid, obj) => {
|
|
this.$refs.form.validate((valid, obj) => {
|
|
|
|
|
+ if (this.form.datasource.some((item) => item.batchStockId == 999)) {
|
|
|
|
|
+ this.$message.warning('订单批次无匹配的可发库存,请核对仓库、批次和颜色');
|
|
|
|
|
+ callback(false);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
// 同一订单产品可能拆成多条发货明细,删除明细后只按当前有效行汇总校验。
|
|
// 同一订单产品可能拆成多条发货明细,删除明细后只按当前有效行汇总校验。
|
|
|
const groups = this.form.datasource.reduce((result, item) => {
|
|
const groups = this.form.datasource.reduce((result, item) => {
|
|
|
const key = item.orderProductId
|
|
const key = item.orderProductId
|