Fix Bug #514: [库房管理-调拨管理-调拨] 调拨单保存与提交校验缺失 - 前端增加数量>0和库存校验,后端批量保存接口补充@Validated注解

根因:批量调拨页面handleSave仅校验单价未校验数量,submitApproval未校验数据完整性即提交审批;后端批量保存接口缺少@Validated导致DTO层@Min(1)未生效
修复:
1. batchTransfer/index.vue handleSave() 增加调拨数量>0和不超过源库存的前端校验
2. batchTransfer/index.vue handleSubmitApproval() 增加数量>0校验后再提交审批
3. ProductTransferController.java 批量保存接口添加@Validated注解启用DTO校验

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-17 21:18:47 +08:00
parent e245f4ec02
commit 046a3e4703
2 changed files with 35 additions and 9 deletions

View File

@@ -93,7 +93,7 @@ public class ProductTransferController {
* @return 操作结果
*/
@PutMapping("/product-transfer-batch")
public R<?> addOrEditBatchTransferReceipt(@RequestBody List<ProductTransferDto> productTransferDtoList) {
public R<?> addOrEditBatchTransferReceipt(@Validated @RequestBody List<ProductTransferDto> productTransferDtoList) {
// 批量保存按钮
Boolean flag = true;
return productTransferAppService.addOrEditBatchTransferReceipt(productTransferDtoList, flag);

View File

@@ -739,15 +739,25 @@ function handleSubmitApproval() {
let length = totalIncentoryInfoList.value.length;
if (length < 1) {
proxy.$modal.msgWarning('请先添加单据');
} else if (data.isEdit) {
proxy.$modal.msgWarning('单据未保存');
} else {
submitApproval(receiptHeaderForm.busNo).then((response) => {
proxy.$modal.msgSuccess('提交审批成功');
tagsViewStore.delView(router.currentRoute.value);
router.replace({ path: 'transferManagentList' });
});
return;
}
// 校验调拨数量:必须 > 0
const invalidQtyRow = totalIncentoryInfoList.value.find(
(row) => !row.itemQuantity || row.itemQuantity <= 0
);
if (invalidQtyRow) {
proxy.$modal.msgWarning('存在调拨数量为0或无效的明细请检查后提交');
return;
}
if (data.isEdit) {
proxy.$modal.msgWarning('单据未保存');
return;
}
submitApproval(receiptHeaderForm.busNo).then((response) => {
proxy.$modal.msgSuccess('提交审批成功');
tagsViewStore.delView(router.currentRoute.value);
router.replace({ path: 'transferManagentList' });
});
}
// 切换仓库类型获取药房/药库列表 目的仓库切换
@@ -907,6 +917,22 @@ function remakeBlur(row, index) {
editBatchTransfer(index);
}
function handleSave() {
// 校验调拨数量:必须 > 0
const invalidQtyRow = totalIncentoryInfoList.value.find(
(row) => !row.itemQuantity || row.itemQuantity <= 0
);
if (invalidQtyRow) {
proxy.$modal.msgError('调拨数量必须大于0请检查');
return;
}
// 校验调拨数量不能超过源仓库库存
const exceedStockRow = totalIncentoryInfoList.value.find(
(row) => row.itemQuantity > row.totalSourceQuantity
);
if (exceedStockRow) {
proxy.$modal.msgError('调拨数量不可超出源库存数量,请检查!');
return;
}
// 校验单价
const invalidPriceRow = totalIncentoryInfoList.value.find(
(row) => !row.price || row.price <= 0