fix(biz): 修复退库功能中的数量计算和数据关联问题

- 修复查看详情时的表单打开方式,使用 formRef.value.open 替代 handleMasterRowClick
- 在退库表单中添加 operatorQty 输入框的实时计算逻辑
- 修改 calculateBagQty 方法中使用的字段名称,从 returnQty 和 stockQty 改为 operatorQty 和 yardQty
- 添加 calculateQty 方法用于根据袋数和规格反向计算数量
- 修复库存扣减时的数据关联错误,移除冗余的 ProStorageMatDO 插入逻辑
- 修正存储日志中的关联明细ID,确保指向正确的记录ID
This commit is contained in:
zxy 2026-06-04 17:45:14 +08:00
parent c70b6aa1d9
commit 6ddd2b18b9
3 changed files with 30 additions and 34 deletions

View File

@ -73,32 +73,6 @@ public class ProStorageServiceImpl implements ProStorageService {
storageInventoryDO.setYardQty(storageInventoryDO.getYardQty().subtract(proStorageMatDO.getOperatorQty())); storageInventoryDO.setYardQty(storageInventoryDO.getYardQty().subtract(proStorageMatDO.getOperatorQty()));
storageInventoryDO.setPackQty(storageInventoryDO.getPackQty() - proStorageMatDO.getBagQty()); storageInventoryDO.setPackQty(storageInventoryDO.getPackQty() - proStorageMatDO.getBagQty());
proStorageInventoryMapper.updateById(storageInventoryDO); proStorageInventoryMapper.updateById(storageInventoryDO);
ProStorageMatDO proStorageMat = new ProStorageMatDO();
proStorageMat.setStockId(proStorage.getId());
proStorageMat.setDescription("");
proStorageMat.setStoreHouseId(storageInventoryDO.getStoreHouseId());
proStorageMat.setStoreAreaId(storageInventoryDO.getStoreAreaId());
proStorageMat.setStoreHouseCd(storageInventoryDO.getStoreHouseCd());
proStorageMat.setStoreHouseName(storageInventoryDO.getStoreHouseName());
proStorageMat.setStoreAreCd(storageInventoryDO.getStoreAreCd());
proStorageMat.setStoreAreaName(storageInventoryDO.getStoreAreaName());
proStorageMat.setMaterialId(storageInventoryDO.getMaterialId());
proStorageMat.setMatName(storageInventoryDO.getMatName());
proStorageMat.setMatCode(storageInventoryDO.getMatCode());
proStorageMat.setSpec(storageInventoryDO.getSpec());
proStorageMat.setUnit(storageInventoryDO.getUnit());
proStorageMat.setLotNo(storageInventoryDO.getLotNo());
proStorageMat.setOperatorQty(proStorageMatDO.getOperatorQty());
// proStorageMat.setSourceId(0L);
// proStorageMat.setRelarionId(0);
// proStorageMat.setBagSpec(0);
// proStorageMat.setBagQty(0);
// proStorageMat.setPlanId(0);
// proStorageMat.setProNo("");
proStorageMat.setInventBillNo(storageInventoryDO.getInventBillNo());
proStorageMatMapper.insert(proStorageMat);
ProStorageLogDO proStorageLog = new ProStorageLogDO(); ProStorageLogDO proStorageLog = new ProStorageLogDO();
// proStorageLog.setStockId(0); // proStorageLog.setStockId(0);
// proStorageLog.setDescription(""); // proStorageLog.setDescription("");
@ -126,7 +100,7 @@ public class ProStorageServiceImpl implements ProStorageService {
proStorageLog.setOperatorName(nickname); proStorageLog.setOperatorName(nickname);
proStorageLog.setRelarionNo(proStorage.getBillNo()); proStorageLog.setRelarionNo(proStorage.getBillNo());
proStorageLog.setRelarionId(proStorage.getId()); proStorageLog.setRelarionId(proStorage.getId());
proStorageLog.setRelarionDetailId(proStorageMat.getId()); proStorageLog.setRelarionDetailId(proStorageMatDO.getId());
// proStorageLog.setDpstNo(""); // proStorageLog.setDpstNo("");
proStorageLog.setInventBillNo(storageInventoryDO.getInventBillNo()); proStorageLog.setInventBillNo(storageInventoryDO.getInventBillNo());
proStorageLogService.saveProStorageLog(proStorageLog); proStorageLogService.saveProStorageLog(proStorageLog);

View File

@ -139,6 +139,7 @@
placeholder="手动录入" placeholder="手动录入"
:disabled="formType === 'detail'" :disabled="formType === 'detail'"
class="bg-yellow-100" class="bg-yellow-100"
@input="calculateQty(scope.row)"
/> />
</template> </template>
</el-table-column> </el-table-column>
@ -362,17 +363,38 @@ const deleteDetailRow = (index: number) => {
/** 计算袋数(根据退库数量和单袋规格) */ /** 计算袋数(根据退库数量和单袋规格) */
const calculateBagQty = (row: any) => { const calculateBagQty = (row: any) => {
// 退 // 退
const returnQty = parseFloat(row.returnQty) || 0 const returnQty = parseFloat(row.operatorQty) || 0
const stockQty = parseFloat(row.stockQty) || 0 const stockQty = parseFloat(row.yardQty) || 0
if (returnQty > stockQty) { if (returnQty > stockQty) {
message.warning('退库数量不能大于库存数量') message.warning('退库数量不能大于库存数量')
row.returnQty = stockQty.toString() row.operatorQty = stockQty.toString()
row.bagQty = Math.ceil(stockQty / (parseFloat(row.bagSpec) || 1)).toString()
return
} }
// //
if (row.returnQty && row.bagSpec) { if (row.operatorQty && row.bagSpec) {
row.returnBagQty = Math.ceil(parseFloat(row.returnQty) / parseFloat(row.bagSpec)) row.bagQty = Math.ceil(parseFloat(row.operatorQty) / parseFloat(row.bagSpec)).toString()
}
}
/** 计算数量(根据退库袋数和单袋规格) */
const calculateQty = (row: any) => {
// 退
const returnBagQty = parseInt(row.bagQty) || 0
const stockBagQty = parseInt(row.packQty) || 0
if (returnBagQty > stockBagQty) {
message.warning('退库袋数不能大于库存袋数')
row.bagQty = stockBagQty.toString()
row.operatorQty = (stockBagQty * (parseFloat(row.bagSpec) || 1)).toString()
return
}
//
if (row.bagQty && row.bagSpec) {
row.operatorQty = (parseInt(row.bagQty) * parseFloat(row.bagSpec)).toString()
} }
} }

View File

@ -279,7 +279,7 @@ const openForm = (type: string, id?: number) => {
/** 查看详情 */ /** 查看详情 */
const handleViewDetail = (row) => { const handleViewDetail = (row) => {
handleMasterRowClick(row) formRef.value.open('detail', row.id)
} }
/** 删除按钮操作 */ /** 删除按钮操作 */