import request from '@/utils/http' function normalizeText(value) { return String(value ?? '').trim() } function normalizeQueryParams(params = {}) { const result = { current: params.current || 1, pageSize: params.pageSize || params.size || 20 } ;['condition', 'code', 'name', 'spec', 'model', 'color', 'size', 'barcode', 'groupId'].forEach((key) => { const value = params[key] if (value === undefined || value === null || value === '') { return } if (typeof value === 'string') { const trimmed = normalizeText(value) if (trimmed) { result[key] = trimmed } return } result[key] = value }) return result } function normalizeGroupTreeParams(params = {}) { return { condition: normalizeText(params.condition) } } export function fetchMatnrPage(params = {}) { return request.post({ url: '/matnr/page', params: normalizeQueryParams(params) }) } export function fetchMatnrDetail(id) { return request.get({ url: `/matnr/${id}` }) } export function fetchMatnrGroupTree(params = {}) { return request.post({ url: '/matnrGroup/tree', params: normalizeGroupTreeParams(params) }) }