fix(商品): 统一列表查询 where 为 operator/value/type 结构
外仓商品页(stock/external_stock):
- 筛选条件改用 buildStockQuery;原来把 ScanBox 的 {value,operator,type} 拍平成裸值,后端解析失败(搜索条件格式错误)
- 筛选字段对齐系统商品页:修复「货物编码」被标成条码、重复两个「条码」;库存数量改 number;Y/N 开关改 boolean;分组/操作符统一
- 筛选不再重置工具栏选择的仓库
其余页面统一:
- 收回/组合商品选择弹窗、商品回收站:where 统一改用 buildStockQuery
- 合计 5 处调用 stock.warehouse.list 的页面全部为嵌套规范
This commit is contained in:
parent
0b00014427
commit
2cdedda6f2
@ -72,6 +72,7 @@
|
|||||||
import { nextTick, onMounted, onUnmounted, ref, watch } from 'vue'
|
import { nextTick, onMounted, onUnmounted, ref, watch } from 'vue'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import { warehouseSearch, stockWarehouse } from '@/api/stock/stock'
|
import { warehouseSearch, stockWarehouse } from '@/api/stock/stock'
|
||||||
|
import { buildStockQuery } from '@/utils/stockQueryBuilder'
|
||||||
import {
|
import {
|
||||||
isStockApiSuccess,
|
isStockApiSuccess,
|
||||||
parseStockWarehouseSearch,
|
parseStockWarehouseSearch,
|
||||||
@ -193,8 +194,8 @@ function formatRowLabel(item: StockPickerItem): string {
|
|||||||
async function loadInitialList() {
|
async function loadInitialList() {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
try {
|
try {
|
||||||
const where: Record<string, unknown> = {}
|
// where 统一按 stock.warehouse.list 规范:{ 字段: { operator, value, type } }
|
||||||
if (props.storeId) where.store_id = props.storeId
|
const where = buildStockQuery(props.storeId ? { store_id: props.storeId } : {})
|
||||||
const res: any = await stockWarehouse({ page: 1, pageSize: PICKER_LIST_PAGE_SIZE }, where)
|
const res: any = await stockWarehouse({ page: 1, pageSize: PICKER_LIST_PAGE_SIZE }, where)
|
||||||
if (!isStockApiSuccess(res)) {
|
if (!isStockApiSuccess(res)) {
|
||||||
list.value = []
|
list.value = []
|
||||||
|
|||||||
@ -60,6 +60,7 @@
|
|||||||
import { ref, watch } from 'vue'
|
import { ref, watch } from 'vue'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import { stockWarehouse, warehouseSearch } from '@/api/stock/stock'
|
import { stockWarehouse, warehouseSearch } from '@/api/stock/stock'
|
||||||
|
import { buildStockQuery } from '@/utils/stockQueryBuilder'
|
||||||
import { isComboGoodsApiSuccess, parseStockWarehouseListResponse } from '../combo-stock-config'
|
import { isComboGoodsApiSuccess, parseStockWarehouseListResponse } from '../combo-stock-config'
|
||||||
import {
|
import {
|
||||||
getStockItemCode,
|
getStockItemCode,
|
||||||
@ -135,10 +136,8 @@ function mapRows(rawList: unknown[]): ComboStockPickerItem[] {
|
|||||||
async function loadInitialList() {
|
async function loadInitialList() {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
try {
|
try {
|
||||||
const where: Record<string, unknown> = {}
|
// where 统一按 stock.warehouse.list 规范:{ 字段: { operator, value, type } }
|
||||||
if (props.storeId) {
|
const where = buildStockQuery(props.storeId ? { store_id: props.storeId } : {})
|
||||||
where.store_id = props.storeId
|
|
||||||
}
|
|
||||||
const res: any = await stockWarehouse({ page: 1, pageSize: PICKER_LIST_PAGE_SIZE }, where)
|
const res: any = await stockWarehouse({ page: 1, pageSize: PICKER_LIST_PAGE_SIZE }, where)
|
||||||
if (!isComboGoodsApiSuccess(res)) {
|
if (!isComboGoodsApiSuccess(res)) {
|
||||||
list.value = []
|
list.value = []
|
||||||
|
|||||||
@ -297,6 +297,8 @@ import type { ToolbarButtonConfig } from '@/views/order/orderManagement/config/o
|
|||||||
import { getStatusTextClass } from '@/views/order/orderManagement/config/order-common-config'
|
import { getStatusTextClass } from '@/views/order/orderManagement/config/order-common-config'
|
||||||
import { useAsyncExportTask } from '@/composables/useAsyncExportTask'
|
import { useAsyncExportTask } from '@/composables/useAsyncExportTask'
|
||||||
import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane'
|
import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane'
|
||||||
|
import { buildStockQuery } from '@/utils/stockQueryBuilder'
|
||||||
|
import { stockScanField } from '@/views/stock/stock/stock-config'
|
||||||
|
|
||||||
// ─── 列表列配置 ─────────────────────────────────────────────────────────────
|
// ─── 列表列配置 ─────────────────────────────────────────────────────────────
|
||||||
const columns = [
|
const columns = [
|
||||||
@ -325,119 +327,113 @@ const columns = [
|
|||||||
{ prop: 'update_at_display', label: '更新时间', width: 160, sortable: true }
|
{ prop: 'update_at_display', label: '更新时间', width: 160, sortable: true }
|
||||||
]
|
]
|
||||||
|
|
||||||
// ─── 筛选字段配置 ─────────────────────────────────────────────────────────
|
// ─── 筛选字段配置(字段结构与系统商品页 stock/stock 保持一致)────────────────
|
||||||
const availableFields: any[] = [
|
const availableFields: any[] = [
|
||||||
{
|
// ===== 商品标识 =====
|
||||||
label: '关键词',
|
stockScanField('product', {
|
||||||
value: 'keyword',
|
|
||||||
type: 'text',
|
|
||||||
operators: ['like'],
|
|
||||||
placeholder: '商品编码/名称/条码',
|
|
||||||
group: '基础信息'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '商品名称',
|
|
||||||
value: 'item_name',
|
|
||||||
type: 'text',
|
|
||||||
group: '基础信息'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '品牌',
|
|
||||||
value: 'brand_name',
|
|
||||||
type: 'text',
|
|
||||||
group: '基础信息'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '条码',
|
|
||||||
value: 'goods_code',
|
|
||||||
type: 'text',
|
|
||||||
group: '基础信息'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'SKU',
|
|
||||||
value: 'id',
|
value: 'id',
|
||||||
|
label: 'SKU',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
group: '基础信息'
|
placeholder: '请输入SKU',
|
||||||
},
|
operators: ['eq', 'contains'],
|
||||||
{
|
defaultOperator: 'eq'
|
||||||
label: '条码',
|
}),
|
||||||
|
stockScanField('product', {
|
||||||
|
value: 'item_code',
|
||||||
|
label: '商品编码',
|
||||||
|
type: 'text',
|
||||||
|
placeholder: '请输入商品编码',
|
||||||
|
operators: ['eq', 'ne', 'contains', 'startswith', 'endswith'],
|
||||||
|
defaultOperator: 'eq'
|
||||||
|
}),
|
||||||
|
stockScanField('product', {
|
||||||
|
value: 'goods_code',
|
||||||
|
label: '货物编码',
|
||||||
|
type: 'text',
|
||||||
|
placeholder: '请输入货物编码',
|
||||||
|
operators: ['eq', 'ne', 'contains'],
|
||||||
|
defaultOperator: 'eq'
|
||||||
|
}),
|
||||||
|
|
||||||
|
// ===== 商品信息 =====
|
||||||
|
stockScanField('info', {
|
||||||
|
value: 'item_name',
|
||||||
|
label: '商品名称',
|
||||||
|
type: 'text',
|
||||||
|
placeholder: '请输入商品名称',
|
||||||
|
operators: ['eq', 'ne', 'contains'],
|
||||||
|
defaultOperator: 'eq'
|
||||||
|
}),
|
||||||
|
stockScanField('info', {
|
||||||
value: 'barcode',
|
value: 'barcode',
|
||||||
|
label: '条码',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
group: '基础信息'
|
placeholder: '请输入商品条码',
|
||||||
},
|
operators: ['eq', 'contains'],
|
||||||
{
|
defaultOperator: 'eq'
|
||||||
label: '库存数量',
|
}),
|
||||||
value: 'quantity',
|
stockScanField('info', {
|
||||||
|
value: 'brand_name',
|
||||||
|
label: '品牌',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
group: '基础信息'
|
placeholder: '请输入品牌',
|
||||||
},
|
operators: ['eq', 'ne', 'contains', 'startswith', 'endswith'],
|
||||||
{
|
defaultOperator: 'eq'
|
||||||
label: '外部商品绑定',
|
}),
|
||||||
value: 'has_bound_item',
|
|
||||||
type: 'select',
|
// ===== 商品属性 =====
|
||||||
group: '流程状态',
|
stockScanField('attribute', {
|
||||||
options: [
|
|
||||||
{ label: '全部', value: undefined },
|
|
||||||
{ label: '是', value: 'Y' },
|
|
||||||
{ label: '否', value: 'N' }
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'ABC分类',
|
|
||||||
value: 'level',
|
|
||||||
type: 'select',
|
|
||||||
group: '流程状态',
|
|
||||||
options: [
|
|
||||||
{ label: '全部', value: undefined },
|
|
||||||
{ label: 'A', value: 'A' },
|
|
||||||
{ label: 'B', value: 'B' },
|
|
||||||
{ label: 'C', value: 'C' }
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '是否图片',
|
|
||||||
value: 'is_images',
|
value: 'is_images',
|
||||||
|
label: '是否有图片',
|
||||||
|
type: 'boolean'
|
||||||
|
}),
|
||||||
|
stockScanField('attribute', {
|
||||||
|
value: 'has_bound_item',
|
||||||
|
label: '外部商品绑定',
|
||||||
|
type: 'boolean',
|
||||||
|
placeholder: '请选择是否已绑定外部商品'
|
||||||
|
}),
|
||||||
|
stockScanField('attribute', {
|
||||||
|
value: 'level',
|
||||||
|
label: 'ABC分类',
|
||||||
type: 'select',
|
type: 'select',
|
||||||
group: '流程状态',
|
placeholder: '请选择分类',
|
||||||
options: [
|
options: [
|
||||||
{ label: '全部', value: undefined },
|
{ value: 'A', label: 'A类' },
|
||||||
{ label: '是', value: 'Y' },
|
{ value: 'B', label: 'B类' },
|
||||||
{ label: '否', value: 'N' }
|
{ value: 'C', label: 'C类' }
|
||||||
]
|
]
|
||||||
},
|
}),
|
||||||
{
|
|
||||||
label: 'SN管理',
|
// ===== 库存信息 =====
|
||||||
|
stockScanField('inventory', {
|
||||||
|
value: 'quantity',
|
||||||
|
label: '库存数量',
|
||||||
|
type: 'number',
|
||||||
|
placeholder: '请输入库存数量',
|
||||||
|
operators: ['eq', 'ne', 'gt', 'lt', 'ge', 'le', 'between'],
|
||||||
|
defaultOperator: 'ge'
|
||||||
|
}),
|
||||||
|
|
||||||
|
// ===== 管理标识 =====
|
||||||
|
stockScanField('management', {
|
||||||
value: 'is_sn_mgmt',
|
value: 'is_sn_mgmt',
|
||||||
type: 'select',
|
label: '序列号管理',
|
||||||
group: '流程状态',
|
type: 'boolean',
|
||||||
options: [
|
placeholder: '请选择是否序列号管理'
|
||||||
{ label: '全部', value: undefined },
|
}),
|
||||||
{ label: '是', value: 'Y' },
|
stockScanField('management', {
|
||||||
{ label: '否', value: 'N' }
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '保质期管理',
|
|
||||||
value: 'is_shelf_life_mgmt',
|
value: 'is_shelf_life_mgmt',
|
||||||
type: 'select',
|
label: '保质期管理',
|
||||||
group: '流程状态',
|
type: 'boolean',
|
||||||
options: [
|
placeholder: '请选择是否保质期管理'
|
||||||
{ label: '全部', value: undefined },
|
}),
|
||||||
{ label: '是', value: 'Y' },
|
stockScanField('management', {
|
||||||
{ label: '否', value: 'N' }
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '批次管理',
|
|
||||||
value: 'is_batch_mgmt',
|
value: 'is_batch_mgmt',
|
||||||
type: 'select',
|
label: '批次管理',
|
||||||
group: '流程状态',
|
type: 'boolean',
|
||||||
options: [
|
placeholder: '请选择是否批次管理'
|
||||||
{ label: '全部', value: undefined },
|
})
|
||||||
{ label: '是', value: 'Y' },
|
|
||||||
{ label: '否', value: 'N' }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
|
|
||||||
const presetTree: any[] = []
|
const presetTree: any[] = []
|
||||||
@ -451,7 +447,7 @@ const scanBox = ref<any>(null)
|
|||||||
const activeTab = ref('info')
|
const activeTab = ref('info')
|
||||||
|
|
||||||
const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
||||||
const queryForm = reactive({ keyword: '', warehouse_id: undefined as number | string | undefined })
|
const queryForm = reactive({ warehouse_id: undefined as number | string | undefined })
|
||||||
const currentCondition = ref<any>({})
|
const currentCondition = ref<any>({})
|
||||||
const currentSort = reactive({ prop: '', order: '' })
|
const currentSort = reactive({ prop: '', order: '' })
|
||||||
const summary = ref<any>(null)
|
const summary = ref<any>(null)
|
||||||
@ -480,10 +476,7 @@ const {
|
|||||||
|
|
||||||
function buildExportPayload() {
|
function buildExportPayload() {
|
||||||
const payload: any = {
|
const payload: any = {
|
||||||
where: { ...currentCondition.value }
|
where: buildStockQuery(currentCondition.value)
|
||||||
}
|
|
||||||
if (queryForm.keyword) {
|
|
||||||
payload.where.keyword = queryForm.keyword
|
|
||||||
}
|
}
|
||||||
if (queryForm.warehouse_id !== undefined && queryForm.warehouse_id !== null && queryForm.warehouse_id !== '') {
|
if (queryForm.warehouse_id !== undefined && queryForm.warehouse_id !== null && queryForm.warehouse_id !== '') {
|
||||||
payload.warehouse_id = queryForm.warehouse_id
|
payload.warehouse_id = queryForm.warehouse_id
|
||||||
@ -624,9 +617,6 @@ function handleToolbarButtonClick(action: ToolbarButtonConfig['action']) {
|
|||||||
handler()
|
handler()
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─── 特殊字段键(不作为 where 条件,需要单独提取)──────────────────────
|
|
||||||
const SPECIAL_KEYS = ['keyword', 'warehouse_id']
|
|
||||||
|
|
||||||
// ─── 加载列表 ──────────────────────────────────────────────────────────────
|
// ─── 加载列表 ──────────────────────────────────────────────────────────────
|
||||||
async function loadList() {
|
async function loadList() {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
@ -636,10 +626,7 @@ async function loadList() {
|
|||||||
page: pagination.currentPage,
|
page: pagination.currentPage,
|
||||||
pageSize: pagination.pageSize
|
pageSize: pagination.pageSize
|
||||||
},
|
},
|
||||||
where: { ...currentCondition.value }
|
where: buildStockQuery(currentCondition.value)
|
||||||
}
|
|
||||||
if (queryForm.keyword) {
|
|
||||||
params.where.keyword = queryForm.keyword
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const sort: StockWarehouseListSort | undefined = currentSort.prop
|
const sort: StockWarehouseListSort | undefined = currentSort.prop
|
||||||
@ -672,41 +659,14 @@ async function loadList() {
|
|||||||
|
|
||||||
// ─── 事件处理 ──────────────────────────────────────────────────────────────
|
// ─── 事件处理 ──────────────────────────────────────────────────────────────
|
||||||
function handleConditionChange(condition: any) {
|
function handleConditionChange(condition: any) {
|
||||||
const where: any = {}
|
// ScanBox 直接下发 { field: { value, operator, type } } 结构,
|
||||||
// 重置特殊字段
|
// 原样保留,交由 buildStockQuery 转为后端 where 规范,避免丢失操作符/类型
|
||||||
queryForm.keyword = ''
|
currentCondition.value = condition && typeof condition === 'object' ? condition : {}
|
||||||
queryForm.warehouse_id = undefined
|
|
||||||
|
|
||||||
if (condition) {
|
|
||||||
Object.keys(condition).forEach(k => {
|
|
||||||
if (SPECIAL_KEYS.includes(k)) {
|
|
||||||
// 关键词、仓库 从 condition 提取到 queryForm
|
|
||||||
const c = condition[k]
|
|
||||||
const val = (c && typeof c === 'object' && c.value !== undefined) ? c.value : c
|
|
||||||
if (k === 'keyword' && val) {
|
|
||||||
queryForm.keyword = val
|
|
||||||
} else if (k === 'warehouse_id' && val !== undefined && val !== null && val !== '') {
|
|
||||||
queryForm.warehouse_id = val
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const c = condition[k]
|
|
||||||
if (c && typeof c === 'object' && c.value !== undefined) {
|
|
||||||
if (c.value !== '' && c.value !== null) {
|
|
||||||
where[k] = c.value
|
|
||||||
}
|
|
||||||
} else if (c !== '' && c !== null && c !== undefined) {
|
|
||||||
where[k] = c
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
currentCondition.value = where
|
|
||||||
pagination.currentPage = 1
|
pagination.currentPage = 1
|
||||||
loadList()
|
loadList()
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleReset() {
|
function handleReset() {
|
||||||
queryForm.keyword = ''
|
|
||||||
currentCondition.value = {}
|
currentCondition.value = {}
|
||||||
if (scanBox.value?.reset) {
|
if (scanBox.value?.reset) {
|
||||||
scanBox.value.reset()
|
scanBox.value.reset()
|
||||||
|
|||||||
@ -111,6 +111,7 @@ import { ref, reactive, onMounted, watch } from 'vue'
|
|||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
import { Search, Delete, RefreshLeft, Refresh } from '@element-plus/icons-vue'
|
import { Search, Delete, RefreshLeft, Refresh } from '@element-plus/icons-vue'
|
||||||
import * as stockApi from '@/api/stock/stock'
|
import * as stockApi from '@/api/stock/stock'
|
||||||
|
import { buildStockQuery } from '@/utils/stockQueryBuilder'
|
||||||
import { parseTime } from '@/utils/index'
|
import { parseTime } from '@/utils/index'
|
||||||
import { formatBarcodeText } from '@/utils/barcode'
|
import { formatBarcodeText } from '@/utils/barcode'
|
||||||
|
|
||||||
@ -217,11 +218,12 @@ const loadData = async () => {
|
|||||||
if (loading.value) return
|
if (loading.value) return
|
||||||
loading.value = true
|
loading.value = true
|
||||||
try {
|
try {
|
||||||
const params: any = {
|
// where 统一按 stock.warehouse.list 规范:{ 字段: { operator, value, type } }
|
||||||
|
const params: any = buildStockQuery({
|
||||||
is_deleted: 1, // Assuming backend supports this flag for recycle bin
|
is_deleted: 1, // Assuming backend supports this flag for recycle bin
|
||||||
keyword: searchKeyword.value,
|
keyword: searchKeyword.value,
|
||||||
type: filterType.value
|
type: filterType.value
|
||||||
}
|
})
|
||||||
const response = await stockApi.stockWarehouse(pagination, params)
|
const response = await stockApi.stockWarehouse(pagination, params)
|
||||||
if (response && (response as any).code === 200) {
|
if (response && (response as any).code === 200) {
|
||||||
list.value = (response as any).data.list || []
|
list.value = (response as any).data.list || []
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user