const STATUS_META = {
|
1: { text: '正常', type: 'success', bool: true },
|
0: { text: '冻结', type: 'danger', bool: false }
|
}
|
|
const IO_STATUS_OPTIONS = [
|
{ label: '待入库', value: 0 },
|
{ label: '入库中', value: 1 },
|
{ label: '任务执行中', value: 2 },
|
{ label: '任务完成', value: 3 }
|
]
|
|
export const WAIT_PAKIN_REPORT_TITLE = '组托单报表'
|
export const WAIT_PAKIN_REPORT_STYLE = {
|
titleAlign: 'center',
|
titleLevel: 'strong',
|
orientation: 'portrait',
|
density: 'compact',
|
showSequence: true
|
}
|
|
function normalizeText(value) {
|
return String(value ?? '').trim()
|
}
|
|
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 normalizeObjectEntries(record = {}) {
|
return Object.fromEntries(
|
Object.entries(record)
|
.filter(([, value]) => value !== undefined && value !== null && value !== '')
|
.map(([key, value]) => [key, normalizeText(value)])
|
)
|
}
|
|
export function createWaitPakinSearchState() {
|
return {
|
condition: '',
|
code: '',
|
barcode: '',
|
ioStatus: '',
|
status: '',
|
memo: ''
|
}
|
}
|
|
export function getWaitPakinPaginationKey() {
|
return {
|
current: 'current',
|
size: 'pageSize'
|
}
|
}
|
|
export function getWaitPakinStatusOptions() {
|
return [
|
{ label: '正常', value: 1 },
|
{ label: '冻结', value: 0 }
|
]
|
}
|
|
export function getWaitPakinIoStatusOptions() {
|
return IO_STATUS_OPTIONS
|
}
|
|
export function getWaitPakinStatusMeta(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 buildWaitPakinSearchParams(params = {}) {
|
const searchParams = {
|
condition: normalizeText(params.condition),
|
code: normalizeText(params.code),
|
barcode: normalizeText(params.barcode),
|
ioStatus:
|
params.ioStatus !== undefined && params.ioStatus !== null && params.ioStatus !== ''
|
? normalizeNumber(params.ioStatus)
|
: void 0,
|
status:
|
params.status !== undefined && params.status !== null && params.status !== ''
|
? normalizeNumber(params.status)
|
: void 0,
|
memo: normalizeText(params.memo)
|
}
|
|
return Object.fromEntries(
|
Object.entries(searchParams).filter(
|
([, value]) => value !== '' && value !== void 0 && value !== null
|
)
|
)
|
}
|
|
export function buildWaitPakinPageQueryParams(params = {}) {
|
return {
|
current: params.current || 1,
|
pageSize: params.pageSize || params.size || 20,
|
...buildWaitPakinSearchParams(params)
|
}
|
}
|
|
export function normalizeWaitPakinDetailRecord(record = {}) {
|
const statusMeta = getWaitPakinStatusMeta(record.statusBool ?? record.status)
|
return {
|
...record,
|
code: normalizeText(record.code) || '--',
|
barcode: normalizeText(record.barcode) || '--',
|
anfme: record.anfme ?? '--',
|
ioStatus: record.ioStatus ?? void 0,
|
ioStatusText: normalizeText(record.ioStatus$ || record.ioStatusText) || '--',
|
flagDefectText:
|
record.flagDefect === 1 || record.flagDefect === '1'
|
? '是'
|
: record.flagDefect === 0 || record.flagDefect === '0'
|
? '否'
|
: '--',
|
statusText: statusMeta.text,
|
statusType: statusMeta.type,
|
statusBool: record.statusBool !== void 0 ? Boolean(record.statusBool) : statusMeta.bool,
|
memo: normalizeText(record.memo) || '--',
|
createByText: normalizeText(record.createBy$ || record.createByText || '') || '--',
|
createTimeText: normalizeText(record.createTime$ || record.createTime || '') || '--',
|
updateByText: normalizeText(record.updateBy$ || record.updateByText || '') || '--',
|
updateTimeText: normalizeText(record.updateTime$ || record.updateTime || '') || '--'
|
}
|
}
|
|
export function normalizeWaitPakinListRow(record = {}) {
|
return normalizeWaitPakinDetailRecord(record)
|
}
|
|
export function normalizeWaitPakinItemRow(record = {}) {
|
const extendFields =
|
record.extendFields && typeof record.extendFields === 'object' ? record.extendFields : {}
|
return {
|
...record,
|
pakinId: record.pakinId ?? '--',
|
maktx: normalizeText(record.maktx) || '--',
|
matnrId: record.matnrId ?? '--',
|
matnrCode: normalizeText(record.matnrCode) || '--',
|
asnCode: normalizeText(record.asnCode) || '--',
|
trackCode: normalizeText(record.trackCode) || '--',
|
anfme: record.anfme ?? '--',
|
workQty: record.workQty ?? '--',
|
unit: normalizeText(record.unit) || '--',
|
qty: record.qty ?? '--',
|
batch: normalizeText(record.batch) || '--',
|
isptResultText: normalizeText(record.isptResult$ || record.isptResultText) || '--',
|
memo: normalizeText(record.memo) || '--',
|
extendFieldsText: Object.keys(extendFields).length
|
? Object.entries(extendFields)
|
.map(([key, value]) => `${normalizeText(key)}:${normalizeText(value)}`)
|
.join(';')
|
: '--'
|
}
|
}
|
|
export function buildWaitPakinPrintRows(records = []) {
|
if (!Array.isArray(records)) {
|
return []
|
}
|
return records.map((record) => normalizeWaitPakinListRow(record))
|
}
|
|
export function buildWaitPakinReportMeta({
|
previewMeta = {},
|
count = 0,
|
orientation = WAIT_PAKIN_REPORT_STYLE.orientation
|
} = {}) {
|
return {
|
reportTitle: WAIT_PAKIN_REPORT_TITLE,
|
reportDate: previewMeta.reportDate,
|
printedAt: previewMeta.printedAt,
|
operator: previewMeta.operator,
|
count,
|
reportStyle: {
|
...WAIT_PAKIN_REPORT_STYLE,
|
orientation
|
}
|
}
|
}
|
|
export function createWaitPakinItemColumns() {
|
return [
|
{ type: 'globalIndex', label: '序号', width: 70, align: 'center' },
|
{ prop: 'maktx', label: '物料名称', minWidth: 180, showOverflowTooltip: true },
|
{ prop: 'matnrCode', label: '物料编码', minWidth: 140, showOverflowTooltip: true },
|
{ prop: 'asnCode', label: 'ASN单号', minWidth: 140, showOverflowTooltip: true },
|
{ prop: 'trackCode', label: '跟踪码', minWidth: 160, showOverflowTooltip: true },
|
{ prop: 'anfme', label: '数量', width: 100, align: 'right' },
|
{ prop: 'workQty', label: '执行中数量', width: 110, align: 'right' },
|
{ prop: 'qty', label: '已完成数量', width: 110, align: 'right' },
|
{ prop: 'unit', label: '单位', width: 90, align: 'center' },
|
{ prop: 'batch', label: '批次号', minWidth: 130, showOverflowTooltip: true },
|
{ prop: 'isptResultText', label: '质检结果', minWidth: 100, showOverflowTooltip: true },
|
{ prop: 'extendFieldsText', label: '扩展字段', minWidth: 220, showOverflowTooltip: true }
|
]
|
}
|
|
export function buildWaitPakinMergePayload(rows = [], siteId) {
|
return {
|
waitPakins: rows
|
.map((item) => {
|
if (item?.id === undefined || item?.id === null || item?.id === '') {
|
return null
|
}
|
return {
|
id: Number(item.id)
|
}
|
})
|
.filter(Boolean),
|
siteId: Number(siteId)
|
}
|
}
|
|
export function createWaitPakinSiteSearchState() {
|
return {
|
name: '',
|
site: '',
|
deviceSite: ''
|
}
|
}
|
|
export function buildWaitPakinSiteSearchParams(params = {}) {
|
return normalizeObjectEntries({
|
type: 1,
|
name: params.name,
|
site: params.site,
|
deviceSite: params.deviceSite
|
})
|
}
|
|
export function normalizeWaitPakinSiteRow(record = {}) {
|
return {
|
...record,
|
name: normalizeText(record.name) || '--',
|
site: normalizeText(record.site) || '--',
|
deviceSite: normalizeText(record.deviceSite) || '--',
|
wcsCode: normalizeText(record.wcsCode) || '--',
|
label: normalizeText(record.label) || '--',
|
updateTimeText: normalizeText(record.updateTime$ || record.updateTime || '') || '--'
|
}
|
}
|