From cd86255b13881606671fabec9f314c4aa75c625f Mon Sep 17 00:00:00 2001 From: ouyangxq <775153912@qq.com> Date: Fri, 23 Oct 2026 00:55:21 +0800 Subject: [PATCH] fix(dispatch): preview selected driver master license before saving --- .../components/DispatchResourceFields.test.ts | 12 +++++++- .../components/DispatchResourceFields.vue | 2 +- .../DispatchWorkflowDialog.layout.test.ts | 30 +++++++++++++++++-- .../components/DispatchWorkflowDialog.vue | 10 ++++++- 4 files changed, 49 insertions(+), 5 deletions(-) diff --git a/src/modules/overseas-warehouse/components/DispatchResourceFields.test.ts b/src/modules/overseas-warehouse/components/DispatchResourceFields.test.ts index 7c9efff2..3508b74e 100644 --- a/src/modules/overseas-warehouse/components/DispatchResourceFields.test.ts +++ b/src/modules/overseas-warehouse/components/DispatchResourceFields.test.ts @@ -3,11 +3,21 @@ import { flushPromises, mount } from '@vue/test-utils' import { beforeEach, expect, it, vi } from 'vitest' import DispatchResourceFields from './DispatchResourceFields.vue' import { resources } from '../dispatchTestFixtures' -import { listDrivers, listVehicles, type VehicleDetail } from '@/modules/overseas-master-data' +import { listDrivers, listVehicles, type DriverDetail, type VehicleDetail } from '@/modules/overseas-master-data' const can = vi.hoisted(() => vi.fn(() => true)) vi.mock('@/core/access/accessPreview', () => ({ useAccessPreviewStore: () => ({ can }) })) vi.mock('@/modules/overseas-master-data', () => ({ listDrivers: vi.fn(), listVehicles: vi.fn(), overseasMasterDataPermissions: { vehicleList: 'vehicle:list', driverList: 'driver:list' } })) beforeEach(() => { vi.clearAllMocks(); can.mockReturnValue(true); vi.mocked(listVehicles).mockResolvedValue({ records: [], page: 1, size: 100, total: 0, pages: 0 }) }) +it('carries the selected master license for preview without carrying another driver’s trip photos', async () => { + const candidate: DriverDetail = { id: '22', driverNo: 'DR22', details: { name: '司机乙', phone: '555-0022', ownership: 'OWNED', region: 'OVERSEAS', licenseNumber: 'LICENSE22', licenseType: null, licenseIssuedOn: null, licenseExpiresOn: '2028-01-01', licenseZone: 'UTC', remark: null, profile: null }, active: true, reviewStatus: 'APPROVED', licenseFileId: '33', recordVersion: 1, updatedBy: 'operator', updatedAt: '2026-10-23T00:00:00Z', qualification: { canDispatch: true, expiringSoon: false, reason: 'ELIGIBLE', licenseExpiresOn: '2028-01-01' }, licenseState: 'VALID', warehouseCode: null, warehouseName: null } + vi.mocked(listDrivers).mockResolvedValue({ records: [candidate], page: 1, size: 100, total: 1, pages: 1, summary: { total: 1, owned: 1, dispatched: 0, expiringSoon: 0, expired: 0 } }) + const value = resources() + const wrapper = mount(DispatchResourceFields, { props: { ...value, disabled: false }, global: { plugins: [ElementPlus] } }) + const state = wrapper.vm as unknown as { searchDrivers(): Promise; selectDriver(id: string): void } + await state.searchDrivers(); state.selectDriver('22'); await flushPromises() + expect(wrapper.emitted('update:driver')!.at(-1)![0]).toMatchObject({ driverId: '22', evidence: { fileIds: [], masterLicenseFileId: '33' } }) + wrapper.unmount() +}) it.each([['本趟承运公司', '555-0123'], [null, null]])('shows continuous master snapshot fields read-only and uses a dash for missing facts (%s)', async (carrierName, phone) => { const value = resources(); value.vehicle.mode = 'MASTER'; value.vehicle.vehicleId = 'vehicle-1'; value.vehicle.carrierName = carrierName; value.driver.mode = 'MASTER'; value.driver.driverId = 'driver-1'; value.driver.phone = phone const wrapper = mount(DispatchResourceFields, { props: { vehicle: value.vehicle, driver: value.driver, disabled: false, continuous: true }, global: { plugins: [ElementPlus] } }); await flushPromises() diff --git a/src/modules/overseas-warehouse/components/DispatchResourceFields.vue b/src/modules/overseas-warehouse/components/DispatchResourceFields.vue index e444ee37..3b08ffc4 100644 --- a/src/modules/overseas-warehouse/components/DispatchResourceFields.vue +++ b/src/modules/overseas-warehouse/components/DispatchResourceFields.vue @@ -49,7 +49,7 @@ function selectVehicle(id: string | null) { } function selectDriver(id: string) { const selected = drivers.value.find(row => row.id === id), end = driver.value.evidence?.expectedTaskEndAt || null - driver.value = { mode: 'MASTER', driverId: id, name: selected?.details.name || null, phone: selected?.details.phone || null, evidence: { licenseNo: null, licenseExpiresOn: null, fileIds: [], expectedTaskEndAt: end } } + driver.value = { mode: 'MASTER', driverId: id, name: selected?.details.name || null, phone: selected?.details.phone || null, evidence: { licenseNo: null, licenseExpiresOn: null, fileIds: [], expectedTaskEndAt: end, masterLicenseFileId: selected?.licenseFileId || null } } }