import request from '@/utils/http'
|
|
function normalizeText(value) {
|
return typeof value === 'string' ? value.trim() : value
|
}
|
|
function normalizeIds(ids) {
|
if (Array.isArray(ids)) {
|
return ids
|
.map((id) => String(id).trim())
|
.filter(Boolean)
|
.join(',')
|
}
|
|
if (ids === null || ids === undefined) {
|
return ''
|
}
|
|
return String(ids).trim()
|
}
|
|
function buildSearchParams(params = {}) {
|
const result = {}
|
|
;[
|
'condition',
|
'type',
|
'asnCode',
|
'matnrCode',
|
'trackCode',
|
'batch',
|
'memo',
|
'fieldsIndex'
|
].forEach((key) => {
|
const value = normalizeText(params[key])
|
if (value) {
|
result[key] = value
|
}
|
})
|
|
;['pakinId', 'asnItemId', 'wkType', 'isptResult', 'status'].forEach((key) => {
|
if (params[key] === '' || params[key] === undefined || params[key] === null) {
|
return
|
}
|
|
const numericValue = Number(params[key])
|
if (!Number.isNaN(numericValue)) {
|
result[key] = numericValue
|
}
|
})
|
|
return result
|
}
|
|
export function buildWaitPakinItemPageParams(params = {}) {
|
return {
|
current: params.current || 1,
|
pageSize: params.pageSize || params.size || 20,
|
...buildSearchParams(params)
|
}
|
}
|
|
export function fetchWaitPakinItemPage(params = {}) {
|
return request.post({
|
url: '/waitPakinItem/page',
|
params: buildWaitPakinItemPageParams(params)
|
})
|
}
|
|
export function fetchWaitPakinItemList(params = {}) {
|
return request.post({
|
url: '/waitPakinItem/list',
|
data: buildSearchParams(params)
|
})
|
}
|
|
export function fetchWaitPakinItemMany(ids) {
|
return request.post({
|
url: `/waitPakinItem/many/${normalizeIds(ids)}`
|
})
|
}
|
|
export function fetchWaitPakinItemDetail(id) {
|
return request.get({
|
url: `/waitPakinItem/${id}`
|
})
|
}
|
|
export function fetchWaitPakinItemQuery(condition = '') {
|
return request.post({
|
url: '/waitPakinItem/query',
|
params: { condition: normalizeText(condition) }
|
})
|
}
|
|
export async function fetchExportWaitPakinItemReport(payload = {}, options = {}) {
|
return fetch(`${import.meta.env.VITE_API_URL}/waitPakinItem/export`, {
|
method: 'POST',
|
headers: {
|
'Content-Type': 'application/json',
|
...(options.headers || {})
|
},
|
body: JSON.stringify(payload)
|
})
|
}
|