export const LOC_REVISE_REPORT_TITLE = '库存调整报表'
|
export const LOC_REVISE_REPORT_STYLE = {
|
titleAlign: 'center',
|
titleLevel: 'strong',
|
orientation: 'landscape',
|
density: 'compact',
|
showSequence: true
|
}
|
|
const TYPE_OPTIONS = [
|
{ label: '库存调整', value: 0 },
|
{ label: '盘点调整', value: 1 },
|
{ label: '其它调整', value: 2 }
|
]
|
|
const EXCE_STATUS_OPTIONS = [
|
{ label: '未执行', value: 0, tagType: 'info' },
|
{ label: '执行中', value: 1, tagType: 'warning' },
|
{ label: '执行完成', value: 2, tagType: 'success' }
|
]
|
|
function normalizeText(value) {
|
return String(value ?? '').trim()
|
}
|
|
function normalizeNumber(value, fallback = 0) {
|
if (value === '' || value === null || value === undefined) {
|
return fallback
|
}
|
const numericValue = Number(value)
|
return Number.isFinite(numericValue) ? numericValue : fallback
|
}
|
|
export function getLocReviseTypeOptions() {
|
return TYPE_OPTIONS
|
}
|
|
export function getLocReviseExceStatusOptions() {
|
return EXCE_STATUS_OPTIONS
|
}
|
|
export function createLocReviseSearchState() {
|
return {
|
condition: '',
|
code: '',
|
type: '',
|
areaName: '',
|
exceStatus: '',
|
timeStart: '',
|
timeEnd: ''
|
}
|
}
|
|
export function createLocReviseFormState() {
|
return {
|
id: null,
|
code: '',
|
type: 0,
|
areaId: '',
|
exceTime: '',
|
memo: '',
|
status: 1
|
}
|
}
|
|
export function buildLocReviseDialogModel(record = {}) {
|
const model = createLocReviseFormState()
|
return {
|
...model,
|
...record,
|
id: record.id ?? null,
|
code: record.code || '',
|
type: record.type ?? 0,
|
areaId: record.areaId ?? '',
|
exceTime: record.exceTime || '',
|
memo: record.memo || '',
|
status: record.status ?? 1
|
}
|
}
|
|
export function buildLocReviseSearchParams(params = {}) {
|
const result = {}
|
;['condition', 'code', 'areaName', 'timeStart', 'timeEnd'].forEach((key) => {
|
const value = normalizeText(params[key])
|
if (value) {
|
result[key] = value
|
}
|
})
|
|
if (params.type !== '' && params.type !== null && params.type !== undefined) {
|
result.type = normalizeNumber(params.type)
|
}
|
if (params.exceStatus !== '' && params.exceStatus !== null && params.exceStatus !== undefined) {
|
result.exceStatus = normalizeNumber(params.exceStatus)
|
}
|
|
return result
|
}
|
|
export function buildLocRevisePageQueryParams(params = {}) {
|
return {
|
current: params.current || 1,
|
pageSize: params.pageSize || params.size || 20,
|
...buildLocReviseSearchParams(params)
|
}
|
}
|
|
export function buildReviseLogPageQueryParams(params = {}) {
|
return {
|
current: params.current || 1,
|
pageSize: params.pageSize || params.size || 20,
|
...(params.reviseId !== undefined ? { reviseId: params.reviseId } : {})
|
}
|
}
|
|
export function buildReviseLogItemPageQueryParams(params = {}) {
|
return {
|
current: params.current || 1,
|
pageSize: params.pageSize || params.size || 20,
|
...(params.reviseLogId !== undefined ? { reviseLogId: params.reviseLogId } : {})
|
}
|
}
|
|
export function buildLocReviseSavePayload(formData = {}) {
|
return {
|
...(formData.id ? { id: formData.id } : {}),
|
...(formData.code ? { code: formData.code } : {}),
|
type: normalizeNumber(formData.type),
|
areaId: normalizeNumber(formData.areaId, null),
|
...(normalizeText(formData.exceTime) ? { exceTime: normalizeText(formData.exceTime) } : {}),
|
...(normalizeText(formData.memo) ? { memo: normalizeText(formData.memo) } : {}),
|
status: formData.status === 0 ? 0 : 1
|
}
|
}
|
|
export function resolveWarehouseAreaOptions(records = []) {
|
if (!Array.isArray(records)) {
|
return []
|
}
|
return records.map((record) => ({
|
label: record.name || record.code || `库区${record.id}`,
|
value: record.id
|
}))
|
}
|
|
function resolveOptionLabel(options, value, fallback = '-') {
|
const target = options.find((item) => Number(item.value) === Number(value))
|
return target?.label || fallback
|
}
|
|
export function getLocReviseExceStatusMeta(value) {
|
const target = EXCE_STATUS_OPTIONS.find((item) => Number(item.value) === Number(value))
|
return target || { label: '-', value, tagType: 'info' }
|
}
|
|
export function normalizeLocReviseRow(record = {}) {
|
const exceStatusMeta = getLocReviseExceStatusMeta(record.exceStatus)
|
return {
|
...record,
|
code: record.code || '-',
|
typeLabel: record['type$'] || resolveOptionLabel(TYPE_OPTIONS, record.type),
|
areaLabel: record.areaName || record['areaId$'] || '-',
|
anfme: normalizeNumber(record.anfme),
|
reviseQty: normalizeNumber(record.reviseQty),
|
exceStatusText: record['exceStatus$'] || exceStatusMeta.label,
|
exceStatusTagType: exceStatusMeta.tagType,
|
updateByText: record['updateBy$'] || '-',
|
updateTimeText: record['updateTime$'] || record.updateTime || '-',
|
createByText: record['createBy$'] || '-',
|
createTimeText: record['createTime$'] || record.createTime || '-',
|
exceTimeText: record['exceTime$'] || record.exceTime || '-',
|
memo: record.memo || '-'
|
}
|
}
|
|
export function normalizeReviseLogRow(record = {}) {
|
return {
|
...record,
|
reviseCode: record.reviseCode || '-',
|
locCode: record.locCode || record.barcode || '-',
|
barcode: record.barcode || '-',
|
typeLabel: record['type$'] || '-',
|
useStatusLabel: record['useStatus$'] || record.useStatus || '-',
|
updateByText: record['updateBy$'] || '-',
|
updateTimeText: record['updateTime$'] || record.updateTime || '-'
|
}
|
}
|
|
export function normalizeReviseLogItemRow(record = {}) {
|
const diffQty = normalizeNumber(
|
record.diffQty,
|
normalizeNumber(record.reviseQty) - normalizeNumber(record.anfme)
|
)
|
return {
|
...record,
|
locCode: record.locCode || '-',
|
matnrCode: record.matnrCode || '-',
|
maktx: record.maktx || '-',
|
unit: record.unit || '-',
|
anfme: normalizeNumber(record.anfme),
|
reviseQty: normalizeNumber(record.reviseQty),
|
diffQty,
|
batch: record.batch || '-',
|
spec: record.spec || '-',
|
model: record.model || '-',
|
updateTimeText: record['updateTime$'] || record.updateTime || '-'
|
}
|
}
|
|
export function buildLocRevisePrintRows(records = []) {
|
if (!Array.isArray(records)) {
|
return []
|
}
|
return records.map((record) => normalizeLocReviseRow(record))
|
}
|
|
export function buildLocReviseReportMeta({
|
previewMeta = {},
|
count = 0,
|
orientation = LOC_REVISE_REPORT_STYLE.orientation
|
} = {}) {
|
return {
|
reportTitle: LOC_REVISE_REPORT_TITLE,
|
reportDate: previewMeta.reportDate,
|
printedAt: previewMeta.printedAt,
|
operator: previewMeta.operator,
|
count,
|
reportStyle: {
|
...LOC_REVISE_REPORT_STYLE,
|
orientation
|
}
|
}
|
}
|