This commit is contained in:
2026-08-17 12:31:27 +08:00
parent c6fa22c1b5
commit 6a0c0b9229
22 changed files with 399 additions and 171 deletions
@@ -0,0 +1,23 @@
export const CONTAINER_SPECIFICATIONS = [
{ type: '20GP', capacityCbm: 33, maxWeightKg: 28000 },
{ type: '40GP', capacityCbm: 67, maxWeightKg: 28000 },
{ type: '40HC', capacityCbm: 76, maxWeightKg: 28000 },
{ type: '40NR', capacityCbm: 67, maxWeightKg: 28000 },
{ type: '45HC', capacityCbm: 86, maxWeightKg: 28000 },
] as const
export type ContainerSpecification = (typeof CONTAINER_SPECIFICATIONS)[number]
export function containerSpecification(containerType: string | null | undefined): ContainerSpecification | null {
const normalized = String(containerType || '').trim().toUpperCase()
return CONTAINER_SPECIFICATIONS.find((item) => item.type === normalized) || null
}
export function applyContainerSpecification<T extends { containerType: string; capacityCbm: number | null; maxWeightKg: number | null }>(target: T, containerType: string) {
const specification = containerSpecification(containerType)
if (!specification) return false
target.containerType = specification.type
target.capacityCbm = specification.capacityCbm
target.maxWeightKg = specification.maxWeightKg
return true
}