fix(stocktake): 盘库扫码改为精确匹配,修复漏匹配与性能问题

问题:
1. 准确性 bug: 前端用 getStockList({pageSize:10, keyword}) 模糊搜索 + find()
   当 SKU 前缀相同、目标不在前10条时,误报'未找到该物料库存'
2. 性能: 每次扫码全表 ilike %x% 搜索 3 张表,不走索引

修复:
- 后端 get_stock_info 改为精确匹配(==)优先,未命中再回退模糊搜索
- 新增 GET /inbound/stock/scan 扫码精确匹配接口,返回唯一命中
- 前端 onScanSuccess/handleManualInput 改用 scanStockByBarcode
  一次请求直接命中,不再依赖 pageSize:10 + find()
This commit is contained in:
yueli
2026-08-31 14:49:24 +08:00
parent e026c00a85
commit 7e281cf285
3 changed files with 138 additions and 88 deletions

View File

@ -19,6 +19,15 @@ export function getStockList(params: { page?: number; pageSize?: number; keyword
})
}
// 扫码精确匹配库存(盘库/出库/借库通用,替代模糊搜索漏匹配问题)
export function scanStockByBarcode(barcode: string) {
return request({
url: '/v1/inbound/stock/scan',
method: 'get',
params: { barcode }
})
}
// 打印出库选单
// 修改后: 去掉开头的 /api
export function printSelectionList(items: any[]) {