export const ASN_ORDER_LOG_REPORT_TITLE = '历史通知单报表'
|
export const ASN_ORDER_LOG_REPORT_STYLE = {
|
titleAlign: 'center',
|
titleLevel: 'strong',
|
orientation: 'landscape',
|
density: 'compact',
|
showSequence: true
|
}
|
|
const RLE_STATUS_META = {
|
0: { text: '正常', type: 'info' },
|
1: { text: '已释放', type: 'success' }
|
}
|
|
const NTY_STATUS_META = {
|
0: { text: '未上报', type: 'info' },
|
1: { text: '已上报', type: 'success' },
|
2: { text: '部分上报', type: 'warning' }
|
}
|
|
const STATUS_META = {
|
1: { text: '正常', type: 'success' },
|
0: { text: '冻结', type: 'danger' }
|
}
|
|
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 normalizeDateText(value) {
|
return normalizeText(value)
|
}
|
|
function getStatusMeta(value, map, fallbackText = '-') {
|
const numericValue = Number(value)
|
const meta = map[numericValue]
|
if (meta) {
|
return meta
|
}
|
const text = normalizeText(value)
|
if (!text) {
|
return { text: fallbackText, type: 'info' }
|
}
|
return { text, type: 'info' }
|
}
|
|
function normalizeTagText(value, map) {
|
const text = normalizeText(value)
|
if (text) {
|
return text
|
}
|
const numericValue = Number(value)
|
const meta = map[numericValue]
|
return meta?.text || '-'
|
}
|
|
export function createAsnOrderLogSearchState() {
|
return {
|
condition: '',
|
code: '',
|
poCode: '',
|
poId: '',
|
type: '',
|
wkType: '',
|
logisNo: '',
|
arrTime: '',
|
rleStatus: '',
|
ntyStatus: '',
|
exceStatus: '',
|
status: ''
|
}
|
}
|
|
export function buildAsnOrderLogSearchParams(params = {}) {
|
const searchParams = {
|
condition: normalizeText(params.condition),
|
code: normalizeText(params.code),
|
poCode: normalizeText(params.poCode),
|
poId:
|
params.poId !== undefined && params.poId !== null && params.poId !== ''
|
? normalizeNumber(params.poId)
|
: void 0,
|
type: normalizeText(params.type),
|
wkType: normalizeText(params.wkType),
|
logisNo: normalizeText(params.logisNo),
|
arrTime: normalizeText(params.arrTime),
|
rleStatus:
|
params.rleStatus !== undefined && params.rleStatus !== null && params.rleStatus !== ''
|
? normalizeNumber(params.rleStatus)
|
: void 0,
|
ntyStatus:
|
params.ntyStatus !== undefined && params.ntyStatus !== null && params.ntyStatus !== ''
|
? normalizeNumber(params.ntyStatus)
|
: void 0,
|
exceStatus:
|
params.exceStatus !== undefined && params.exceStatus !== null && params.exceStatus !== ''
|
? normalizeNumber(params.exceStatus)
|
: void 0,
|
status:
|
params.status !== undefined && params.status !== null && params.status !== ''
|
? normalizeNumber(params.status)
|
: void 0
|
}
|
|
return Object.fromEntries(
|
Object.entries(searchParams).filter(
|
([, value]) => value !== '' && value !== void 0 && value !== null
|
)
|
)
|
}
|
|
export function buildAsnOrderLogPageQueryParams(params = {}) {
|
return {
|
current: params.current || 1,
|
pageSize: params.pageSize || params.size || 20,
|
...buildAsnOrderLogSearchParams(params)
|
}
|
}
|
|
export function buildAsnOrderLogDetailQueryParams(params = {}) {
|
return {
|
logId: params.logId,
|
current: params.current || 1,
|
pageSize: params.pageSize || params.size || 20
|
}
|
}
|
|
export function normalizeAsnOrderLogRow(record = {}) {
|
const rleStatusMeta = getStatusMeta(record.rleStatus, RLE_STATUS_META)
|
const ntyStatusMeta = getStatusMeta(record.ntyStatus, NTY_STATUS_META)
|
const statusMeta = getStatusMeta(record.status, STATUS_META)
|
|
return {
|
...record,
|
id: record.id ?? null,
|
asnId: record.asnId ?? '--',
|
code: normalizeText(record.code) || '--',
|
poCode: normalizeText(record.poCode) || '--',
|
poId: record.poId ?? '--',
|
type: normalizeText(record.type) || '',
|
typeText: normalizeTagText(record['type$'] || record.typeText || record.type, {}),
|
wkType: normalizeText(record.wkType) || '',
|
wkTypeText: normalizeTagText(record['wkType$'] || record.wkTypeText || record.wkType, {}),
|
anfme: record.anfme ?? '--',
|
qty: record.qty ?? '--',
|
logisNo: normalizeText(record.logisNo) || '--',
|
arrTime: record.arrTime ?? null,
|
arrTimeText: normalizeDateText(record['arrTime$'] || record.arrTime) || '--',
|
rleStatus: record.rleStatus ?? '--',
|
rleStatusText: normalizeTagText(record['rleStatus$'] || rleStatusMeta.text, RLE_STATUS_META),
|
rleStatusTagType: rleStatusMeta.type,
|
ntyStatus: record.ntyStatus ?? '--',
|
ntyStatusText: normalizeTagText(record['ntyStatus$'] || ntyStatusMeta.text, NTY_STATUS_META),
|
ntyStatusTagType: ntyStatusMeta.type,
|
exceStatus: record.exceStatus ?? '--',
|
exceStatusText: normalizeTagText(record['exceStatus$'] || record.exceStatusText || record.exceStatus, {}),
|
status: record.status ?? '--',
|
statusText: normalizeTagText(record['status$'] || statusMeta.text, STATUS_META),
|
statusType: statusMeta.type,
|
createByText: normalizeText(record['createBy$'] || record.createByText || '') || '--',
|
createTimeText: normalizeDateText(record['createTime$'] || record.createTime) || '--',
|
updateByText: normalizeText(record['updateBy$'] || record.updateByText || '') || '--',
|
updateTimeText: normalizeDateText(record['updateTime$'] || record.updateTime) || '--',
|
memo: normalizeText(record.memo) || '--'
|
}
|
}
|
|
export function normalizeAsnOrderItemLogRow(record = {}) {
|
const ntyStatusMeta = getStatusMeta(record.ntyStatus, NTY_STATUS_META)
|
const statusMeta = getStatusMeta(record.status, STATUS_META)
|
|
return {
|
...record,
|
id: record.id ?? null,
|
logId: record.logId ?? '--',
|
asnItemId: record.asnItemId ?? '--',
|
asnId: record.asnId ?? '--',
|
asnCode: normalizeText(record.asnCode) || '--',
|
platItemId: normalizeText(record.platItemId) || '--',
|
poDetlId: record.poDetlId ?? '--',
|
poCode: normalizeText(record.poCode) || '--',
|
fieldsIndex: normalizeText(record.fieldsIndex) || '--',
|
matnrId: record.matnrId ?? '--',
|
matnrCode: normalizeText(record.matnrCode) || '--',
|
maktx: normalizeText(record.maktx) || '--',
|
anfme: record.anfme ?? '--',
|
stockUnit: normalizeText(record.stockUnit) || '--',
|
purQty: record.purQty ?? '--',
|
purUnit: normalizeText(record.purUnit) || '--',
|
qty: record.qty ?? '--',
|
splrCode: normalizeText(record.splrCode) || '--',
|
splrBatch: normalizeText(record.splrBatch) || '--',
|
splrName: normalizeText(record.splrName) || '--',
|
qrcode: normalizeText(record.qrcode) || '--',
|
trackCode: normalizeText(record.trackCode) || '--',
|
barcode: normalizeText(record.barcode) || '--',
|
packName: normalizeText(record.packName) || '--',
|
ntyStatus: record.ntyStatus ?? '--',
|
ntyStatusText: normalizeTagText(record['ntyStatus$'] || ntyStatusMeta.text, NTY_STATUS_META),
|
ntyStatusTagType: ntyStatusMeta.type,
|
status: record.status ?? '--',
|
statusText: normalizeTagText(record['status$'] || statusMeta.text, STATUS_META),
|
statusType: statusMeta.type,
|
createByText: normalizeText(record['createBy$'] || record.createByText || '') || '--',
|
createTimeText: normalizeDateText(record['createTime$'] || record.createTime) || '--',
|
updateByText: normalizeText(record['updateBy$'] || record.updateByText || '') || '--',
|
updateTimeText: normalizeDateText(record['updateTime$'] || record.updateTime) || '--',
|
memo: normalizeText(record.memo) || '--'
|
}
|
}
|
|
export function buildAsnOrderLogPrintRows(records = []) {
|
if (!Array.isArray(records)) {
|
return []
|
}
|
return records.map((record) => normalizeAsnOrderLogRow(record))
|
}
|
|
export function buildAsnOrderLogReportMeta({
|
previewMeta = {},
|
count = 0,
|
orientation = ASN_ORDER_LOG_REPORT_STYLE.orientation
|
} = {}) {
|
return {
|
reportTitle: ASN_ORDER_LOG_REPORT_TITLE,
|
reportDate: previewMeta.reportDate,
|
printedAt: previewMeta.printedAt,
|
operator: previewMeta.operator,
|
count,
|
reportStyle: {
|
...ASN_ORDER_LOG_REPORT_STYLE,
|
orientation
|
}
|
}
|
}
|
|
export function getAsnOrderLogRleStatusOptions() {
|
return [
|
{ label: '正常', value: 0 },
|
{ label: '已释放', value: 1 }
|
]
|
}
|
|
export function getAsnOrderLogNtyStatusOptions() {
|
return [
|
{ label: '未上报', value: 0 },
|
{ label: '已上报', value: 1 },
|
{ label: '部分上报', value: 2 }
|
]
|
}
|
|
export function getAsnOrderLogStatusOptions() {
|
return [
|
{ label: '正常', value: 1 },
|
{ label: '冻结', value: 0 }
|
]
|
}
|
|
export function getAsnOrderLogTypeOptions() {
|
return []
|
}
|
|
export function getAsnOrderLogWkTypeOptions() {
|
return []
|
}
|
|
export function getAsnOrderLogExceStatusOptions() {
|
return []
|
}
|
|
export function resolveDictOptions(records = [], options = {}) {
|
const { group } = options
|
if (!Array.isArray(records)) {
|
return []
|
}
|
|
return records
|
.filter((item) => {
|
if (!item || typeof item !== 'object') {
|
return false
|
}
|
if (group === undefined) {
|
return true
|
}
|
return normalizeText(item.group) === normalizeText(group)
|
})
|
.map((item) => {
|
const value = item.value ?? item.id ?? item.dictValue
|
if (value === undefined || value === null || value === '') {
|
return null
|
}
|
return {
|
value: normalizeText(value),
|
label: normalizeText(item.label || item.name || item.dictLabel || value)
|
}
|
})
|
.filter(Boolean)
|
}
|