const TASK_TYPE_META = {
|
1: { text: '入库', type: 'success' }
|
}
|
|
const TASK_STATUS_META = {
|
98: { text: '入库完成', type: 'success' },
|
99: { text: '上报完成', type: 'warning' },
|
100: { text: '库存更新完成', type: 'success' },
|
101: { text: '创建出库任务', type: 'info' }
|
}
|
|
export const IN_STATISTIC_PAGE_TITLE = '入库统计'
|
|
function normalizeText(value) {
|
return String(value ?? '').trim()
|
}
|
|
function normalizeNumber(value, fallback = void 0) {
|
if (value === '' || value === null || value === undefined) {
|
return fallback
|
}
|
const numericValue = Number(value)
|
return Number.isFinite(numericValue) ? numericValue : fallback
|
}
|
|
export function createInStatisticSearchState() {
|
return {
|
condition: '',
|
dayTime: '',
|
maktx: '',
|
matnrCode: '',
|
batch: ''
|
}
|
}
|
|
export function getInStatisticPaginationKey() {
|
return {
|
current: 'current',
|
size: 'pageSize'
|
}
|
}
|
|
export function buildInStatisticSearchParams(params = {}) {
|
const searchParams = {
|
condition: normalizeText(params.condition),
|
dayTime: normalizeText(params.dayTime),
|
maktx: normalizeText(params.maktx),
|
matnrCode: normalizeText(params.matnrCode),
|
batch: normalizeText(params.batch),
|
taskType: normalizeNumber(params.taskType, 1),
|
taskStatus: normalizeNumber(params.taskStatus, 100)
|
}
|
|
return Object.fromEntries(
|
Object.entries(searchParams).filter(([, value]) => value !== '' && value !== void 0 && value !== null)
|
)
|
}
|
|
export function buildInStatisticPageQueryParams(params = {}) {
|
return {
|
current: params.current || 1,
|
pageSize: params.pageSize || params.size || 20,
|
...buildInStatisticSearchParams(params)
|
}
|
}
|
|
export function getInStatisticTaskTypeMeta(taskType) {
|
if (taskType === null || taskType === undefined || taskType === '') {
|
return { text: '入库', type: 'success' }
|
}
|
return TASK_TYPE_META[Number(taskType)] || { text: String(taskType), type: 'info' }
|
}
|
|
export function getInStatisticTaskStatusMeta(taskStatus) {
|
if (taskStatus === null || taskStatus === undefined || taskStatus === '') {
|
return { text: '-', type: 'info' }
|
}
|
return TASK_STATUS_META[Number(taskStatus)] || { text: String(taskStatus), type: 'info' }
|
}
|
|
export function normalizeInStatisticRow(record = {}) {
|
const taskTypeMeta = getInStatisticTaskTypeMeta(record.taskType ?? record.task_type)
|
const taskStatusMeta = getInStatisticTaskStatusMeta(record.taskStatus ?? record.task_status)
|
|
return {
|
...record,
|
id: record.id ?? '--',
|
dayTimeText: normalizeText(record.dayTime || record.day_time || ''),
|
taskTypeText: normalizeText(record.taskTypeText || record['taskType$'] || taskTypeMeta.text),
|
taskTypeTagType: normalizeText(record.taskTypeTagType || taskTypeMeta.type) || 'info',
|
taskStatusText: normalizeText(record.taskStatusText || record['taskStatus$'] || taskStatusMeta.text),
|
taskStatusTagType: normalizeText(record.taskStatusTagType || taskStatusMeta.type) || 'info',
|
locCode: normalizeText(record.locCode || record.loc_code || ''),
|
barcode: normalizeText(record.barcode || ''),
|
matnrCode: normalizeText(record.matnrCode || record.matnr_code || ''),
|
maktx: normalizeText(record.maktx || ''),
|
batch: normalizeText(record.batch || ''),
|
unit: normalizeText(record.unit || ''),
|
anfme: record.anfme ?? '--',
|
fieldsIndex: normalizeText(record.fieldsIndex || record.fields_index || ''),
|
createByText: normalizeText(record.createBy$ || record.createByText || record.createBy || ''),
|
createTimeText: normalizeText(record.createTime$ || record.createTime || ''),
|
updateByText: normalizeText(record.updateBy$ || record.updateByText || record.updateBy || ''),
|
updateTimeText: normalizeText(record.updateTime$ || record.updateTime || ''),
|
memo: normalizeText(record.memo || '')
|
}
|
}
|