export const QLY_INSPECT_REPORT_TITLE = '质检信息报表'
|
export const QLY_INSPECT_REPORT_STYLE = {
|
titleAlign: 'center',
|
titleLevel: 'strong',
|
orientation: 'portrait',
|
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
|
}
|
|
export function createQlyInspectSearchState() {
|
return {
|
condition: '',
|
code: '',
|
wkType: '',
|
asnCode: '',
|
isptStatus: '',
|
isptQty: ''
|
}
|
}
|
|
export function buildQlyInspectSearchParams(params = {}) {
|
const result = {}
|
|
;['condition', 'code', 'wkType', 'asnCode', 'isptStatus', 'isptQty'].forEach((key) => {
|
const value = normalizeText(params[key])
|
if (value) {
|
result[key] = value
|
}
|
})
|
|
return result
|
}
|
|
export function buildQlyInspectPageQueryParams(params = {}) {
|
return {
|
current: params.current || 1,
|
pageSize: params.pageSize || params.size || 20,
|
...buildQlyInspectSearchParams(params)
|
}
|
}
|
|
export function buildQlyInspectItemsQueryParams(params = {}) {
|
return {
|
current: params.current || 1,
|
pageSize: params.pageSize || params.size || 20,
|
...(params.ispectId !== undefined ? { ispectId: params.ispectId } : {})
|
}
|
}
|
|
export function normalizeQlyInspectRow(record = {}) {
|
return {
|
...record,
|
code: record.code || '-',
|
wkTypeLabel: record['wkType$'] || record.wkType || '-',
|
asnId: record.asnId ?? '-',
|
asnCode: record.asnCode || '-',
|
isptQty: normalizeNumber(record.isptQty),
|
isptStatusText: record['isptStatus$'] || '-',
|
updateByText: record['updateBy$'] || '-',
|
updateTimeText: record['updateTime$'] || record.updateTime || '-',
|
createByText: record['createBy$'] || '-',
|
createTimeText: record['createTime$'] || record.createTime || '-',
|
statusText:
|
record.statusBool === true || Number(record.status) === 1
|
? '启用'
|
: record.statusBool === false || Number(record.status) === 0
|
? '停用'
|
: '-',
|
memo: record.memo || '-'
|
}
|
}
|
|
export function normalizeQlyInspectItemRow(record = {}) {
|
return {
|
...record,
|
ispectId: record.ispectId ?? '-',
|
matnrCode: record.matnrCode || '-',
|
maktx: record.maktx || '-',
|
label: record.label || '-',
|
splrBatch: record.splrBatch || '-',
|
stockBatch: record.stockBatch || '-',
|
rcptQty: normalizeNumber(record.rcptQty),
|
dlyQty: normalizeNumber(record.dlyQty),
|
anfme: normalizeNumber(record.anfme),
|
splrName: record.splrName || '-',
|
isptResultText: record['isptResult$'] || '-'
|
}
|
}
|
|
export function buildQlyInspectPrintRows(records = []) {
|
if (!Array.isArray(records)) {
|
return []
|
}
|
return records.map((record) => normalizeQlyInspectRow(record))
|
}
|
|
export function buildQlyInspectReportMeta({
|
previewMeta = {},
|
count = 0,
|
orientation = QLY_INSPECT_REPORT_STYLE.orientation
|
} = {}) {
|
return {
|
reportTitle: QLY_INSPECT_REPORT_TITLE,
|
reportDate: previewMeta.reportDate,
|
printedAt: previewMeta.printedAt,
|
operator: previewMeta.operator,
|
count,
|
reportStyle: {
|
...QLY_INSPECT_REPORT_STYLE,
|
orientation
|
}
|
}
|
}
|