2026-08-12 18:53:18 +08:00
|
|
|
import type { OceanBookingContainer } from './types'
|
2026-08-17 12:31:27 +08:00
|
|
|
import { applyContainerSpecification, containerSpecification } from '@/shared/domain/containerSpecifications'
|
2026-08-12 18:53:18 +08:00
|
|
|
|
|
|
|
|
export function createBlankContainerRequirement(): OceanBookingContainer {
|
2026-08-17 12:31:27 +08:00
|
|
|
return { containerType: '40HC', containerKind: 'FCL', capacityCbm: 76, maxWeightKg: 28000, quantity: 1 }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function selectContainerRequirementType(requirement: OceanBookingContainer, containerType: string) {
|
|
|
|
|
applyContainerSpecification(requirement, containerType)
|
2026-08-12 18:53:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function containerRequirementError(requirements: OceanBookingContainer[]) {
|
2026-08-17 12:31:27 +08:00
|
|
|
const invalid = requirements.find((item) => {
|
|
|
|
|
const specification = containerSpecification(item.containerType)
|
|
|
|
|
return !specification || Number(item.capacityCbm) !== specification.capacityCbm
|
|
|
|
|
|| Number(item.maxWeightKg) !== specification.maxWeightKg || !(Number(item.quantity) > 0)
|
|
|
|
|
})
|
|
|
|
|
return invalid ? `箱型 ${invalid.containerType || '未命名'} 必须使用平台固定规格,请重新选择柜型` : null
|
2026-08-12 18:53:18 +08:00
|
|
|
}
|