fix: limit dispatch vehicle choices
This commit is contained in:
@@ -94,15 +94,15 @@ describe('dispatch overseas API', () => {
|
||||
|
||||
it('loads drafts and preserves long container ids in create and delete paths', async () => {
|
||||
vi.mocked(overseasHttp.get).mockResolvedValue({ code: '200', message: 'success', data: [] })
|
||||
vi.mocked(overseasHttp.post).mockResolvedValue({ code: '200', message: 'success', data: { id: '190000000000000099', capacity: 68, palletIds: [] } })
|
||||
vi.mocked(overseasHttp.post).mockResolvedValue({ code: '200', message: 'success', data: { id: '190000000000000099', capacity: 30, palletIds: [] } })
|
||||
vi.mocked(overseasHttp.delete).mockResolvedValue({ code: '200', message: 'success', data: null })
|
||||
|
||||
await listDispatchDrafts()
|
||||
await createDispatchDraftContainer('draft/1', 68)
|
||||
await createDispatchDraftContainer('draft/1', 30)
|
||||
await deleteDispatchDraftContainer('draft/1', '190000000000000099')
|
||||
|
||||
expect(overseasHttp.get).toHaveBeenCalledWith('/platform/v1/last-leg/dispatches/drafts')
|
||||
expect(overseasHttp.post).toHaveBeenCalledWith('/platform/v1/last-leg/dispatches/drafts/containers', { draftToken: 'draft/1', capacity: 68 })
|
||||
expect(overseasHttp.post).toHaveBeenCalledWith('/platform/v1/last-leg/dispatches/drafts/containers', { draftToken: 'draft/1', capacity: 30 })
|
||||
expect(overseasHttp.delete).toHaveBeenCalledWith('/platform/v1/last-leg/dispatches/drafts/draft%2F1/containers/190000000000000099')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -12,14 +12,9 @@ import OperationErrorToast from '@/shared/components/OperationErrorToast.vue'
|
||||
import { createDispatchDraftContainer, deleteDispatchDraftContainer, listDispatchCandidates, listDispatchDrafts, lockDispatchDraftPallet, preArrangeDispatch, unlockDispatchDraftPallet, type DispatchPalletCandidateDto } from '../api/dispatches'
|
||||
import { formatOverseasDateTime } from '../lastMilePresentation'
|
||||
import type { InboundOrderListItem } from '../types'
|
||||
import { dispatchVehicleSpecs } from '../dispatchVehicleSpecs'
|
||||
import OrderReferenceText from './OrderReferenceText.vue'
|
||||
|
||||
type VehicleSpec = {
|
||||
value: string
|
||||
label: string
|
||||
capacity: number
|
||||
maxWeightLb: number
|
||||
}
|
||||
interface LoadingContainer {
|
||||
id: string
|
||||
capacity: number
|
||||
@@ -92,33 +87,7 @@ const assignedIds = computed(() => containers.value.flatMap((item) => item.palle
|
||||
const assigned = computed(() => assignedIds.value.map((id) => palletSnapshot(id)).filter((item): item is DispatchPalletCandidateDto => Boolean(item)))
|
||||
const assignedPackages = computed(() => assigned.value.reduce((sum, item) => sum + Number(item.packageCount || 0), 0))
|
||||
const assignedVolume = computed(() => assigned.value.reduce((sum, item) => sum + Number(item.volumeCbm || 0), 0))
|
||||
const vehicleSpecs: VehicleSpec[] = [
|
||||
{
|
||||
value: 'LARGE_30',
|
||||
label: '大车(30托)',
|
||||
capacity: 30,
|
||||
maxWeightLb: 40000,
|
||||
},
|
||||
{
|
||||
value: 'SMALL_15',
|
||||
label: '小车(15托)',
|
||||
capacity: 15,
|
||||
maxWeightLb: 10000,
|
||||
},
|
||||
{
|
||||
value: 'SMALL_14',
|
||||
label: '小车(14托)',
|
||||
capacity: 14,
|
||||
maxWeightLb: 10000,
|
||||
},
|
||||
{
|
||||
value: 'SMALL_12',
|
||||
label: '小车(12托)',
|
||||
capacity: 12,
|
||||
maxWeightLb: 10000,
|
||||
},
|
||||
]
|
||||
const selectedVehicleSpec = computed(() => vehicleSpecs.find((item) => item.value === selectedVehicle.value))
|
||||
const selectedVehicleSpec = computed(() => dispatchVehicleSpecs.find((item) => item.value === selectedVehicle.value))
|
||||
const weightLb = (item?: DispatchPalletCandidateDto) => Number(item?.volumeWeightKg || 0) * 2.2046226218
|
||||
const containerWeightLb = (container: LoadingContainer) => container.palletIds.reduce((sum, id) => sum + weightLb(palletSnapshot(id)), 0)
|
||||
|
||||
@@ -368,7 +337,7 @@ watch(
|
||||
if (draft?.draftToken) {
|
||||
draftToken.value = draft.draftToken
|
||||
containers.value = (draft.containers || []).map((c) => {
|
||||
const spec = vehicleSpecs.find((item) => item.capacity === c.capacity) || vehicleSpecs[0]!
|
||||
const spec = dispatchVehicleSpecs.find((item) => item.capacity === c.capacity) || dispatchVehicleSpecs[0]!
|
||||
return {
|
||||
id: c.id,
|
||||
capacity: c.capacity,
|
||||
@@ -564,7 +533,7 @@ watch([warehouseTab, () => query.orderType], () => {
|
||||
</AppDialog>
|
||||
<el-dialog class="admin-density-dialog" v-model="vehicleDialogOpen" title="选择车型" width="360px" append-to-body>
|
||||
<el-radio-group v-model="selectedVehicle" class="vehicle-options">
|
||||
<el-radio v-for="spec in vehicleSpecs" :key="spec.value" :value="spec.value">{{ spec.label }} · 限重 {{ spec.maxWeightLb }}LB</el-radio>
|
||||
<el-radio v-for="spec in dispatchVehicleSpecs" :key="spec.value" :value="spec.value">{{ spec.label }} · 限重 {{ spec.maxWeightLb }}LB</el-radio>
|
||||
</el-radio-group>
|
||||
<template #footer><el-button @click="vehicleDialogOpen = false">取消</el-button><el-button type="primary" @click="confirmAddContainer">确定</el-button></template>
|
||||
</el-dialog>
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
export const dispatchVehicleSpecs = [
|
||||
{ value: 'LARGE_30', label: '大车(30托)', capacity: 30, maxWeightLb: 40000 },
|
||||
{ value: 'SMALL_15', label: '小车(15托)', capacity: 15, maxWeightLb: 10000 },
|
||||
] as const
|
||||
|
||||
export const dispatchVehicleSizeOptions = dispatchVehicleSpecs.map(({ capacity }) => ({
|
||||
label: `${capacity}托`,
|
||||
value: `${capacity}托`,
|
||||
}))
|
||||
@@ -136,6 +136,7 @@ describe('DispatchesView', () => {
|
||||
expect(source).toContain('removeDispatchItem')
|
||||
expect(source).not.toContain('托盘箱唛确认')
|
||||
expect(source).not.toContain('palletCartonMarks')
|
||||
expect(source).toContain('dispatchVehicleSizeOptions')
|
||||
expect(source).not.toContain('departDispatch')
|
||||
|
||||
canPermission.mockReturnValue(false)
|
||||
|
||||
@@ -19,6 +19,7 @@ import AppDialog from '@/shared/components/AppDialog.vue'
|
||||
import type { DispatchListItem } from '../types'
|
||||
import { formatOverseasDateTime } from '../lastMilePresentation'
|
||||
import { overseasWarehousePermissions as permission } from '../permissions'
|
||||
import { dispatchVehicleSizeOptions } from '../dispatchVehicleSpecs'
|
||||
|
||||
const router = useRouter()
|
||||
const access = useAccessPreviewStore()
|
||||
@@ -100,7 +101,7 @@ const loadingTypeOptions = [
|
||||
{ label: '混装', value: 'MIXED' },
|
||||
]
|
||||
const vehicleTypeOptions = ['厢式货车', '平板车', '冷藏车', '集装箱卡车', '尾板车'].map((label) => ({ label, value: label }))
|
||||
const vehicleSizeOptions = ['53尺大车(30托)', '26尺中车(14托)', '16尺小车(8托)', 'Cargo Van(4托)'].map((label) => ({ label, value: label }))
|
||||
const vehicleSizeOptions = dispatchVehicleSizeOptions
|
||||
const appointmentAccountOptions = [
|
||||
{ label: '4号账号(美西)', value: '4' },
|
||||
{ label: '8号账号(美东)', value: '8' },
|
||||
|
||||
@@ -284,6 +284,12 @@ describe('overseas warehouse first-batch prototype contract', () => {
|
||||
expect(dialog).not.toContain('`normal-${mark}`')
|
||||
expect(dialog).not.toContain('暂无箱唛')
|
||||
expect(dialog).toContain('class="warehouse-tabs density-tabs"')
|
||||
expect(dialog).toContain('dispatchVehicleSpecs')
|
||||
const vehicleSpecs = source('../dispatchVehicleSpecs.ts')
|
||||
expect(vehicleSpecs).toContain("label: '大车(30托)'")
|
||||
expect(vehicleSpecs).toContain("label: '小车(15托)'")
|
||||
expect(vehicleSpecs).not.toContain('14托')
|
||||
expect(vehicleSpecs).not.toContain('12托')
|
||||
expect(dialog).not.toContain('排车路线(选填)')
|
||||
expect(dialog).not.toContain('v-model="route"')
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user