import request from '@/utils/http'
|
|
function normalizeText(value) {
|
return typeof value === 'string' ? value.trim() : value
|
}
|
|
function normalizeNumber(value) {
|
if (value === '' || value === null || value === undefined) {
|
return null
|
}
|
const numericValue = Number(value)
|
return Number.isFinite(numericValue) ? numericValue : null
|
}
|
|
function withTextParam(target, key, value) {
|
const normalized = normalizeText(value)
|
if (normalized) {
|
target[key] = normalized
|
}
|
}
|
|
function withNumberParam(target, key, value) {
|
const normalized = normalizeNumber(value)
|
if (normalized !== null) {
|
target[key] = normalized
|
}
|
}
|
|
export function buildLocItemPageParams(params = {}) {
|
const payload = {
|
current: params.current || 1,
|
pageSize: params.pageSize || params.size || 20
|
}
|
|
;[
|
'condition',
|
'type',
|
'maktx',
|
'matnrCode',
|
'trackCode',
|
'unit',
|
'batch',
|
'splrBatch',
|
'spec',
|
'model',
|
'fieldsIndex',
|
'memo'
|
].forEach((key) => withTextParam(payload, key, params[key]))
|
|
;['locId', 'orderId', 'orderItemId', 'wkType', 'matnrId', 'anfme', 'status'].forEach((key) =>
|
withNumberParam(payload, key, params[key])
|
)
|
|
if (params.timeStart) {
|
payload.timeStart = params.timeStart
|
}
|
if (params.timeEnd) {
|
payload.timeEnd = params.timeEnd
|
}
|
|
return payload
|
}
|
|
export function fetchLocItemPage(params = {}) {
|
return request.post({
|
url: '/locItem/page',
|
params: buildLocItemPageParams(params)
|
})
|
}
|
|
export function fetchLocItemDetail(id) {
|
return request.get({
|
url: `/locItem/${id}`
|
})
|
}
|
|
export function fetchEnabledFields() {
|
return request.get({
|
url: '/fields/enable/list'
|
})
|
}
|