优化
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { CONTAINER_SPECIFICATIONS, DEFAULT_CONTAINER_TYPE, containerSpecification } from './containerSpecifications'
|
||||
|
||||
describe('container specifications', () => {
|
||||
it('uses the three confirmed container types and defaults to 40HQ', () => {
|
||||
expect(CONTAINER_SPECIFICATIONS.map((item) => item.type)).toEqual(['40GP', '40HQ', '45HQ'])
|
||||
expect(DEFAULT_CONTAINER_TYPE).toBe('40HQ')
|
||||
})
|
||||
|
||||
it('keeps practical loading ranges and the common cargo weight limit', () => {
|
||||
expect(CONTAINER_SPECIFICATIONS.map(({ type, recommendedMinCbm, capacityCbm, maxWeightKg }) => (
|
||||
{ type, recommendedMinCbm, capacityCbm, maxWeightKg }
|
||||
))).toEqual([
|
||||
{ type: '40GP', recommendedMinCbm: 56, capacityCbm: 58, maxWeightKg: 19500 },
|
||||
{ type: '40HQ', recommendedMinCbm: 65, capacityCbm: 68, maxWeightKg: 19500 },
|
||||
{ type: '45HQ', recommendedMinCbm: 82, capacityCbm: 86, maxWeightKg: 19500 },
|
||||
])
|
||||
expect(containerSpecification('40hc')).toBeNull()
|
||||
})
|
||||
})
|
||||
@@ -1,12 +1,13 @@
|
||||
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 },
|
||||
{ type: '40GP', recommendedMinCbm: 56, capacityCbm: 58, maxWeightKg: 19500, description: '美线电商较少使用,通常优先选择 40HQ' },
|
||||
{ type: '40HQ', recommendedMinCbm: 65, capacityCbm: 68, maxWeightKg: 19500, description: '轻泡货首选,适合家居、玩具、日用品' },
|
||||
{ type: '45HQ', recommendedMinCbm: 82, capacityCbm: 86, maxWeightKg: 19500, description: '抛货量大时考虑,底盘和海外仓预约资源较少' },
|
||||
] as const
|
||||
|
||||
export const DEFAULT_CONTAINER_TYPE = '40HQ' as const
|
||||
|
||||
export type ContainerSpecification = (typeof CONTAINER_SPECIFICATIONS)[number]
|
||||
export type ContainerType = ContainerSpecification['type']
|
||||
|
||||
export function containerSpecification(containerType: string | null | undefined): ContainerSpecification | null {
|
||||
const normalized = String(containerType || '').trim().toUpperCase()
|
||||
|
||||
Reference in New Issue
Block a user