export const WAVE_ITEM_REPORT_TITLE = '波次明细报表'
|
export const WAVE_ITEM_REPORT_STYLE = {
|
titleAlign: 'center',
|
titleLevel: 'strong',
|
orientation: 'landscape',
|
density: 'compact',
|
showSequence: true
|
}
|
|
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
|
}
|
|
const WAVE_ITEM_STATUS_MAP = {
|
0: { label: '未执行', tagType: 'info' },
|
1: { label: '执行中', tagType: 'warning' },
|
2: { label: '暂停', tagType: 'warning' },
|
3: { label: '已下发', tagType: 'primary' },
|
4: { label: '任务完成', tagType: 'success' }
|
}
|
|
function getItemStatusConfig(status, statusText) {
|
const fallback = WAVE_ITEM_STATUS_MAP[Number(status)] || {
|
label: statusText || '-',
|
tagType: 'info'
|
}
|
return {
|
label: statusText || fallback.label,
|
tagType: fallback.tagType
|
}
|
}
|
|
function normalizeStockLocs(stockLocs) {
|
if (!stockLocs) {
|
return '[]'
|
}
|
if (typeof stockLocs === 'string') {
|
return stockLocs
|
}
|
try {
|
return JSON.stringify(stockLocs)
|
} catch {
|
return '[]'
|
}
|
}
|
|
export function createWaveItemSearchState() {
|
return {
|
condition: '',
|
waveId: '',
|
waveCode: '',
|
orderCode: '',
|
matnrCode: '',
|
maktx: '',
|
batch: '',
|
splrBatch: '',
|
unit: '',
|
fieldsIndex: '',
|
status: '',
|
exceStatus: '',
|
timeStart: '',
|
timeEnd: ''
|
}
|
}
|
|
export function buildWaveItemSearchParams(params = {}) {
|
const result = {}
|
;[
|
'condition',
|
'waveCode',
|
'orderCode',
|
'matnrCode',
|
'maktx',
|
'batch',
|
'splrBatch',
|
'unit',
|
'fieldsIndex',
|
'timeStart',
|
'timeEnd'
|
].forEach((key) => {
|
const value = normalizeText(params[key])
|
if (value) {
|
result[key] = value
|
}
|
})
|
|
if (params.waveId !== '' && params.waveId !== undefined && params.waveId !== null) {
|
result.waveId = Number(params.waveId)
|
}
|
|
if (params.status !== '' && params.status !== undefined && params.status !== null) {
|
result.status = Number(params.status)
|
}
|
|
if (params.exceStatus !== '' && params.exceStatus !== undefined && params.exceStatus !== null) {
|
result.exceStatus = Number(params.exceStatus)
|
}
|
|
return result
|
}
|
|
export function buildWaveItemPageQueryParams(params = {}) {
|
return {
|
current: params.current || 1,
|
pageSize: params.pageSize || params.size || 20,
|
...buildWaveItemSearchParams(params)
|
}
|
}
|
|
export function normalizeWaveItemRow(record = {}) {
|
const statusConfig = getItemStatusConfig(record.exceStatus, record['exceStatus$'])
|
return {
|
...record,
|
waveCode: record.waveCode || '-',
|
orderCode: record.orderCode || '-',
|
matnrCode: record.matnrCode || '-',
|
maktx: record.maktx || '-',
|
batch: record.batch || '-',
|
splrBatch: record.splrBatch || '-',
|
unit: record.unit || '-',
|
fieldsIndex: record.fieldsIndex || '-',
|
anfme: normalizeNumber(record.anfme),
|
workQty: normalizeNumber(record.workQty),
|
qty: normalizeNumber(record.qty),
|
stockQty: normalizeNumber(record.stockQty),
|
stockLocsText: normalizeStockLocs(record.stockLocs),
|
exceStatusText: statusConfig.label,
|
exceStatusTagType: statusConfig.tagType,
|
createTimeText: record['createTime$'] || record.createTime || '-',
|
updateTimeText: record['updateTime$'] || record.updateTime || '-'
|
}
|
}
|
|
export function buildWaveItemPrintRows(records = []) {
|
if (!Array.isArray(records)) {
|
return []
|
}
|
return records.map((record) => normalizeWaveItemRow(record))
|
}
|
|
export function buildWaveItemReportMeta({
|
previewMeta = {},
|
count = 0,
|
orientation = WAVE_ITEM_REPORT_STYLE.orientation
|
} = {}) {
|
return {
|
reportTitle: WAVE_ITEM_REPORT_TITLE,
|
reportDate: previewMeta.reportDate,
|
printedAt: previewMeta.printedAt,
|
operator: previewMeta.operator,
|
count,
|
reportStyle: {
|
...WAVE_ITEM_REPORT_STYLE,
|
orientation
|
}
|
}
|
}
|