const TYPE_OPTIONS = [
|
{ label: '库存调整', value: 0, tagType: 'primary' },
|
{ label: '盘点调整', value: 1, tagType: 'warning' },
|
{ label: '其它调整', value: 2, tagType: 'info' }
|
]
|
|
const STATUS_OPTIONS = [
|
{ label: '正常', value: 1, tagType: 'success' },
|
{ label: '冻结', value: 0, tagType: 'danger' }
|
]
|
|
function normalizeText(value) {
|
return typeof value === 'string' ? value.trim() : value
|
}
|
|
function normalizeNumber(value, fallback = void 0) {
|
if (value === '' || value === null || value === undefined) {
|
return fallback
|
}
|
const numericValue = Number(value)
|
return Number.isFinite(numericValue) ? numericValue : fallback
|
}
|
|
function pickText(record, keys, fallback = '-') {
|
for (const key of keys) {
|
const value = record?.[key]
|
if (typeof value === 'string' && value.trim()) {
|
return value.trim()
|
}
|
}
|
return fallback
|
}
|
|
export const REVISE_LOG_REPORT_TITLE = '库位调整日志'
|
export const REVISE_LOG_REPORT_STYLE = {
|
titleAlign: 'center',
|
titleLevel: 'strong',
|
orientation: 'landscape',
|
density: 'compact',
|
showSequence: true
|
}
|
|
export function getReviseLogTypeOptions() {
|
return TYPE_OPTIONS
|
}
|
|
export function getReviseLogStatusOptions() {
|
return STATUS_OPTIONS
|
}
|
|
export function getReviseLogPaginationKey() {
|
return {
|
current: 'current',
|
size: 'pageSize'
|
}
|
}
|
|
export function createReviseLogSearchState() {
|
return {
|
condition: '',
|
reviseId: '',
|
reviseCode: '',
|
warehouseId: '',
|
areaId: '',
|
type: '',
|
barcode: '',
|
useStatus: '',
|
channel: '',
|
row: '',
|
col: '',
|
lev: '',
|
memo: '',
|
status: '',
|
timeStart: '',
|
timeEnd: ''
|
}
|
}
|
|
export function buildReviseLogSearchParams(params = {}) {
|
const result = {}
|
;[
|
'condition',
|
'reviseCode',
|
'barcode',
|
'useStatus',
|
'memo',
|
'timeStart',
|
'timeEnd'
|
].forEach((key) => {
|
const value = normalizeText(params[key])
|
if (value) {
|
result[key] = value
|
}
|
})
|
|
;['reviseId', 'warehouseId', 'areaId', 'type', 'channel', 'row', 'col', 'lev', 'status'].forEach(
|
(key) => {
|
const value = normalizeNumber(params[key], void 0)
|
if (value !== void 0) {
|
result[key] = value
|
}
|
}
|
)
|
|
return result
|
}
|
|
export function buildReviseLogPageQueryParams(params = {}) {
|
return {
|
current: params.current || 1,
|
pageSize: params.pageSize || params.size || 20,
|
...buildReviseLogSearchParams(params)
|
}
|
}
|
|
export function getReviseLogTypeMeta(value) {
|
const target = TYPE_OPTIONS.find((item) => Number(item.value) === Number(value))
|
return target || { label: '-', value, tagType: 'info' }
|
}
|
|
export function getReviseLogStatusMeta(value) {
|
const target = STATUS_OPTIONS.find((item) => Number(item.value) === Number(value))
|
return target || { label: '-', value, tagType: 'info' }
|
}
|
|
export function normalizeReviseLogRow(record = {}) {
|
const typeMeta = getReviseLogTypeMeta(record.type)
|
const statusMeta = getReviseLogStatusMeta(record.status)
|
return {
|
...record,
|
reviseId: normalizeNumber(record.reviseId, record.reviseId),
|
reviseCode: pickText(record, ['reviseCode', 'code']),
|
warehouseLabel: pickText(record, ['warehouseId$', 'warehouseName', 'warehouseLabel']),
|
areaLabel: pickText(record, ['areaId$', 'areaName', 'areaLabel']),
|
locCode: pickText(record, ['locCode']),
|
typeLabel: pickText(record, ['type$'], typeMeta.label),
|
barcode: pickText(record, ['barcode']),
|
useStatusText: pickText(record, ['useStatus$'], record.useStatus || '-'),
|
channelText: pickText(record, ['channel$'], record.channel ?? '-'),
|
rowText: pickText(record, ['row$'], record.row ?? '-'),
|
colText: pickText(record, ['col$'], record.col ?? '-'),
|
levText: pickText(record, ['lev$'], record.lev ?? '-'),
|
statusText: pickText(record, ['status$'], statusMeta.label),
|
statusTagType: statusMeta.tagType,
|
createByText: pickText(record, ['createBy$']),
|
createTimeText: pickText(record, ['createTime$'], record.createTime || '-'),
|
updateByText: pickText(record, ['updateBy$']),
|
updateTimeText: pickText(record, ['updateTime$'], record.updateTime || '-'),
|
memo: pickText(record, ['memo'], '-')
|
}
|
}
|