|
@@ -1559,10 +1559,95 @@
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
async setBatchAndWarehouse(item, index) {
|
|
async setBatchAndWarehouse(item, index) {
|
|
|
|
|
+ console.log('333~~~~', index);
|
|
|
|
|
+ // 通过产品编码查仓库
|
|
|
|
|
+ const tempWarehouse = await getIdWarehouseList({
|
|
|
|
|
+ categoryId: item.productId,
|
|
|
|
|
+ })
|
|
|
|
|
+ // 有仓库列表
|
|
|
|
|
+ if (tempWarehouse?.length) {
|
|
|
|
|
+ console.log('666~~~~', index, tempWarehouse);
|
|
|
|
|
+ this.$set(
|
|
|
|
|
+ this.form.datasource[index],
|
|
|
|
|
+ 'warehouseList',
|
|
|
|
|
+ tempWarehouse
|
|
|
|
|
+ );
|
|
|
|
|
+ if (item.warehouseId) {
|
|
|
|
|
+ this.$set(
|
|
|
|
|
+ this.form.datasource[index],
|
|
|
|
|
+ 'warehouseNum',
|
|
|
|
|
+ await getWarehouseOutStock({
|
|
|
|
|
+ warehouseId: item.warehouseId,
|
|
|
|
|
+ code: item.productCode
|
|
|
|
|
+ })
|
|
|
|
|
+ );
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (this.form.datasource[index]?.warehouseList?.length) {
|
|
|
|
|
+ this.$set(
|
|
|
|
|
+ this.form.datasource[index],
|
|
|
|
|
+ 'warehouseId',
|
|
|
|
|
+ this.form.datasource[index]?.warehouseList[0].warehouseId
|
|
|
|
|
+ );
|
|
|
|
|
+ await this.warehouseChange(index, this.form.datasource[index]);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const templist1 = await getBatchList({
|
|
|
|
|
+ categoryCode: item.productCode,
|
|
|
|
|
+ warehouseId: item.warehouseId,
|
|
|
|
|
+ size: -1
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ let tempBatchNoList = templist1?.list || [];
|
|
|
|
|
+ console.log('888~~~~', index, item.batchNo);
|
|
|
|
|
+
|
|
|
|
|
+ const batchNoObj = tempBatchNoList.find(i => i.batchNo == item.batchNo);
|
|
|
|
|
+
|
|
|
|
|
+ if(batchNoObj) {
|
|
|
|
|
+ this.$set(
|
|
|
|
|
+ this.form.datasource[index],
|
|
|
|
|
+ 'batchStockId',
|
|
|
|
|
+ batchNoObj.id
|
|
|
|
|
+ );
|
|
|
|
|
+ this.$set(
|
|
|
|
|
+ this.form.datasource[index],
|
|
|
|
|
+ 'warehouseNum',
|
|
|
|
|
+ batchNoObj.measureQuantity || 0
|
|
|
|
|
+ );
|
|
|
|
|
+ } else { //不存在
|
|
|
|
|
+ // 批次列表添加不存在的批次号对象
|
|
|
|
|
+ tempBatchNoList.push({
|
|
|
|
|
+ batchNo: item.batchNo,
|
|
|
|
|
+ id: 999,
|
|
|
|
|
+ measureQuantity: 0
|
|
|
|
|
+ })
|
|
|
|
|
+ // 设置为不存在的批次ID
|
|
|
|
|
+ this.$set(
|
|
|
|
|
+ this.form.datasource[index],
|
|
|
|
|
+ 'batchStockId',
|
|
|
|
|
+ 999
|
|
|
|
|
+ );
|
|
|
|
|
+ this.$set(
|
|
|
|
|
+ this.form.datasource[index],
|
|
|
|
|
+ 'warehouseNum',
|
|
|
|
|
+ ''
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // // 批次号
|
|
|
|
|
+ this.$set(
|
|
|
|
|
+ this.form.datasource[index],
|
|
|
|
|
+ 'batchNoList',
|
|
|
|
|
+ tempBatchNoList
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ async setBatchAndWarehouse1(item, index) {
|
|
|
// 通过产品编号和批次号获取仓库列表
|
|
// 通过产品编号和批次号获取仓库列表
|
|
|
const warehouse = await getIdWarehouseList({
|
|
const warehouse = await getIdWarehouseList({
|
|
|
categoryId: item.productId,
|
|
categoryId: item.productId,
|
|
|
- batchNo: item.batchNo
|
|
|
|
|
|
|
+ // batchNo: item.batchNo
|
|
|
})
|
|
})
|
|
|
// 如果有仓库列表
|
|
// 如果有仓库列表
|
|
|
if (warehouse?.length) {
|
|
if (warehouse?.length) {
|
|
@@ -1673,6 +1758,7 @@
|
|
|
'warehouseNum',
|
|
'warehouseNum',
|
|
|
batchNo.measureQuantity || 0
|
|
batchNo.measureQuantity || 0
|
|
|
);
|
|
);
|
|
|
|
|
+
|
|
|
} else { //不存在
|
|
} else { //不存在
|
|
|
// 批次列表添加不存在的批次号对象
|
|
// 批次列表添加不存在的批次号对象
|
|
|
batchNoList = batchNoList.push({
|
|
batchNoList = batchNoList.push({
|
|
@@ -1853,22 +1939,55 @@
|
|
|
const errors = [];
|
|
const errors = [];
|
|
|
|
|
|
|
|
// 遍历数据源进行业务规则校验
|
|
// 遍历数据源进行业务规则校验
|
|
|
- this.form.datasource.forEach((item) => {
|
|
|
|
|
|
|
+ this.form.datasource.forEach((item, index) => {
|
|
|
|
|
+ const productInfo = this.getProductDisplayInfo(item);
|
|
|
|
|
+
|
|
|
// 检查数量是否超过订单数量(退货单除外)
|
|
// 检查数量是否超过订单数量(退货单除外)
|
|
|
if (this.isQuantityExceedsOrder(item)) {
|
|
if (this.isQuantityExceedsOrder(item)) {
|
|
|
if (this.sourceType != 3) { // 非退货单
|
|
if (this.sourceType != 3) { // 非退货单
|
|
|
- errors.push({ type: 'quantity', message: ERROR_MESSAGES.QUANTITY_EXCEEDS_ORDER, stopValidation: this.isTotalCount == 1 });
|
|
|
|
|
|
|
+ errors.push({
|
|
|
|
|
+ type: 'quantity',
|
|
|
|
|
+ message: `产品[${productInfo.name}]的发货数量${item.totalCount}大于订单总数量${item.orderTotalCount}`,
|
|
|
|
|
+ stopValidation: this.isTotalCount == 1,
|
|
|
|
|
+ item: item
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 检查批次号是否正确
|
|
// 检查批次号是否正确
|
|
|
|
|
+ // if (this.isBatchNumberInvalid(item)) {
|
|
|
|
|
+ // errors.push({
|
|
|
|
|
+ // type: 'batch',
|
|
|
|
|
+ // message: `产品[${productInfo.name}]填写的批次号与库存批次号不相符,请重新选择批次号出库或删除批次号`,
|
|
|
|
|
+ // stopValidation: true,
|
|
|
|
|
+ // item: item
|
|
|
|
|
+ // });
|
|
|
|
|
+ // }
|
|
|
|
|
+
|
|
|
if (this.isBatchNumberInvalid(item)) {
|
|
if (this.isBatchNumberInvalid(item)) {
|
|
|
- errors.push({ type: 'batch', message: ERROR_MESSAGES.BATCH_NUMBER_INVALID, stopValidation: true });
|
|
|
|
|
|
|
+ // 获取当前批次号和正确的库存批次号信息
|
|
|
|
|
+ const currentBatchNumber = item.batchNo || '未填写';
|
|
|
|
|
+ // const availableBatches = item.availableBatchNumbers || item.validBatchNumbers || [];
|
|
|
|
|
+ // const batchInfo = availableBatches.length > 0
|
|
|
|
|
+ // ? `当前可选择批次号:${availableBatches.join('、')}`
|
|
|
|
|
+ // : '当前无有效批次';
|
|
|
|
|
+
|
|
|
|
|
+ errors.push({
|
|
|
|
|
+ type: 'batch',
|
|
|
|
|
+ message: `第${index + 1}条产品[${productInfo.name}]填写的批次号"${currentBatchNumber}"与库存批次号不相符,请重新选择批次号出库或删除批次号`,
|
|
|
|
|
+ stopValidation: true,
|
|
|
|
|
+ item: item
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 检查挂起产品库存
|
|
// 检查挂起产品库存
|
|
|
if (this.isSuspendedProductOverstock(item)) {
|
|
if (this.isSuspendedProductOverstock(item)) {
|
|
|
- errors.push({ type: 'suspend', message: ERROR_MESSAGES.SUSPENDED_PRODUCT_OVERSTOCK, stopValidation: true });
|
|
|
|
|
|
|
+ errors.push({
|
|
|
|
|
+ type: 'suspend',
|
|
|
|
|
+ message: `挂起产品[${productInfo.name}]的发货数量${item.totalCount}不能大于库存${item.warehouseNum}`,
|
|
|
|
|
+ stopValidation: true,
|
|
|
|
|
+ item: item
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
|
|
@@ -1918,6 +2037,21 @@
|
|
|
*/
|
|
*/
|
|
|
isSuspendedProductOverstock(item) {
|
|
isSuspendedProductOverstock(item) {
|
|
|
return item.isSuspend == 1 && Number(item.totalCount) > item.warehouseNum;
|
|
return item.isSuspend == 1 && Number(item.totalCount) > item.warehouseNum;
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取产品显示信息
|
|
|
|
|
+ * @param {Object} item 数据项
|
|
|
|
|
+ * @returns {Object} 包含产品名称和编码的对象
|
|
|
|
|
+ */
|
|
|
|
|
+ getProductDisplayInfo(item) {
|
|
|
|
|
+ return {
|
|
|
|
|
+ name: item.productName || item.name || '未知产品',
|
|
|
|
|
+ code: item.productCode || item.code || '',
|
|
|
|
|
+ info: item.productName && item.productCode
|
|
|
|
|
+ ? `${item.productName}(${item.productCode})`
|
|
|
|
|
+ : (item.productName || item.name || '未知产品')
|
|
|
|
|
+ };
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|