export const TRANSFER_ITEM_REPORT_TITLE = '调拨明细报表'
|
export const TRANSFER_ITEM_REPORT_STYLE = {
|
titleAlign: 'center',
|
titleLevel: 'strong',
|
orientation: 'landscape',
|
density: 'compact',
|
showSequence: true,
|
showBorder: true
|
}
|
|
const STATUS_META = {
|
1: { text: '正常', type: 'success', bool: true },
|
0: { text: '冻结', type: 'danger', bool: false }
|
}
|
|
function normalizeText(value, fallback = '--') {
|
if (value === null || value === undefined || value === '') {
|
return fallback
|
}
|
const text = String(value).trim()
|
return text || fallback
|
}
|
|
function normalizeNumber(value, fallback = void 0) {
|
if (value === '' || value === null || value === undefined) {
|
return fallback
|
}
|
const parsed = Number(value)
|
return Number.isNaN(parsed) ? fallback : parsed
|
}
|
|
function pushText(target, key, value) {
|
const text = normalizeText(value, '')
|
if (text) {
|
target[key] = text
|
}
|
}
|
|
function pushNumber(target, key, value) {
|
const numericValue = normalizeNumber(value, void 0)
|
if (numericValue !== void 0) {
|
target[key] = numericValue
|
}
|
}
|
|
function getStatusMeta(status, statusText) {
|
const numericStatus = Number(status)
|
return STATUS_META[numericStatus] || {
|
text: normalizeText(statusText || status || '--'),
|
type: 'info',
|
bool: false
|
}
|
}
|
|
export function createTransferItemSearchState() {
|
return {
|
condition: '',
|
timeStart: '',
|
timeEnd: '',
|
transferId: '',
|
transferCode: '',
|
matnrId: '',
|
maktx: '',
|
matnrCode: '',
|
unit: '',
|
anfme: '',
|
qty: '',
|
workQty: '',
|
batch: '',
|
splrId: '',
|
spec: '',
|
model: '',
|
fieldsIndex: '',
|
platItemId: '',
|
platOrderCode: '',
|
platWorkCode: '',
|
projectCode: '',
|
memo: '',
|
status: ''
|
}
|
}
|
|
export function getTransferItemPaginationKey() {
|
return {
|
current: 'current',
|
size: 'pageSize'
|
}
|
}
|
|
export function getTransferItemStatusOptions() {
|
return [
|
{ label: '正常', value: 1 },
|
{ label: '冻结', value: 0 }
|
]
|
}
|
|
export function getTransferItemStatusMeta(status) {
|
if (status === true || Number(status) === 1) {
|
return STATUS_META[1]
|
}
|
if (status === false || Number(status) === 0) {
|
return STATUS_META[0]
|
}
|
return { text: '未知', type: 'info', bool: false }
|
}
|
|
export function buildTransferItemSearchParams(params = {}) {
|
const result = {}
|
|
;[
|
'condition',
|
'timeStart',
|
'timeEnd',
|
'transferCode',
|
'maktx',
|
'matnrCode',
|
'unit',
|
'batch',
|
'spec',
|
'model',
|
'fieldsIndex',
|
'platItemId',
|
'platOrderCode',
|
'platWorkCode',
|
'projectCode',
|
'memo'
|
].forEach((key) => pushText(result, key, params[key]))
|
|
;['transferId', 'matnrId', 'anfme', 'qty', 'workQty', 'splrId', 'status'].forEach((key) =>
|
pushNumber(result, key, params[key])
|
)
|
|
return result
|
}
|
|
export function buildTransferItemPageQueryParams(params = {}) {
|
return {
|
current: params.current || 1,
|
pageSize: params.pageSize || params.size || 20,
|
...buildTransferItemSearchParams(params)
|
}
|
}
|
|
export function normalizeTransferItemRow(record = {}) {
|
const statusMeta = getStatusMeta(record.statusBool ?? record.status, record['status$'] || record.statusText)
|
|
return {
|
...record,
|
id: record.id ?? null,
|
transferId: normalizeNumber(record.transferId, '--'),
|
transferCode: normalizeText(record.transferCode),
|
matnrId: normalizeNumber(record.matnrId, '--'),
|
maktx: normalizeText(record.maktx),
|
matnrCode: normalizeText(record.matnrCode),
|
unit: normalizeText(record.unit),
|
anfme: normalizeNumber(record.anfme, '--'),
|
qty: normalizeNumber(record.qty, '--'),
|
workQty: normalizeNumber(record.workQty, '--'),
|
batch: normalizeText(record.batch),
|
splrId: normalizeNumber(record.splrId, '--'),
|
splrCode: normalizeText(record.splrCode),
|
splrName: normalizeText(record.splrName),
|
spec: normalizeText(record.spec),
|
model: normalizeText(record.model),
|
fieldsIndex: normalizeText(record.fieldsIndex),
|
platItemId: normalizeText(record.platItemId),
|
platOrderCode: normalizeText(record.platOrderCode),
|
platWorkCode: normalizeText(record.platWorkCode),
|
projectCode: normalizeText(record.projectCode),
|
statusText: statusMeta.text,
|
statusType: statusMeta.type,
|
statusBool: record.statusBool !== void 0 ? Boolean(record.statusBool) : statusMeta.bool,
|
createByText: normalizeText(record['createBy$'] || record.createByText),
|
createTimeText: normalizeText(record['createTime$'] || record.createTimeText || record.createTime, '--'),
|
updateByText: normalizeText(record['updateBy$'] || record.updateByText),
|
updateTimeText: normalizeText(record['updateTime$'] || record.updateTimeText || record.updateTime, '--'),
|
memo: normalizeText(record.memo)
|
}
|
}
|
|
export function buildTransferItemPrintRows(records = []) {
|
if (!Array.isArray(records)) {
|
return []
|
}
|
return records.map((record) => normalizeTransferItemRow(record))
|
}
|
|
export function buildTransferItemReportMeta({
|
previewMeta = {},
|
count = 0,
|
orientation = TRANSFER_ITEM_REPORT_STYLE.orientation
|
} = {}) {
|
return {
|
reportTitle: TRANSFER_ITEM_REPORT_TITLE,
|
reportDate: previewMeta.reportDate,
|
printedAt: previewMeta.printedAt,
|
operator: previewMeta.operator,
|
count,
|
reportStyle: {
|
...TRANSFER_ITEM_REPORT_STYLE,
|
orientation
|
}
|
}
|
}
|