Fix Bug #514: [库房管理-调拨管理-调拨] 调拨单保存与提交校验缺失:允许保存/提交数量为0或无库存的无效单据

后端:在 addOrEditBatchTransferReceipt、addOrEditTransferReceipt、submitApproval 三个方法中补充调拨单价 > 0 的校验(数量校验已存在但缺单价)。
前端:在 batchTransfer 和 transferManagent 的批量保存 handleSave() 中补充调拨数量 > 0 及不超过源库存数量的前端校验,实现前后端双重拦截。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
关羽
2026-05-16 20:08:23 +08:00
parent c4f0d64cff
commit e08409737b
3 changed files with 42 additions and 0 deletions

View File

@@ -205,6 +205,10 @@ public class ProductTransferAppServiceImpl implements IProductTransferAppService
// 校验调拨数量:必须 > 0 且不超过源库存数量(从数据库查实时库存)
Integer tenantId = SecurityUtils.getLoginUser().getTenantId();
for (ProductTransferDto dto : productTransferDtoList) {
// 校验单价
if (dto.getPrice() == null || dto.getPrice().compareTo(java.math.BigDecimal.ZERO) <= 0) {
return R.fail("调拨单价不能为空或为0请检查");
}
if (dto.getItemQuantity() == null || dto.getItemQuantity().compareTo(java.math.BigDecimal.ZERO) <= 0) {
return R.fail("调拨数量必须大于0");
}
@@ -335,6 +339,10 @@ public class ProductTransferAppServiceImpl implements IProductTransferAppService
// 校验调拨数量:必须 > 0 且不超过源库存数量(从数据库查实时库存)
Integer tenantId = SecurityUtils.getLoginUser().getTenantId();
for (ProductTransferDto dto : productTransferDtoList) {
// 校验单价
if (dto.getPrice() == null || dto.getPrice().compareTo(java.math.BigDecimal.ZERO) <= 0) {
return R.fail("调拨单价不能为空或为0请检查");
}
if (dto.getItemQuantity() == null || dto.getItemQuantity().compareTo(java.math.BigDecimal.ZERO) <= 0) {
return R.fail("调拨数量必须大于0");
}
@@ -424,6 +432,10 @@ public class ProductTransferAppServiceImpl implements IProductTransferAppService
if (requestList != null && !requestList.isEmpty()) {
Integer tenantId = SecurityUtils.getLoginUser().getTenantId();
for (SupplyRequest request : requestList) {
// 校验单价
if (request.getPrice() == null || request.getPrice().compareTo(java.math.BigDecimal.ZERO) <= 0) {
return R.fail("调拨单价不能为空或为0请检查后重新保存");
}
if (request.getItemQuantity() == null || request.getItemQuantity().compareTo(java.math.BigDecimal.ZERO) <= 0) {
return R.fail("调拨数量必须大于0请检查后重新保存");
}

View File

@@ -907,6 +907,21 @@ function remakeBlur(row, index) {
editBatchTransfer(index);
}
function handleSave() {
// 校验调拨数量
const invalidQtyRow = totalIncentoryInfoList.value.find(
(row) => !row.itemQuantity || row.itemQuantity <= 0
);
if (invalidQtyRow) {
proxy.$modal.msgError('调拨数量必须大于0请检查');
return;
}
const overStockRow = totalIncentoryInfoList.value.find(
(row) => row.itemQuantity > row.totalSourceQuantity
);
if (overStockRow) {
proxy.$modal.msgError('调拨数量不可超出源库存数量,请检查!');
return;
}
// 校验单价
const invalidPriceRow = totalIncentoryInfoList.value.find(
(row) => !row.price || row.price <= 0

View File

@@ -1263,6 +1263,21 @@ function editBatchTransfer(index) {
function handleSave(row, index) {
rowList.value = [];
// 校验调拨数量
const invalidQtyRow = form.purchaseinventoryList.find(
(r) => !r.itemQuantity || r.itemQuantity <= 0
);
if (invalidQtyRow) {
proxy.$message.warning('调拨数量必须大于0请检查');
return;
}
const overStockRow = form.purchaseinventoryList.find(
(r) => r.itemQuantity > r.totalSourceQuantity
);
if (overStockRow) {
proxy.$message.warning('调拨数量不可超出源库存数量,请检查!');
return;
}
if (route.query.supplyBusNo) {
// 编辑
forms.purchaseinventoryList.map((row, index) => {