diff --git a/src/modules/container-loading/components/OceanBookingLinkDialog.test.ts b/src/modules/container-loading/components/OceanBookingLinkDialog.test.ts index 21ad88d8..2f04920a 100644 --- a/src/modules/container-loading/components/OceanBookingLinkDialog.test.ts +++ b/src/modules/container-loading/components/OceanBookingLinkDialog.test.ts @@ -57,4 +57,23 @@ describe('OceanBookingLinkDialog', () => { expect(wrapper.emitted('linked')).toHaveLength(1) wrapper.unmount() }) + + it('prefills and preserves a real container number recorded before booking linkage', async () => { + const existingContainer = { ...container, containerNo: 'MSCU6639870' } + const wrapper = mount(OceanBookingLinkDialog, { + props: { modelValue: true, container: existingContainer }, + global: { plugins: [ElementPlus] }, + }) + await flushPromises() + const vm = wrapper.vm as unknown as { candidateKey: string; containerNo: string; save: () => Promise } + expect(vm.containerNo).toBe('MSCU6639870') + + vm.candidateKey = '101:202' + await vm.save() + + expect(linkContainerOceanBooking).toHaveBeenCalledExactlyOnceWith('9001', { + oceanBookingId: '101', requirementId: '202', containerNo: 'MSCU6639870', expectedVersion: 7, + }) + wrapper.unmount() + }) }) diff --git a/src/modules/container-loading/components/OceanBookingLinkDialog.vue b/src/modules/container-loading/components/OceanBookingLinkDialog.vue index d4e9d600..91633f8b 100644 --- a/src/modules/container-loading/components/OceanBookingLinkDialog.vue +++ b/src/modules/container-loading/components/OceanBookingLinkDialog.vue @@ -31,7 +31,7 @@ function close() { emit('update:modelValue', false) } async function loadCandidates() { const target = props.container candidateKey.value = '' - containerNo.value = '' + containerNo.value = normalizeContainerNo(target?.containerNo) candidates.value = [] error.value = null if (!target) return