feat(stock-check): 添加盘点商品支持多行商品查询

- 商品查询框改为多行文本域,支持换行一行一个(去空行、去重)并展示已识别数量
- 查询条件统一为 where.stock_query = { operator: 'contains', value: [...], type: 'text' } 数组下发
- 支持 Ctrl+Enter 快捷查询,Enter 保留换行
- 补充 storage.inventory.list 的 stock_query 数组用法注释

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
liufumingren 2026-10-28 07:44:28 +08:00
parent d76d3c6746
commit b12420e5a9
2 changed files with 37 additions and 6 deletions

View File

@ -5,7 +5,7 @@ const v = "1.0"
/** storage.inventory.list 请求参数 */
export type InventoryListParams = {
/** 统一 where 条件对象,可用字段:stock_id(商品ID)、space_id(库位ID)、store_id(货主ID)、inventory_type(ZP/CC/JS/XS/ZT/DJ/FP)、batch_no(批次号)、inbound_order_no(入库单号)、available_quantity(可用数量,支持 gt/lt)、inbound_time(入库时间,支持 between)、created_at(创建时间,支持 between)、stock_query(虚拟筛选字段:按商品编码/名称/货物编码/条码/SKU ID 模糊匹配,如 { operator: 'like', value: '111' }) */
/** 统一 where 条件对象,可用字段:stock_id(商品ID)、space_id(库位ID)、store_id(货主ID)、inventory_type(ZP/CC/JS/XS/ZT/DJ/FP)、batch_no(批次号)、inbound_order_no(入库单号)、available_quantity(可用数量,支持 gt/lt)、inbound_time(入库时间,支持 between)、created_at(创建时间,支持 between)、stock_query(虚拟筛选字段:按商品编码/名称/货物编码/条码/SKU ID 匹配;value 可传单个值或数组,如 { operator: 'like', value: '111' } / { operator: 'contains', value: ['111', '6971587968127'], type: 'text' }) */
where?: Record<string, any>
/** 分页参数 { page, pageSize },默认 page=1, pageSize=20 */
pagination?: { page?: number; pageSize?: number }

View File

@ -3,6 +3,8 @@
两种模式(由来源盘点单的 type 决定):
- 商品类(type=store/goods):从 storage.inventory.list 勾选商品 → stock.check.addDetail 传 stock_ids
· 商品查询框支持**换行一行一个**(去空行、去重),整体作为
`where.stock_query = { operator: 'contains', value: [...], type: 'text' }` 数组查询
· ⚠️ 服务端按「商品 + 库存库位」**拆行**:一个商品在该仓库的每个**启用库存库位**各生成一条
明细行(location_id/location_code 快照 + 账面取该库位库存),故「新增条数」可能多于所选商品数
· 无启用库存库位的商品不入明细,计入 invalid_stock_ids(提示为「无效商品」)
@ -62,12 +64,18 @@
<div class="task-panel__toolbar-main">
<el-input
v-model="filters.keyword"
type="textarea"
size="small"
clearable
placeholder="商品编码 / 名称 / 条码"
:autosize="{ minRows: 1, maxRows: 4 }"
resize="none"
placeholder="商品编码 / 名称 / 条码,一行一个"
class="filter-item filter-item--keyword"
@keyup.enter="handleSearch"
@keydown.ctrl.enter.prevent="handleSearch"
/>
<span v-if="keywordList.length > 1" class="filter-keyword-count">
已识别 {{ keywordList.length }} 个查询值
</span>
<el-input
v-model="filters.batch_no"
size="small"
@ -405,6 +413,18 @@ const submitChannelTip = computed(() => {
})
const filters = reactive({ keyword: '', batch_no: '' })
/**
* 商品查询关键字:支持换行一行一个,逐行去空格、去空行、去重
*
* 查询时整体作为 `where.stock_query.value` 数组下发(operator=contains / type=text),
* 后端按商品编码 / 名称 / 条码等字段对数组内每个值做匹配。
*/
const keywordList = computed<string[]>(() => {
const parts = String(filters.keyword ?? '').split(/\r?\n/)
return [...new Set(parts.map((s) => s.trim()).filter(Boolean))]
})
const rows = ref<Record<string, any>[]>([])
const loading = ref(false)
const submitting = ref(false)
@ -486,7 +506,7 @@ function mapRow(item: any, index: number): Record<string, any> {
async function loadRows() {
loading.value = true
try {
const keyword = filters.keyword.trim()
const keywords = keywordList.value
const batchNo = filters.batch_no.trim()
const res: any = await getInventoryList({
where: {
@ -494,8 +514,11 @@ async function loadRows() {
...(boundStoreId.value
? { store_id: { operator: 'eq', value: boundStoreId.value, type: 'number' } }
: {}),
// stock_query 为虚拟筛选字段:按商品编码/名称/条码/SKU ID 模糊匹配
...(keyword ? { stock_query: { operator: 'like', value: keyword } } : {}),
// stock_query 为虚拟筛选字段:按商品编码/名称/条码/SKU ID 匹配;
// 支持换行一行一个 → value 传数组,由后端逐值匹配
...(keywords.length
? { stock_query: { operator: 'contains', value: keywords, type: 'text' } }
: {}),
...(batchNo ? { batch_no: batchNo } : {})
},
pagination: { page: pagination.page, pageSize: pagination.pageSize },
@ -950,6 +973,14 @@ watch(
width: 260px;
}
/* 商品查询支持换行一行一个:提示已识别多少个查询值 */
.filter-keyword-count {
font-size: 12px;
line-height: 20px;
color: #909399;
flex-shrink: 0;
}
/* 表格固定高度:数据少也保持同样大小,超出时表格内部滚动(短屏自适应) */
.picker-table {
height: min(520px, calc(100vh - 340px));