From 4595dfef3475fccd76669338a27d91804dc14bde Mon Sep 17 00:00:00 2001 From: ouyangxq <775153912@qq.com> Date: Tue, 27 Oct 2026 08:33:01 +0800 Subject: [PATCH] fix(dispatch): present loading evidence as a single-column list --- .../DispatchLoadingDocuments.test.ts | 38 ++++++---- .../components/DispatchLoadingDocuments.vue | 71 +++++++++++++------ 2 files changed, 75 insertions(+), 34 deletions(-) diff --git a/src/modules/overseas-warehouse/components/DispatchLoadingDocuments.test.ts b/src/modules/overseas-warehouse/components/DispatchLoadingDocuments.test.ts index a64d18a4..75915801 100644 --- a/src/modules/overseas-warehouse/components/DispatchLoadingDocuments.test.ts +++ b/src/modules/overseas-warehouse/components/DispatchLoadingDocuments.test.ts @@ -33,30 +33,34 @@ it('refreshes photos added or replaced by PDA without writing and notifies the p }))) vi.mocked(api.getLoadingDocuments).mockResolvedValue(data({ recordVersion: '26', stage: 'DELIVERING', complete: true, photos })) await wrapper.get('[aria-label="刷新装车资料"]').trigger('click'); await flushPromises() - for (const item of photos) expect(wrapper.text()).toContain(item.fileName) + expect(wrapper.findAll('.loading-photo-row')).toHaveLength(25) + for (const item of photos) expect(wrapper.text()).not.toContain(item.fileName) expect(wrapper.text()).not.toContain(photo.fileName) - expect(wrapper.findAll('tbody tr').map(row => row.findAll('td')[1]!.text())).toEqual(Object.values(api.loadingPhotoLabels).map(label => `${label}5/5 张`)) + expect(wrapper.findAll('.loading-document-heading').map(row => row.text())).toEqual(Object.values(api.loadingPhotoLabels).map(label => `${label}5/5 张`)) expect(wrapper.emitted('saved')).toHaveLength(1) expect(api.uploadLoadingPhoto).not.toHaveBeenCalled(); expect(api.bindLoadingPhoto).not.toHaveBeenCalled() vi.mocked(api.getLoadingDocuments).mockRejectedValueOnce(new Error('刷新失败')) await wrapper.get('[aria-label="刷新装车资料"]').trigger('click'); await flushPromises() - expect(wrapper.text()).toContain(photos[0]!.fileName) + expect(wrapper.findAll('.loading-photo-row')).toHaveLength(25) expect(wrapper.emitted('saved')).toHaveLength(1) wrapper.unmount() }) it('offers five whole-dispatch slots and only reports saved after binding succeeds', async () => { const wrapper = setup(); await flushPromises() expect(wrapper.findAll('input[type="file"]')).toHaveLength(5) - const table = wrapper.get('table[aria-label="装车照片"]') - expect(table.findAll('thead th').map(cell => cell.text())).toEqual(['操作', '照片类别', '文件名称', '图片预览', '保存时间']) - expect(table.findAll('tbody tr').map(row => row.findAll('td')[1]!.text())).toEqual(Object.values(api.loadingPhotoLabels).map(label => `${label}0/5 张`)) + const list = wrapper.get('[aria-label="装车照片"]') + expect(wrapper.find('table').exists()).toBe(false) + expect(list.findAll('h3').map(heading => heading.text())).toEqual(Object.values(api.loadingPhotoLabels)) + expect(list.findAll('.photo-count').map(count => count.text())).toEqual(Array(5).fill('0/5 张')) + expect(list.findAll('.photo-empty')).toHaveLength(5) await upload(wrapper) expect(api.uploadLoadingPhoto).toHaveBeenCalledWith('PC/1', 'LOADING_SCENE', expect.any(File), expect.any(String), '1') expect(api.bindLoadingPhoto).toHaveBeenCalledWith('PC/1', 'LOADING_SCENE', expect.objectContaining({ recordVersion: '0', fileId: '101' })) expect(vi.mocked(api.bindLoadingPhoto).mock.calls[0]![2].uploadKey).toBe(vi.mocked(api.uploadLoadingPhoto).mock.calls[0]![3]) expect(wrapper.emitted('saved')).toHaveLength(1) expect(wrapper.text()).toContain('图片读取失败') - expect(table.get('tbody tr').text()).toContain('loading.png') + expect(list.get('.loading-photo-row').attributes('aria-label')).toBe('司机驾驶证第1张') + expect(list.text()).not.toContain('loading.png') wrapper.unmount() }) it('stops a batch when re-review changes the source during upload instead of rebasing old files', async () => { @@ -84,7 +88,7 @@ it('shows an imported PDF license as an authenticated document and accepts an ex await flushPromises() expect(wrapper.get('a').attributes('href')).toBe('blob:license') expect(wrapper.findComponent({ name: 'ElImage' }).exists()).toBe(false) - const input = wrapper.get('input[aria-label="更换license.pdf"]') + const input = wrapper.get('input[aria-label="更换司机驾驶证第1张"]') expect(input.attributes('accept')).toContain('application/pdf') expect(wrapper.get('input[aria-label="上传车牌照片"]').attributes('accept')).not.toContain('application/pdf') Object.defineProperty(input.element, 'files', { configurable: true, value: [new File(['%PDF-1.4'], 'new.pdf', { type: 'application/pdf' })] }) @@ -93,19 +97,29 @@ it('shows an imported PDF license as an authenticated document and accepts an ex } finally { wrapper.unmount(); vi.restoreAllMocks() } }) it('shows every photo in a category, stops at five and replaces the selected image only', async () => { - const photos = Array.from({ length: 5 }, (_, index) => ({ ...photo, fileId: String(101 + index), fileName: `photo-${index}.png` })) + const photos = Array.from({ length: 5 }, (_, index) => ({ ...photo, fileId: String(101 + index), fileName: `photo-${index}.png`, savedAt: `2026-10-26T11:49:0${index}.978960362Z` })) vi.mocked(api.getLoadingDocuments).mockResolvedValue(data({ recordVersion: '5', photos })) const replacement = { ...photo, fileId: '999' } vi.mocked(api.uploadLoadingPhoto).mockResolvedValue(replacement) vi.mocked(api.bindLoadingPhoto).mockResolvedValue(data({ recordVersion: '6', photos: photos.map(item => item.fileId === '103' ? replacement : item) })) const wrapper = setup(); await flushPromises() expect(wrapper.get('input[aria-label="上传司机驾驶证"]').attributes('disabled')).toBeDefined() - for (const item of photos) expect(wrapper.text()).toContain(item.fileName) - const input = wrapper.get('input[aria-label="更换photo-2.png"]') + const rows = wrapper.findAll('.loading-photo-row') + expect(rows).toHaveLength(5) + rows.forEach((row, index) => { + expect(row.attributes('aria-label')).toBe(`司机驾驶证第${index + 1}张`) + expect(row.get('.photo-time').text()).toMatch(new RegExp(`保存时间:2026-10-26 \\d{2}:49:0${index}$`)) + expect(row.findAll('input[type="file"]')).toHaveLength(1) + }) + for (const item of photos) expect(wrapper.text()).not.toContain(item.fileName) + const input = rows[2]!.get('input[aria-label="更换司机驾驶证第3张"]') Object.defineProperty(input.element, 'files', { configurable: true, value: [new File(['new'], 'new.png', { type: 'image/png' })] }) await input.trigger('change'); await flushPromises() expect(api.bindLoadingPhoto).toHaveBeenLastCalledWith('PC/1', 'LOADING_SCENE', expect.objectContaining({ recordVersion: '5', fileId: '999', replaceFileId: '103' })) - expect(wrapper.text()).toContain('photo-0.png'); expect(wrapper.text()).toContain('photo-4.png') + expect(wrapper.findAll('.loading-photo-row')).toHaveLength(5) + expect(wrapper.findAll('.loading-photo-row')[0]!.get('.photo-time').text()).toMatch(/:49:00$/) + expect(wrapper.findAll('.loading-photo-row')[2]!.get('.photo-time').text()).toBe('保存时间:—') + expect(wrapper.findAll('.loading-photo-row')[4]!.get('.photo-time').text()).toMatch(/:49:04$/) wrapper.unmount() }) it('saves a multiple selection with fresh versions and notifies the parent once', async () => { diff --git a/src/modules/overseas-warehouse/components/DispatchLoadingDocuments.vue b/src/modules/overseas-warehouse/components/DispatchLoadingDocuments.vue index af7410b1..cefac057 100644 --- a/src/modules/overseas-warehouse/components/DispatchLoadingDocuments.vue +++ b/src/modules/overseas-warehouse/components/DispatchLoadingDocuments.vue @@ -1,6 +1,7 @@