优化
This commit is contained in:
@@ -1,19 +1,26 @@
|
||||
import type { OceanBookingContainer } from './types'
|
||||
import type { OceanBookingContainerInput } from './types'
|
||||
import { applyContainerSpecification, containerSpecification } from '@/shared/domain/containerSpecifications'
|
||||
|
||||
export function createBlankContainerRequirement(): OceanBookingContainer {
|
||||
return { containerType: '40HC', containerKind: 'FCL', capacityCbm: 76, maxWeightKg: 28000, quantity: 1 }
|
||||
export function createBlankBookingContainer(): OceanBookingContainerInput {
|
||||
return { containerNo: '', containerType: '40HC', containerKind: 'FCL', capacityCbm: 76, maxWeightKg: 28000 }
|
||||
}
|
||||
|
||||
export function selectContainerRequirementType(requirement: OceanBookingContainer, containerType: string) {
|
||||
applyContainerSpecification(requirement, containerType)
|
||||
export function selectBookingContainerType(container: OceanBookingContainerInput, containerType: string) {
|
||||
applyContainerSpecification(container, containerType)
|
||||
}
|
||||
|
||||
export function containerRequirementError(requirements: OceanBookingContainer[]) {
|
||||
const invalid = requirements.find((item) => {
|
||||
export function bookingContainerError(containers: OceanBookingContainerInput[]) {
|
||||
if (!containers.length) return '请至少登记一个真实柜'
|
||||
if (containers.length > 20) return '单次订舱最多登记 20 个真实柜'
|
||||
const normalizedNumbers = containers.map((item) => item.containerNo.trim().toUpperCase())
|
||||
const missingNumberIndex = normalizedNumbers.findIndex((value) => !value)
|
||||
if (missingNumberIndex >= 0) return `第 ${missingNumberIndex + 1} 个真实柜尚未填写集装箱号`
|
||||
const duplicateNumber = normalizedNumbers.find((value, index) => normalizedNumbers.indexOf(value) !== index)
|
||||
if (duplicateNumber) return `集装箱号 ${duplicateNumber} 在本次订舱中重复`
|
||||
const invalid = containers.find((item) => {
|
||||
const specification = containerSpecification(item.containerType)
|
||||
return !specification || Number(item.capacityCbm) !== specification.capacityCbm
|
||||
|| Number(item.maxWeightKg) !== specification.maxWeightKg || !(Number(item.quantity) > 0)
|
||||
|| Number(item.maxWeightKg) !== specification.maxWeightKg
|
||||
})
|
||||
return invalid ? `箱型 ${invalid.containerType || '未命名'} 必须使用平台固定规格,请重新选择柜型` : null
|
||||
return invalid ? `柜型 ${invalid.containerType || '未命名'} 必须使用平台固定规格,请重新选择柜型` : null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user