88 lines
3.0 KiB
TypeScript
88 lines
3.0 KiB
TypeScript
import type { LastMileOrderSummaryDto } from './api/lastMileOrders'
|
|
import type { LastMileOrderListItem } from './types'
|
|
|
|
const orderTypeLabels: Record<string, string> = {
|
|
ONE_CLICK_DROPSHIP: '一件代发',
|
|
FIRST_LEG: '头程',
|
|
REJECTED: '拒收订单',
|
|
EXPRESS: '快递订单',
|
|
}
|
|
|
|
const statusLabels: Record<string, string> = {
|
|
PENDING_ASSIGNMENT: '待分配',
|
|
DESTINATION_ASSIGNED: '已分配目的仓',
|
|
INBOUND_PLANNED: '已生成入库计划',
|
|
PENDING_PROCESSING: '待处理',
|
|
PROCESSING: '处理中',
|
|
COMPLETED: '已完成',
|
|
CANCELLED: '已取消',
|
|
}
|
|
|
|
function text(value: unknown) {
|
|
const normalized = String(value ?? '').trim()
|
|
return normalized || '—'
|
|
}
|
|
|
|
function count(value: number | null | undefined) {
|
|
return Number.isFinite(value) ? Number(value) : 0
|
|
}
|
|
|
|
function yesNo(value: boolean | null | undefined) {
|
|
return value == null ? '—' : value ? '是' : '否'
|
|
}
|
|
|
|
export function lastMileStatusLabel(value: unknown) {
|
|
const code = String(value ?? '').trim()
|
|
return statusLabels[code] || text(code)
|
|
}
|
|
|
|
export function lastMileOrderTypeLabel(value: unknown) {
|
|
const code = String(value ?? '').trim()
|
|
return orderTypeLabels[code] || text(code)
|
|
}
|
|
|
|
export function formatOverseasDateTime(value: unknown) {
|
|
const raw = String(value ?? '').trim()
|
|
if (!raw) return '—'
|
|
const date = new Date(raw)
|
|
return Number.isNaN(date.getTime()) ? raw : date.toLocaleString('zh-CN', { hour12: false })
|
|
}
|
|
|
|
export function toLastMileOrderListItem(dto: LastMileOrderSummaryDto): LastMileOrderListItem {
|
|
return {
|
|
id: String(dto.id),
|
|
customerId: String(dto.customerId),
|
|
orderNo: text(dto.orderNo),
|
|
warning: dto.abnormal ? '异常' : '—',
|
|
orderType: lastMileOrderTypeLabel(dto.orderType),
|
|
rejectedAt: '—',
|
|
inboundCode: text(dto.inboundCode),
|
|
owner: text(dto.customerName),
|
|
warehouse: text(dto.overseasWarehouseName),
|
|
transferWarehouse: text(dto.transferWarehouseName),
|
|
fbaWarehouse: text(dto.fbaWarehouseCode),
|
|
containerNo: text(dto.containerNo),
|
|
containerStatus: text(dto.containerStatus),
|
|
abnormal: yesNo(dto.abnormal),
|
|
held: yesNo(dto.detained),
|
|
pallets: count(dto.palletCount),
|
|
cartons: count(dto.packageCount),
|
|
volume: count(dto.volumeCbm),
|
|
quantity: count(dto.productQuantity),
|
|
volumeWeight: count(dto.volumeWeightKg),
|
|
portEta: formatOverseasDateTime(dto.estimatedArrivalAt),
|
|
portAta: formatOverseasDateTime(dto.actualArrivalAt),
|
|
warehouseEta: formatOverseasDateTime(dto.estimatedWarehouseAt),
|
|
inboundOrderNo: text(dto.inboundOrderNo),
|
|
outboundOrderNo: text(dto.outboundOrderNo),
|
|
dispatchOrderNo: text(dto.deliveryOrderNo),
|
|
relabelOrderNo: text(dto.relabelOrderNo),
|
|
relabelStatus: lastMileStatusLabel(dto.relabelStatus),
|
|
consolidated: text(dto.palletMergeFlag),
|
|
status: lastMileStatusLabel(dto.currentStatus),
|
|
internalRemark: text(dto.privateRemark),
|
|
customerRemark: text(dto.customerRemark),
|
|
warehouseRemark: text(dto.warehouseRemark),
|
|
}
|
|
}
|