export const WAIT_PAKIN_LOG_REPORT_TITLE = '组托历史档报表'
|
export const WAIT_PAKIN_LOG_REPORT_STYLE = {
|
titleAlign: 'center',
|
titleLevel: 'strong',
|
orientation: 'landscape',
|
density: 'compact',
|
showSequence: true
|
}
|
|
const IO_STATUS_MAP = {
|
0: { label: '待入库', tagType: 'info' },
|
1: { label: '入库中', tagType: 'warning' },
|
2: { label: '任务执行中', tagType: 'warning' },
|
3: { label: '任务完成', tagType: 'success' }
|
}
|
|
function normalizeText(value) {
|
return String(value ?? '').trim()
|
}
|
|
function normalizeNumber(value) {
|
if (value === '' || value === null || value === undefined) {
|
return 0
|
}
|
const numericValue = Number(value)
|
return Number.isFinite(numericValue) ? numericValue : 0
|
}
|
|
function getIoStatusConfig(status, statusText) {
|
const numericStatus = Number(status)
|
const fallback = IO_STATUS_MAP[numericStatus] || {
|
label: statusText || '-',
|
tagType: 'info'
|
}
|
return {
|
label: statusText || fallback.label,
|
tagType: fallback.tagType
|
}
|
}
|
|
export function createWaitPakinLogSearchState() {
|
return {
|
condition: '',
|
pakinId: '',
|
code: '',
|
barcode: '',
|
ioStatus: ''
|
}
|
}
|
|
export function buildWaitPakinLogSearchParams(params = {}) {
|
const result = {}
|
|
;['condition', 'code', 'barcode'].forEach((key) => {
|
const value = normalizeText(params[key])
|
if (value) {
|
result[key] = value
|
}
|
})
|
|
if (params.pakinId !== '' && params.pakinId !== undefined && params.pakinId !== null) {
|
result.pakinId = Number(params.pakinId)
|
}
|
|
if (params.ioStatus !== '' && params.ioStatus !== undefined && params.ioStatus !== null) {
|
result.ioStatus = Number(params.ioStatus)
|
}
|
|
return result
|
}
|
|
export function buildWaitPakinLogPageQueryParams(params = {}) {
|
return {
|
current: params.current || 1,
|
pageSize: params.pageSize || params.size || 20,
|
...buildWaitPakinLogSearchParams(params)
|
}
|
}
|
|
export function buildWaitPakinLogDetailQueryParams(params = {}) {
|
return {
|
logId: params.logId,
|
current: params.current || 1,
|
pageSize: params.pageSize || params.size || 20
|
}
|
}
|
|
export function normalizeWaitPakinLogRow(record = {}) {
|
const ioStatusConfig = getIoStatusConfig(record.ioStatus, record['ioStatus$'])
|
return {
|
...record,
|
id: record.id ?? null,
|
pakinId: record.pakinId ?? '-',
|
code: record.code || '-',
|
barcode: record.barcode || '-',
|
anfme: normalizeNumber(record.anfme),
|
ioStatusText: ioStatusConfig.label,
|
ioStatusTagType: ioStatusConfig.tagType,
|
updateByText: record['updateBy$'] || '-',
|
updateTimeText: record['updateTime$'] || record.updateTime || '-',
|
createByText: record['createBy$'] || '-',
|
createTimeText: record['createTime$'] || record.createTime || '-',
|
statusText:
|
record.statusBool === true || Number(record.status) === 1
|
? '正常'
|
: record.statusBool === false || Number(record.status) === 0
|
? '冻结'
|
: '-',
|
memo: record.memo || '-'
|
}
|
}
|
|
export function normalizeWaitPakinItemLogRow(record = {}) {
|
return {
|
...record,
|
id: record.id ?? null,
|
pakinId: record.pakinId ?? '-',
|
pakinItemId: record.pakinItemId ?? '-',
|
asnId: record.asnId ?? '-',
|
asnCode: record.asnCode || '-',
|
asnItemId: record.asnItemId ?? '-',
|
trackCode: record.trackCode || '-',
|
maktx: record.maktx || '-',
|
matnrCode: record.matnrCode || '-',
|
anfme: normalizeNumber(record.anfme),
|
workQty: normalizeNumber(record.workQty),
|
unit: record.unit || '-',
|
qty: normalizeNumber(record.qty),
|
batch: record.batch || '-',
|
updateByText: record['updateBy$'] || '-',
|
updateTimeText: record['updateTime$'] || record.updateTime || '-'
|
}
|
}
|
|
export function buildWaitPakinLogPrintRows(records = []) {
|
if (!Array.isArray(records)) {
|
return []
|
}
|
return records.map((record) => normalizeWaitPakinLogRow(record))
|
}
|
|
export function buildWaitPakinLogReportMeta({
|
previewMeta = {},
|
count = 0,
|
orientation = WAIT_PAKIN_LOG_REPORT_STYLE.orientation
|
} = {}) {
|
return {
|
reportTitle: WAIT_PAKIN_LOG_REPORT_TITLE,
|
reportDate: previewMeta.reportDate,
|
printedAt: previewMeta.printedAt,
|
operator: previewMeta.operator,
|
count,
|
reportStyle: {
|
...WAIT_PAKIN_LOG_REPORT_STYLE,
|
orientation
|
}
|
}
|
}
|
|
export function getWaitPakinIoStatusOptions() {
|
return Object.entries(IO_STATUS_MAP).map(([value, item]) => ({
|
label: item.label,
|
value: Number(value)
|
}))
|
}
|