diff --git a/src/modules/appointment-calendar/PROTOTYPE_MATRIX.md b/src/modules/appointment-calendar/PROTOTYPE_MATRIX.md index 1536d507..8589f772 100644 --- a/src/modules/appointment-calendar/PROTOTYPE_MATRIX.md +++ b/src/modules/appointment-calendar/PROTOTYPE_MATRIX.md @@ -1,5 +1,11 @@ # 预约工作日历逐操作矩阵 +## 2026-10-21 排车候选分页 + +| 页面/组件 | 操作与承载依据 | 本次调整 | 验收 | +|---|---|---|---| +| WorkDispatchForm | 保留既有预约事项深链内的表单、批次范围与整车草稿流程;现行排车契约第17项候选分页 | 表下分页仅请求当前页;说明总数为关联计划候选数,表格仅显示本批货物;跨页保留选择和原批次版本,完整组/来源版本变化阻止建单 | 定向自动检查单独记录;1920×1080、100%待人工截图确认 | + ## 2026-10-20 日期时间组件统一(当前确认) 依据:用户截图 `codex-clipboard-ed442cca-1bd2-43d3-87e8-6671e5bcc508.png`,以及随后明确要求排查并优化同类原生日期输入。保留现有业务入口与承载方式,使用 Element Plus 日期/时间控件及已有公共表单样式。 diff --git a/src/modules/appointment-calendar/WorkDispatchForm.test.ts b/src/modules/appointment-calendar/WorkDispatchForm.test.ts index 847c5f69..214f242d 100644 --- a/src/modules/appointment-calendar/WorkDispatchForm.test.ts +++ b/src/modules/appointment-calendar/WorkDispatchForm.test.ts @@ -48,7 +48,7 @@ beforeEach(() => { natives = [candidate()]; draft = { draftToken: 'server-owned-token', recordVersion: 0, status: 'ACTIVE', warehouseId: 'origin-1', containers: [], sources: [], expiresAt: '2026-10-20T00:00:00Z' } vi.mocked(getReceivingContext).mockImplementation(async key => receiving(key)) vi.mocked(getBatchDispatchCandidates).mockImplementation(async key => ({ batchKey: key, version: 4, candidates: [row('9007199254740993', 'customer-a', key)], blockReasons: [] })) - vi.mocked(listDispatchCandidates).mockImplementation(async () => ({ candidates: clone(natives), complete: true, snapshotAt: '2026-10-19T00:00:00Z' })) + vi.mocked(listDispatchCandidates).mockImplementation(async () => ({ total: 1, page: 1, size: 20, pages: 1, candidates: clone(natives), complete: true, snapshotAt: '2026-10-19T00:00:00Z' })) vi.mocked(createDispatchDraft).mockImplementation(async () => clone(draft)) vi.mocked(createDispatchDraftContainer).mockImplementation(async body => { draft.recordVersion = 1; draft.containers = [{ draftContainerId: 'container-1', sequenceNo: 1, capacity: body.capacity, sourceKeys: [] }]; return clone(draft) }) vi.mocked(lockDispatchDraftPallet).mockImplementation(async body => { const source = natives.find(value => value.selection.planPalletId === body.source.planPalletId)!; draft.recordVersion = Number(draft.recordVersion) + 1; draft.sources.push(clone(source)); draft.containers[0]!.sourceKeys.push(source.sourceKey); return clone(draft) }) @@ -58,7 +58,7 @@ beforeEach(() => { }) it('creates the whole dispatch when native Long candidate quantities arrive as strings and batch quantities are Integers', async () => { const actual = await vi.importActual('../overseas-warehouse/api/dispatches') - const get = vi.spyOn(http, 'get').mockResolvedValue(parseApiJsonResponse(JSON.stringify({ code: '200', data: { candidates: [{ ...candidate(), availablePackages: '12' }], complete: true, snapshotAt: '' } }))) + const get = vi.spyOn(http, 'get').mockResolvedValue(parseApiJsonResponse(JSON.stringify({ code: '200', data: { total: 1, page: 1, size: 20, pages: 1, candidates: [{ ...candidate(), availablePackages: '12' }], complete: true, snapshotAt: '' } }))) vi.mocked(listDispatchCandidates).mockImplementation(actual.listDispatchCandidates) const wrapper = render() try { @@ -98,7 +98,7 @@ it('uses a server-owned draft, explicit zero versions, native source hashes and }) it('combines same-warehouse real customers in one container and keeps each batch source owner', async () => { const second = row('9007199254740994', 'customer-b'); natives.push(candidate(second)); vi.mocked(getBatchDispatchCandidates).mockResolvedValue({ batchKey: batch, version: 4, candidates: [row(), second], blockReasons: [] }) - const wrapper = render(); await flushPromises(); expect(wrapper.findAll('input').map(input => (input.element as HTMLInputElement).checked)).toEqual([true, true]) + const wrapper = render(); await flushPromises(); expect(wrapper.findAll('input[type=checkbox]').map(input => (input.element as HTMLInputElement).checked)).toEqual([true, true]) await button(wrapper, '创建整车排车单').trigger('click'); await flushPromises(); const groups = vi.mocked(convertDispatchDraft).mock.calls[0]![0].groups expect(groups).toHaveLength(1); expect(groups[0]!.dispatch.cargo).toEqual(natives.map(value => value.selection)); expect(groups[0]!.dispatch.batchAllocations.map(value => value.customerId)).toEqual(['customer-a', 'customer-b']); expect(wrapper.text()).not.toContain('共车'); wrapper.unmount() }) @@ -112,12 +112,12 @@ it('keeps blocked, mismatched-customer, wrong-source and unknown-quantity cargo const blocked = { ...row('2'), blockReasons: ['本托已被其他排车占用'] }, wrong = row('3'), unknown = { ...row('4'), packageCount: null }, wrongSource = row('5') wrong.allocations[0]!.customerId = 'customer-b'; wrongSource.allocations[0]!.sourceKey = 'ORDER:unrelated'; natives.push(...[blocked, wrong, unknown, wrongSource].map(value => candidate(value))) vi.mocked(getBatchDispatchCandidates).mockResolvedValue({ batchKey: batch, version: 4, candidates: [row(), blocked, wrong, unknown, wrongSource], blockReasons: [] }) - const wrapper = render(); await flushPromises(); expect(wrapper.findAll('input').map(input => (input.element as HTMLInputElement).checked)).toEqual([true, false, false, false, false]) + const wrapper = render(); await flushPromises(); expect(wrapper.findAll('input[type=checkbox]').map(input => (input.element as HTMLInputElement).checked)).toEqual([true, false, false, false, false]) expect(wrapper.text()).toContain('本托已被其他排车占用'); await button(wrapper, '创建整车排车单').trigger('click'); await flushPromises(); expect(vi.mocked(convertDispatchDraft).mock.calls[0]![0].groups[0]!.dispatch.batchAllocations).toEqual(row().allocations); wrapper.unmount() }) -it('fails closed on incomplete native candidates, missing versions, and cross-warehouse batches', async () => { - vi.mocked(listDispatchCandidates).mockResolvedValueOnce({ candidates: natives, complete: false, snapshotAt: '' }); const incomplete = render(); await flushPromises(); expect(incomplete.text()).toContain('未完整返回'); expect(createDispatchDraft).not.toHaveBeenCalled(); incomplete.unmount() - natives[0]!.selection.sourceVersion = ''; const missing = render(); await flushPromises(); expect(missing.get('input').attributes('disabled')).toBeDefined(); missing.unmount() +it('accepts partial pages but fails closed on missing versions and cross-warehouse batches', async () => { + vi.mocked(listDispatchCandidates).mockResolvedValueOnce({ total: 1, page: 1, size: 20, pages: 1, candidates: natives, complete: false, snapshotAt: '' }); const incomplete = render(); await flushPromises(); expect(incomplete.get('input[type=checkbox]').attributes('disabled')).toBeUndefined(); expect(createDispatchDraft).not.toHaveBeenCalled(); incomplete.unmount() + natives[0]!.selection.sourceVersion = ''; const missing = render(); await flushPromises(); expect(missing.text()).toContain('来源版本不完整'); missing.unmount() vi.mocked(getReceivingContext).mockImplementation(async key => { const value = receiving(key); if (key !== batch) value.batch.originWarehouseId = 'another-warehouse'; return value }) const cross = render({ batchKeys: [batch, 'FBA_APPOINTMENT:2'] }); await flushPromises(); expect(cross.text()).toContain('相同的起运仓'); expect(convertDispatchDraft).not.toHaveBeenCalled(); cross.unmount() }) @@ -160,3 +160,38 @@ it('shows batch-level blockers even without rows and refuses duplicate physical const blocked = render(); await flushPromises(); expect(blocked.get('[role="alert"]').text()).toContain('原批次已替代'); expect(createDispatchDraft).not.toHaveBeenCalled(); blocked.unmount() const duplicate = render({ batchKeys: [batch, 'FBA_APPOINTMENT:2'] }); await flushPromises(); expect(duplicate.findAll('input').every(input => input.attributes('disabled') !== undefined)).toBe(true); expect(duplicate.text()).toContain('同一实物'); expect(convertDispatchDraft).not.toHaveBeenCalled(); duplicate.unmount() }) + +it('keeps original batch allocations and selected cargo while paging through associated plan candidates', async () => { + const first = row(), second = row('9007199254740994', 'customer-b') + natives = [candidate(first), candidate(second)] + vi.mocked(getBatchDispatchCandidates).mockResolvedValue({ batchKey: batch, version: 4, candidates: [first, second], blockReasons: [] }) + vi.mocked(listDispatchCandidates).mockImplementation(async query => ({ total: 21, page: query.page!, size: query.size!, pages: 2, candidates: [clone(natives[query.page === 2 ? 1 : 0]!)], complete: false, snapshotAt: '' })) + const wrapper = render() + try { + await flushPromises(); expect(wrapper.findAll('input[type=checkbox]')).toHaveLength(1) + await wrapper.get('input[type=checkbox]').setValue(true) + const state = wrapper.vm as unknown as { changeCandidatePage(page: number): void } + state.changeCandidatePage(2); await flushPromises(); await wrapper.get('input[type=checkbox]').setValue(true) + expect(listDispatchCandidates).toHaveBeenLastCalledWith(expect.objectContaining({ page: 2, size: 20, warehouseTab: 'ALL', warehouseId: 'origin-1' })) + expect(getBatchDispatchCandidates).toHaveBeenCalledTimes(1) + expect(listDispatchCandidates).toHaveBeenCalledTimes(2) + await button(wrapper, '创建整车排车单').trigger('click'); await flushPromises() + expect(convertDispatchDraft).toHaveBeenCalledTimes(1) + expect(vi.mocked(convertDispatchDraft).mock.calls[0]![0].groups[0]!.dispatch.batchAllocations).toEqual([...first.allocations, ...second.allocations]) + } finally { wrapper.unmount() } +}) +it('rejects a selected batch source whose group version changed on another candidate page', async () => { + vi.mocked(listDispatchCandidates).mockImplementation(async query => { + const value = clone(natives[0]!) + if (query.page === 2) value.selectionGroup.groupVersion = 'new-group-version' + return { total: 21, page: query.page!, size: query.size!, pages: 2, candidates: [value], complete: false, snapshotAt: '' } + }) + const wrapper = render() + try { + await flushPromises(); await wrapper.get('input[type=checkbox]').setValue(true) + ;(wrapper.vm as unknown as { changeCandidatePage(page: number): void }).changeCandidatePage(2) + await flushPromises(); await button(wrapper, '创建整车排车单').trigger('click'); await flushPromises() + expect(wrapper.text()).toContain('选货组组成已变化') + expect(createDispatchDraft).not.toHaveBeenCalled() + } finally { wrapper.unmount() } +}) diff --git a/src/modules/appointment-calendar/WorkDispatchForm.vue b/src/modules/appointment-calendar/WorkDispatchForm.vue index 2f23dfb9..06723b6f 100644 --- a/src/modules/appointment-calendar/WorkDispatchForm.vue +++ b/src/modules/appointment-calendar/WorkDispatchForm.vue @@ -4,7 +4,7 @@ import { computed, onBeforeUnmount, onMounted, ref } from 'vue' import { ElMessage } from 'element-plus' import { useAccessPreviewStore } from '@/core/access/accessPreview' import { useAuthStore } from '@/core/auth/auth' -import { getDispatch, getBatchDispatchCandidates, listDispatchCandidates, createDispatchDraft, createDispatchDraftContainer, listDispatchDrafts, lockDispatchDraftPallet, convertDispatchDraft, releaseDispatchDraft, dispatchVehicleSpecs, DispatchInputError, requireVersion, requireBatchVersions, requireSelectionGroup, expandSelectionGroups, assertSelectionGroupVersions, selectionGroupBlockReason, validateCommandResult, validateCurrentDispatch, isDefiniteDispatchRejection, type BatchDispatchCandidate, type BatchDispatchCandidates, type Candidate, type DispatchDetail, type DispatchDraft, type ConvertDraft, type ConvertedDraft, type DraftSelection, type VersionCommand } from '@/modules/overseas-warehouse' +import { getDispatch, getBatchDispatchCandidates, listDispatchCandidates, useDispatchCandidates, createDispatchDraft, createDispatchDraftContainer, listDispatchDrafts, lockDispatchDraftPallet, convertDispatchDraft, releaseDispatchDraft, dispatchVehicleSpecs, DispatchInputError, requireVersion, requireBatchVersions, requireSelectionGroup, expandSelectionGroups, assertSelectionGroupVersions, selectionGroupBlockReason, validateCommandResult, validateCurrentDispatch, isDefiniteDispatchRejection, type BatchDispatchCandidate, type BatchDispatchCandidates, type Candidate, type DispatchDetail, type DispatchDraft, type ConvertDraft, type ConvertedDraft, type DraftSelection, type VersionCommand } from '@/modules/overseas-warehouse' import LoadErrorState from '@/shared/components/LoadErrorState.vue' import ApiErrorMeta from '@/shared/components/ApiErrorMeta.vue' import { getApiErrorDetails, type ApiErrorDetails } from '@/shared/api/http' @@ -21,14 +21,20 @@ type Preparation = { warehouseId: string; capacity: number; rows: ReadyRow[]; di const access = useAccessPreviewStore(), auth = useAuthStore(), owner = auth.user?.id || '' const scope = JSON.stringify([...new Set(props.batchKeys)].sort()), storageKey = `appointment-dispatch:${owner}:${scope}` const contexts = ref([]), rows = ref([]), selected = ref([]), warehouseId = ref('') -const loading = ref(false), saving = ref(false), error = ref(null), saveError = ref(null) +const working = ref(false), saving = ref(false), error = ref(null), saveError = ref(null) +const candidatePage = useDispatchCandidates(error, listDispatchCandidates) +const { page: candidatePageNumber, size: candidatePageSize, total: candidateTotal } = candidatePage +const loading = computed(() => working.value || candidatePage.loading.value) +const selectedRows = ref>({}) +let receivingContexts: Awaited>[] = [] +let nativeGeneration = 0 const capacity = ref(30), result = ref(null), pending = ref(null), corrupted = ref(false) const adding = ref(false), addingBusy = ref(false), arrangingRemaining = ref(false), existingReady = ref(false) const existing = ref>([]), baseline = ref('[]') const readable = computed(() => ['platform:appointment:list', 'platform:overseas-warehouse:last-mile-order:list', 'platform:overseas-warehouse:inbound-order:list', 'platform:overseas-warehouse:dispatch:list'].every(permission => access.can(permission))) const canCreate = computed(() => readable.value && access.can('platform:overseas-warehouse:dispatch:create')) const writable = computed(() => props.canWrite && canCreate.value && !corrupted.value && (!existing.value.length || existingReady.value)) -const chosen = computed(() => rows.value.filter(row => selected.value.includes(row.key))) +const chosen = computed(() => selected.value.map(key => selectedRows.value[key]).filter((row): row is BatchRow => Boolean(row))) const unresolved = computed(() => saving.value || Boolean(pending.value) || corrupted.value) useWorkDraft(computed(() => JSON.stringify(selected.value) !== baseline.value && !result.value), unresolved) const clone = (value: T): T => JSON.parse(JSON.stringify(value)) as T @@ -43,7 +49,7 @@ function detailPath(no: string) { return `/overseas-warehouse/dispatches/${encod async function load() { if (!readable.value || pending.value || corrupted.value) return const current = ++generation, batches = [...new Set(props.batchKeys)] - loading.value = true; error.value = null; existingReady.value = false; rows.value = []; selected.value = []; baseline.value = '[]'; contexts.value = [] + working.value = true; error.value = null; existingReady.value = false; rows.value = []; selected.value = []; baseline.value = '[]'; contexts.value = []; selectedRows.value = {}; candidatePage.reset(); nativeGeneration++ try { if (!batches.length || batches.some(key => !/^FBA_APPOINTMENT:\d+$/.test(key))) throw new DispatchInputError('请从真实预约批次进入排车,不能重组其他业务批次') const receiving = await Promise.all(batches.map(key => getReceivingContext(key))) @@ -66,16 +72,24 @@ async function load() { if (current !== generation) return if (batchCandidates.some((context, index) => context.batchKey !== batches[index])) throw new DispatchInputError('实物候选与当前预约批次不一致') requireBatchVersions(batchCandidates.flatMap(context => context.candidates.flatMap(row => row.allocations))) - contexts.value = batchCandidates - const planIds = [...new Set(batchCandidates.flatMap(context => context.candidates.map(row => row.planId)))] - const native = planIds.length ? await listDispatchCandidates({ warehouseId: warehouseId.value, planIds }) : { candidates: [], complete: true } - if (current !== generation) return - requireBatchVersions([...batchCandidates.flatMap(context => context.candidates.flatMap(row => row.allocations)), ...native.candidates.flatMap(row => row.appointmentBatches)]) - if (native.complete !== true) throw new DispatchInputError('本仓原生候选未完整返回,不能按部分结果建单') - rows.value = batchCandidates.flatMap((context, index) => context.candidates.map(row => { - const matches = native.candidates.filter(value => value.selection.sourceType === 'INBOUND_PLAN' && value.selection.planPalletId === row.planPalletId && value.customerId === row.customerId) + contexts.value = batchCandidates; receivingContexts = receiving + await loadCandidatePage(true) + } catch (cause) { if (current === generation) error.value = getApiErrorDetails(cause, cause instanceof DispatchInputError ? cause.message : '批次可排实物读取失败') } + finally { if (current === generation) working.value = false } +} +async function loadCandidatePage(autoSelect = false) { + const sequence = ++nativeGeneration, current = generation + const planIds = [...new Set(contexts.value.flatMap(context => context.candidates.map(row => row.planId)))] + if (!planIds.length) { candidatePage.reset(); rows.value = []; return } + await candidatePage.load({ warehouseId: warehouseId.value, planIds, page: candidatePageNumber.value, size: candidatePageSize.value, warehouseTab: 'ALL' }) + if (sequence !== nativeGeneration || current !== generation) return + if (error.value) { rows.value = []; return } + try { + requireBatchVersions(candidatePage.candidates.value.flatMap(row => row.appointmentBatches)) + rows.value = contexts.value.flatMap((context, index) => context.candidates.map(row => { + const matches = candidatePage.candidates.value.filter(value => value.selection.sourceType === 'INBOUND_PLAN' && value.selection.planPalletId === row.planPalletId && value.customerId === row.customerId) const candidate = matches.length === 1 ? matches[0]! : null - const sources = receiving[index]!.batch.items + const sources = receivingContexts[index]!.batch.items const blocks = [...context.blockReasons, ...row.blockReasons] if (!candidate || candidate.warehouseId !== warehouseId.value || !candidate.sourceVersion || candidate.selection.sourceVersion !== candidate.sourceVersion) blocks.push('原生实物来源、起运仓或版本待核实') if (candidate) { const groupBlock = selectionGroupBlockReason(candidate); if (groupBlock) blocks.push(groupBlock) } @@ -84,20 +98,25 @@ async function load() { if (row.allocations.reduce((sum, allocation) => sum + allocation.packageCount, 0) !== row.packageCount) blocks.push('逐来源批次分配与实物箱数不一致') return { ...row, key: `${context.batchKey}:${row.customerId}:${row.planPalletId}`, batchKey: context.batchKey, native: candidate, blockReasons: [...new Set(blocks)] } })) + if (candidateTotal.value > candidatePageSize.value) rows.value = rows.value.filter(row => row.native) for (const row of rows.value) if (row.native && rows.value.filter(other => other.native?.sourceKey === row.native!.sourceKey).length > 1) row.blockReasons.push('同一实物出现在多条批次候选,请先核对分配范围') - const eligible = rows.value.filter(row => !reasons(row).length) - selected.value = batches.length === 1 && physicalCount(eligible) <= capacity.value ? eligible.map(row => row.key) : [] - baseline.value = JSON.stringify(selected.value) - } catch (cause) { if (current === generation) error.value = getApiErrorDetails(cause, cause instanceof DispatchInputError ? cause.message : '批次可排实物读取失败') } - finally { if (current === generation) loading.value = false } + if (autoSelect && candidateTotal.value <= candidatePageSize.value) { + const eligible = rows.value.filter(row => !reasons(row).length) + selected.value = props.batchKeys.length === 1 && physicalCount(eligible) <= capacity.value ? eligible.map(row => row.key) : [] + selectedRows.value = Object.fromEntries(eligible.filter(row => selected.value.includes(row.key)).map(row => [row.key, clone(row)])) + baseline.value = JSON.stringify(selected.value) + } + } catch (cause) { error.value = getApiErrorDetails(cause, cause instanceof DispatchInputError ? cause.message : '批次可排实物读取失败') } } +function changeCandidatePage(page: number) { candidatePageNumber.value = page; void loadCandidatePage() } +function changeCandidateSize(size: number) { candidatePageSize.value = size; candidatePageNumber.value = 1; void loadCandidatePage() } function select(row: BatchRow, event: Event) { const input = event.target as HTMLInputElement if (!writable.value || unresolved.value || loading.value || error.value || reasons(row).length) { input.checked = selected.value.includes(row.key); return } if (!input.checked) selected.value = selected.value.filter(key => key !== row.key) else if (!selected.value.includes(row.key)) { if (physicalCount([...chosen.value, row]) > capacity.value) ElMessage.warning('已达到本组计划托位上限,请核对实际托盘') - else selected.value.push(row.key) + else { selectedRows.value[row.key] = clone(row); selected.value.push(row.key) } } input.checked = selected.value.includes(row.key) } @@ -153,6 +172,7 @@ async function save() { ensureOwner() if (!pending.value) { if (!writable.value || error.value || result.value || !chosen.value.length || chosen.value.some(row => reasons(row).length || !row.native) || physicalCount(chosen.value) > capacity.value) throw new DispatchInputError('请核对本仓实物资格、来源批次与计划托位') + candidatePage.assertCurrent(chosen.value.map(row => row.native!)) pending.value = { warehouseId: warehouseId.value, capacity: capacity.value, rows: clone(chosen.value) as ReadyRow[], dispatchKey: crypto.randomUUID(), draft: null, containerId: null, lockedKeys: [], step: null, converted: null, releasing: false }; persist() } saving.value = true @@ -200,7 +220,7 @@ async function releaseRejected() { } async function remaining() { if (!unresolved.value && !addingBusy.value) { result.value = null; adding.value = false; arrangingRemaining.value = true; await load() } } onMounted(load) -onBeforeUnmount(() => { generation++ }) +onBeforeUnmount(() => { generation++; nativeGeneration++; candidatePage.reset() })

本次草稿与原请求已保留,请勿改变来源、版本或另建排车单。核对并重试原请求

diff --git a/src/modules/container-loading/api/platformContainerCustoms.test.ts b/src/modules/container-loading/api/platformContainerCustoms.test.ts index 70397885..9e42d246 100644 --- a/src/modules/container-loading/api/platformContainerCustoms.test.ts +++ b/src/modules/container-loading/api/platformContainerCustoms.test.ts @@ -1,6 +1,6 @@ import { beforeEach, describe, expect, it, vi } from 'vitest' import { http } from '@/shared/api/http' -import { recordClearanceResult, type DeclarationBatch } from './platformContainerCustoms' +import { createDeclarationBatch, submitDeclarationBatch, recordClearanceResult, type DeclarationBatch } from './platformContainerCustoms' import { completeAllBuyContainerCustoms, downloadContainerCustomsReceipt, downloadContainerCustomsDocument, getContainerCustoms, sendContainerCustomsToBroker, startContainerCustoms, uploadContainerCustomsReceipt } from './platformContainerCustoms' const customs = { @@ -15,6 +15,22 @@ const customs = { describe('platform container customs API', () => { beforeEach(() => vi.restoreAllMocks()) + it('preserves the server batch number when creating and submitting a declaration', async () => { + const batch = { id: '123', customsContainerId: '456', loadingPlanId: '789', batchNo: 'DECL202610200001', sourceVersion: 1, version: 0, results: [] } + const post = vi.spyOn(http, 'post').mockResolvedValue({ code: '200', data: batch }) + const created = await createDeclarationBatch('789', 3) + expect(created.batchNo).toBe('DECL202610200001') + expect(post.mock.calls[0]?.slice(0, 2)).toEqual([ + '/platform/v1/customs/loading-plans/789/declaration-batches', { expectedVersion: 3, remark: null }, + ]) + const submitted = await submitDeclarationBatch(created, ' CUSTOMS-EXTERNAL-1 ') + expect(submitted.batchNo).toBe(created.batchNo) + expect(post.mock.calls[1]?.slice(0, 2)).toEqual([ + '/platform/v1/customs/loading-plans/declaration-batches/123/submit', + { expectedVersion: 0, customsEntryNo: 'CUSTOMS-EXTERNAL-1', remark: null }, + ]) + }) + it('records domestic customs time in Shanghai even when UTC falls on the previous day', async () => { vi.useFakeTimers() try { diff --git a/src/modules/container-loading/api/platformContainerCustoms.ts b/src/modules/container-loading/api/platformContainerCustoms.ts index db2c3cd0..24fc787f 100644 --- a/src/modules/container-loading/api/platformContainerCustoms.ts +++ b/src/modules/container-loading/api/platformContainerCustoms.ts @@ -178,13 +178,13 @@ export async function getDeclarationBatches(loadingPlanId: string) { return (unwrapApiResponse(response) || []).map(normalizeDeclarationBatch) } -export async function createDeclarationBatch(loadingPlanId: string, expectedVersion: number, batchNo?: string) { - const response = await http.post, ApiEnvelope>(`${basePath}/${encodeURIComponent(loadingPlanId)}/declaration-batches`, { expectedVersion, batchNo: batchNo?.trim() || null, remark: null }, { headers: { 'Idempotency-Key': operationId('customs-declaration-batch-create') } }) +export async function createDeclarationBatch(loadingPlanId: string, expectedVersion: number) { + const response = await http.post, ApiEnvelope>(`${basePath}/${encodeURIComponent(loadingPlanId)}/declaration-batches`, { expectedVersion, remark: null }, { headers: { 'Idempotency-Key': operationId('customs-declaration-batch-create') } }) return normalizeDeclarationBatch(unwrapApiResponse(response)) } export async function submitDeclarationBatch(batch: DeclarationBatch, customsEntryNo: string) { - const response = await http.post, ApiEnvelope>(`${basePath}/declaration-batches/${encodeURIComponent(batch.id)}/submit`, { expectedVersion: batch.version, batchNo: batch.batchNo, customsEntryNo: customsEntryNo.trim(), remark: null }, { headers: { 'Idempotency-Key': operationId('customs-declaration-batch-submit') } }) + const response = await http.post, ApiEnvelope>(`${basePath}/declaration-batches/${encodeURIComponent(batch.id)}/submit`, { expectedVersion: batch.version, customsEntryNo: customsEntryNo.trim(), remark: null }, { headers: { 'Idempotency-Key': operationId('customs-declaration-batch-submit') } }) return normalizeDeclarationBatch(unwrapApiResponse(response)) } diff --git a/src/modules/overseas-warehouse/PROTOTYPE_MATRIX.md b/src/modules/overseas-warehouse/PROTOTYPE_MATRIX.md index d6daa46d..ed2487e6 100644 --- a/src/modules/overseas-warehouse/PROTOTYPE_MATRIX.md +++ b/src/modules/overseas-warehouse/PROTOTYPE_MATRIX.md @@ -16,6 +16,13 @@ 本次仅调整列表顶部插槽位置与公共类,不改变详情、新增、编辑、审核、文件预览或取消等操作承载,不修改业务脚本、API 或权限。 +## 2026-10-20 候选服务端分页 + +| 页面/操作 | 已确认承载与依据 | 本批实现 | 验收 | +|---|---|---|---| +| 智能排车/选货分组 | 本文“智能排车在途预排与操作整理”矩阵;现行排车契约第17项的服务端分页;`SmartDispatchDialog.vue` 居中弹框与候选/装车组布局 | 候选表下显示总数、页码和10/20/50条选择;筛选与区域页签交给服务端,变化后回第一页;草稿保留跨页完整组 | 自动检查单独记录;1920×1080、100%待人工截图确认 | +| 既有排车/加货 | `DispatchWorkflowDialog.vue` 的既有1120px居中工作流弹框;同一候选分页契约 | 候选表下分页并显示已选完整组数;跨页保留选择,提交继续检查组版本和批次原始版本 | 自动检查单独记录;1920×1080、100%待人工截图确认 | + ## 2026-10-20 智能排车紧凑布局复核 ### 后续截图:标签、标题与底部操作区对齐 diff --git a/src/modules/overseas-warehouse/api/dispatches.test.ts b/src/modules/overseas-warehouse/api/dispatches.test.ts index c31a7686..7e94b4f7 100644 --- a/src/modules/overseas-warehouse/api/dispatches.test.ts +++ b/src/modules/overseas-warehouse/api/dispatches.test.ts @@ -65,10 +65,10 @@ describe('native whole-vehicle dispatch API', () => { expect(vi.mocked(http.get).mock.calls.map(call => call[0])).toEqual(['/platform/v1/last-leg/dispatches/PC%2F1', '/platform/v1/last-leg/dispatches/PC%2F1/loading', '/platform/v1/last-leg/dispatches/PC%2F1/commands/key%2F1']) }) it('reads candidates with their exact sourceVersion and repeated plan query parameters', async () => { - const data = { candidates: [candidate()], snapshotAt: '2026-10-19T10:00:00Z', complete: true } + const data = { total: 1, page: 1, size: 20, pages: 1, candidates: [candidate()], snapshotAt: '2026-10-19T10:00:00Z', complete: true } vi.mocked(http.get).mockResolvedValueOnce({ data }) - expect(await api.listDispatchCandidates({ warehouseId: '321', planIds: ['11', '12'] })).toEqual(data) - expect(http.get).toHaveBeenCalledWith('/platform/v1/last-leg/dispatches/candidates', { params: { warehouseId: '321', planIds: ['11', '12'] }, paramsSerializer: { indexes: null } }) + expect(await api.listDispatchCandidates({ warehouseId: '321', planIds: ['11', '12'], page: 2, size: 20, warehouseTab: 'NYC' })).toEqual(data) + expect(http.get).toHaveBeenCalledWith('/platform/v1/last-leg/dispatches/candidates', { params: { warehouseId: '321', planIds: ['11', '12'], page: 2, size: 20, warehouseTab: 'NYC' }, paramsSerializer: { indexes: null } }) }) it('creates an empty real dispatch without an artificial customer or cargo', async () => { const request: CreateDispatch = { idempotencyKey: 'create', warehouseId: '321', vehicle: null, driver: null, plannedDepartureAt: null, estimatedArrivalAt: null, remark: null, cargo: [], batchAllocations: [] } diff --git a/src/modules/overseas-warehouse/components/DispatchWorkflowDialog.layout.test.ts b/src/modules/overseas-warehouse/components/DispatchWorkflowDialog.layout.test.ts index 6ca05377..4b177c2a 100644 --- a/src/modules/overseas-warehouse/components/DispatchWorkflowDialog.layout.test.ts +++ b/src/modules/overseas-warehouse/components/DispatchWorkflowDialog.layout.test.ts @@ -54,7 +54,7 @@ beforeEach(() => { vi.mocked(api.getDispatchRoute).mockResolvedValue({ dispatchNo: 'PC/1', recordVersion: 0, edit: gate, stops: [{ index: 0, name: '起运仓', address: '起点地址', destinationKey: null }, { index: 1, name: '目的仓甲', address: '甲地址', destinationKey: 'A' }, { index: 2, name: '外接卸货点', address: '乙地址', destinationKey: 'B' }] }) vi.mocked(api.getDispatchItems).mockResolvedValue({ dispatchNo: 'PC/1', recordVersion: '9007199254740993', status: 'ACTIVE', stage: 'BEFORE_LOADING', items: [item('9223372036854775001'), item('picked', 1)] }) vi.mocked(api.listDispatches).mockResolvedValue(page()) - vi.mocked(api.listDispatchCandidates).mockResolvedValue({ candidates: [sharedPalletCandidates()[0]!], complete: true, snapshotAt: '' }) + vi.mocked(api.listDispatchCandidates).mockResolvedValue({ total: 1, page: 1, size: 20, pages: 1, candidates: [sharedPalletCandidates()[0]!], complete: true, snapshotAt: '' }) vi.mocked(api.getDispatchArrangement).mockResolvedValue(arrangement()) vi.mocked(api.getDispatchEvidence).mockImplementation(async (_, __, id) => evidence(id)) vi.mocked(api.getDispatchEvidenceContent).mockResolvedValue(new Blob(['png'], { type: 'image/png' })) diff --git a/src/modules/overseas-warehouse/components/DispatchWorkflowDialog.test.ts b/src/modules/overseas-warehouse/components/DispatchWorkflowDialog.test.ts index 6104a9de..44e2c0a6 100644 --- a/src/modules/overseas-warehouse/components/DispatchWorkflowDialog.test.ts +++ b/src/modules/overseas-warehouse/components/DispatchWorkflowDialog.test.ts @@ -16,7 +16,7 @@ vi.mock('../api/dispatches', () => ({ getDispatch: vi.fn(), getDispatchItems: vi interface State { submit(): Promise; retryError(): Promise; measurements: Array<{ weightKg: number | null; volumeCbm: number | null; deliveryIndex: number | null; palletSpaces: number | null }>; form: { reason: string; decision: string; remark: string }; detail: DispatchDetail } it('adds all hidden shared-pallet sources once and rejects a changed group composition before another command', async () => { const [first, second] = sharedPalletCandidates() - vi.mocked(api.listDispatches).mockResolvedValue(page()); vi.mocked(api.listDispatchCandidates).mockResolvedValue({ candidates: [first!], complete: true, snapshotAt: '' }) + vi.mocked(api.listDispatches).mockResolvedValue(page()); vi.mocked(api.listDispatchCandidates).mockResolvedValue({ total: 1, page: 1, size: 20, pages: 1, candidates: [first!], complete: true, snapshotAt: '' }) const { wrapper, state } = await open('ADD_CARGO') const selection = wrapper.vm as unknown as { selectCargo(row: NonNullable, checked: boolean): void } selection.selectCargo(first!, true) @@ -25,6 +25,7 @@ it('adds all hidden shared-pallet sources once and rejects a changed group compo first!.selectionGroup.complete = false; selection.selectCargo(first!, false) await state.submit(); expect(api.addDispatchCargo).not.toHaveBeenCalled(); expect(wrapper.text()).toContain('请选择来源完整') first!.selectionGroup.complete = true + await (wrapper.vm as unknown as { searchCargo(): Promise }).searchCargo() selection.selectCargo(first!, true) vi.mocked(api.addDispatchCargo).mockImplementation(async (_, request) => command('ADD_CARGO', request.idempotencyKey)); vi.mocked(api.getDispatch).mockResolvedValue(detail({ recordVersion: 1 })) await state.submit(); expect(api.addDispatchCargo).toHaveBeenCalledExactlyOnceWith('PC/1', expect.objectContaining({ cargo: [first!.selection, second!.selection] })) @@ -32,7 +33,7 @@ it('adds all hidden shared-pallet sources once and rejects a changed group compo }) it.each([0, '0', '9007199254740993'])('adds cargo with original batch version %s while keeping the parent dispatch version independent', async recordVersion => { const value = candidate({ appointmentBatches: [{ batchKey: 'FBA_APPOINTMENT:1', batchNo: 'AP-1', customerId: 'C1', recordVersion, sources: [{ sourceKey: 'ORDER:1', destinationKey: 'FBA:ONT8', packageCount: 2 }] }] }) - vi.mocked(api.listDispatches).mockResolvedValue(page()); vi.mocked(api.listDispatchCandidates).mockResolvedValue({ candidates: [value], complete: true, snapshotAt: '' }) + vi.mocked(api.listDispatches).mockResolvedValue(page()); vi.mocked(api.listDispatchCandidates).mockResolvedValue({ total: 1, page: 1, size: 20, pages: 1, candidates: [value], complete: true, snapshotAt: '' }) const { wrapper, state } = await open('ADD_CARGO') try { (wrapper.vm as unknown as { selectCargo(row: typeof value, checked: boolean): void }).selectCargo(value, true) @@ -43,7 +44,7 @@ it.each([0, '0', '9007199254740993'])('adds cargo with original batch version %s }) it('blocks cargo addition when the authoritative batch version is absent', async () => { const value = candidate({ appointmentBatches: [{ batchKey: 'FBA_APPOINTMENT:1', batchNo: 'AP-1', customerId: 'C1', recordVersion: undefined as unknown as number, sources: [] }] }) - vi.mocked(api.listDispatches).mockResolvedValue(page()); vi.mocked(api.listDispatchCandidates).mockResolvedValue({ candidates: [value], complete: true, snapshotAt: '' }) + vi.mocked(api.listDispatches).mockResolvedValue(page()); vi.mocked(api.listDispatchCandidates).mockResolvedValue({ total: 1, page: 1, size: 20, pages: 1, candidates: [value], complete: true, snapshotAt: '' }) const { wrapper, state } = await open('ADD_CARGO') try { (wrapper.vm as unknown as { selectCargo(row: typeof value, checked: boolean): void }).selectCargo(value, true); await state.submit() @@ -234,3 +235,30 @@ it('describes a proven success with a failed GET as completed and retries only i expect(wrapper.emitted('saved')).toHaveLength(1) wrapper.unmount() }) + +it('preserves selected complete groups across pages and submits hidden sources with their original versions', async () => { + const [first, hidden] = sharedPalletCandidates(), second = candidate({ sourceKey: 'next-page' }) + vi.mocked(api.listDispatches).mockResolvedValue(page()) + vi.mocked(api.listDispatchCandidates).mockImplementation(async query => ({ candidates: query.page === 2 ? [second] : [first!], page: query.page!, size: query.size!, total: 21, pages: 2, complete: false, snapshotAt: '' })) + const { wrapper, state } = await open('ADD_CARGO') + try { + const selection = wrapper.vm as unknown as { selectCargo(row: typeof second, checked: boolean): void; changeCandidatePage(value: number): void; candidatePageNumber: number; candidateKeyword: string; searchCargo(): Promise } + selection.selectCargo(first!, true); selection.changeCandidatePage(2); await flushPromises(); selection.selectCargo(second, true); await flushPromises() + expect(wrapper.text()).toContain('已选择 2 个完整来源组') + selection.candidateKeyword = 'next'; await selection.searchCargo() + expect(api.listDispatchCandidates).toHaveBeenLastCalledWith(expect.objectContaining({ page: 1, orderNo: 'next' })) + expect(api.listDispatches).toHaveBeenCalledTimes(1) + vi.mocked(api.addDispatchCargo).mockImplementation(async (_, request) => command('ADD_CARGO', request.idempotencyKey)); vi.mocked(api.getDispatch).mockResolvedValue(detail({ recordVersion: 1 })) + await state.submit() + expect(api.addDispatchCargo).toHaveBeenCalledWith('PC/1', expect.objectContaining({ cargo: [first!.selection, hidden!.selection, second.selection] })) + } finally { wrapper.unmount() } +}) +it('shows authoritative warehouse lookup failures when retrying a cargo search', async () => { + vi.mocked(api.listDispatches).mockRejectedValue(new Error('warehouse lookup unavailable')) + const { wrapper } = await open('ADD_CARGO') + try { + await (wrapper.vm as unknown as { searchCargo(): Promise }).searchCargo() + expect(wrapper.text()).toContain('货物候选读取失败') + expect(api.listDispatchCandidates).not.toHaveBeenCalled() + } finally { wrapper.unmount() } +}) diff --git a/src/modules/overseas-warehouse/components/DispatchWorkflowDialog.vue b/src/modules/overseas-warehouse/components/DispatchWorkflowDialog.vue index 5e2f3def..9e7053ae 100644 --- a/src/modules/overseas-warehouse/components/DispatchWorkflowDialog.vue +++ b/src/modules/overseas-warehouse/components/DispatchWorkflowDialog.vue @@ -11,6 +11,7 @@ import LineClampText from '@/shared/components/LineClampText.vue' import ApiErrorMeta from '@/shared/components/ApiErrorMeta.vue' import LoadErrorState from '@/shared/components/LoadErrorState.vue' import * as api from '../api/dispatches' +import { useDispatchCandidates } from '../useDispatchCandidates' import type { AddCargo, ArrangeDelivery, ArrangeGroup, ArrangementPreview, Candidate, CommandResult, DispatchAction, DispatchDetail, Driver, LoadingComplete, LoadingPreview, ReasonCommand, ReviewCommand, UpdateDispatch, Vehicle, VersionCommand } from '../dispatchContracts' import type { DispatchItems, DispatchRoute, DispatchRouteCommand, DispatchRouteStop } from '../dispatchContracts' import { DispatchInputError, requireVersion, requireBatchVersions, requireSelectionGroup, expandSelectionGroups, selectionGroupBlockReason } from '../dispatchContracts' @@ -30,11 +31,16 @@ const currentAction = computed(() => pending.value?.action || props.action) const currentNo = computed(() => pending.value?.dispatchNo || props.dispatchNo) const currentOperation = computed(() => pending.value ? pending.value.operation : props.operation) const items = ref(null), itemId = ref(''), route = ref(null), stops = ref([]) -const detail = ref(null), loading = ref(false), error = ref(null) +const detail = ref(null), working = ref(false), error = ref(null) const factsStale = ref(false) const preview = ref(null), arrangement = ref(null), groups = ref([]) const arrangeFields = ref | null>(null) -const candidates = ref([]), selected = ref>([]), candidateKeyword = ref('') +const candidatePage = useDispatchCandidates(error) +const { candidates, page: candidatePageNumber, size: candidatePageSize, total: candidateTotal } = candidatePage +const loading = computed(() => working.value || candidatePage.loading.value) +const selected = ref>([]), candidateKeyword = ref('') +const candidateWarehouseId = ref('') +let candidateFilterKey = '' const measurements = ref>([]) const blankVehicle = (): Vehicle => ({ mode: 'MASTER', vehicleId: null, plate: null, carrierName: null, capacity: { palletSpaces: null, maxLoadKg: null, maxVolumeCbm: null }, evidenceFileIds: [] }) const blankDriver = (): Driver => ({ mode: 'MASTER', driverId: null, name: null, phone: null, evidence: { licenseNo: null, licenseExpiresOn: null, fileIds: [], expectedTaskEndAt: null } }) @@ -50,9 +56,10 @@ const uploadingEvidence = computed(() => evidenceBusy.VEHICLE || evidenceBusy.DR async function load() { const sequence = ++generation, no = currentNo.value, action = currentAction.value - if (editorRequestKey && pending.value?.body.idempotencyKey === editorRequestKey && detail.value?.dispatchNo === no) { loading.value = false; return } - loading.value = true; factsStale.value = false; error.value = null; detail.value = null; preview.value = null; arrangement.value = null; selected.value = [] + if (editorRequestKey && pending.value?.body.idempotencyKey === editorRequestKey && detail.value?.dispatchNo === no) { working.value = false; return } + working.value = true; factsStale.value = false; error.value = null; detail.value = null; preview.value = null; arrangement.value = null; selected.value = [] items.value = null; itemId.value = ''; route.value = null; stops.value = [] + candidatePage.reset(); candidateWarehouseId.value = '' try { if (action === 'CREATE') throw new DispatchInputError('请从排车列表的原请求入口恢复新建排车') const value = await api.getDispatch(no) @@ -97,20 +104,32 @@ async function load() { } if (action === 'ADD_CARGO') await loadCandidates(sequence) } catch (cause) { if (sequence === generation) error.value = getApiErrorDetails(cause, cause instanceof DispatchInputError ? cause.message : '排车操作资料读取失败') } - finally { if (sequence === generation) loading.value = false } + finally { if (sequence === generation) working.value = false } } async function loadCandidates(sequence = generation) { - // Detail has no warehouse field: resolve the authoritative list row by this business number. - const page = await api.listDispatches({ page: 1, size: 1, dispatchNo: currentNo.value, status: 'ACTIVE' }) - const row = page.records.find(item => item.dispatchNo === currentNo.value) - if (!row?.warehouseId) throw new DispatchInputError('当前排车起运仓未返回,请刷新核对') - const result = await api.listDispatchCandidates({ warehouseId: row.warehouseId, orderNo: candidateKeyword.value || undefined }) + if (!candidateWarehouseId.value) { + // Detail has no warehouse field: resolve the authoritative list row by this business number. + const no = currentNo.value + const result = await api.listDispatches({ page: 1, size: 1, dispatchNo: no, status: 'ACTIVE' }) + if (sequence !== generation) return + const row = result.records.find(item => item.dispatchNo === no) + if (!row?.warehouseId) throw new DispatchInputError('当前排车起运仓未返回,请刷新核对') + candidateWarehouseId.value = row.warehouseId + } if (sequence !== generation) return - if (result.complete !== true) throw new DispatchInputError('候选来源未完整返回,请缩小范围重新查询') - if (result.candidates.some(source => source.warehouseId !== row.warehouseId || !source.sourceVersion || source.selection.sourceVersion !== source.sourceVersion)) throw new DispatchInputError('货物起运仓或来源版本不完整,请重新读取') - candidates.value = result.candidates + const filterKey = JSON.stringify([candidateWarehouseId.value, candidateKeyword.value]) + if (filterKey !== candidateFilterKey) { candidatePageNumber.value = 1; candidateFilterKey = filterKey } + await candidatePage.load({ warehouseId: candidateWarehouseId.value, orderNo: candidateKeyword.value || undefined, page: candidatePageNumber.value, size: candidatePageSize.value, warehouseTab: 'ALL' }) } -async function searchCargo() { if (frozen.value) return; loading.value = true; error.value = null; try { await loadCandidates() } catch (cause) { error.value = getApiErrorDetails(cause, cause instanceof DispatchInputError ? cause.message : '货物候选读取失败') } finally { loading.value = false } } +async function searchCargo() { + if (frozen.value) return + const sequence = generation + candidatePageNumber.value = 1 + try { await loadCandidates(sequence) } + catch (cause) { if (sequence === generation) error.value = getApiErrorDetails(cause, cause instanceof DispatchInputError ? cause.message : '货物候选读取失败') } +} +function changeCandidatePage(value: number) { candidatePageNumber.value = value; void loadCandidates() } +function changeCandidateSize(value: number) { candidatePageSize.value = value; void searchCargo() } function requirePlanPallet(row: Candidate): string { if (!row.selection.planPalletId) throw new DispatchInputError('批次分配缺少真实计划来源,请核对') @@ -122,7 +141,7 @@ function selectCargo(row: Candidate, checked: unknown) { if (checked !== true) { selected.value = selected.value.filter(value => value.groupKey !== row.selectionGroup?.groupKey && value.sourceKey !== row.sourceKey); return } const group = requireSelectionGroup(row) selected.value = selected.value.filter(value => value.groupKey !== group.groupKey && value.sourceKey !== row.sourceKey) - if (checked === true) selected.value.push({ sourceKey: row.sourceKey, groupKey: group.groupKey, groupVersion: group.groupVersion }) + if (checked === true) selected.value.push({ sourceKey: row.sourceKey, groupKey: group.groupKey, groupVersion: group.groupVersion, row }) } catch (cause) { error.value = getApiErrorDetails(cause, cause instanceof Error ? cause.message : '完整选货组无效') } } function payload(): object { @@ -142,12 +161,13 @@ function payload(): object { case 'EDIT': return { ...common, vehicle: vehicle.value, driver: driver.value, plannedDepartureAt: form.plannedDepartureAt || null, estimatedArrivalAt: form.estimatedArrivalAt || null, remark: form.remark || null } satisfies UpdateDispatch case 'ADD_CARGO': { const chosen = selected.value.map(value => { - const row = candidates.value.find(candidate => candidate.sourceKey === value.sourceKey) + const row = value.row if (!row || row.selectionGroup?.groupKey !== value.groupKey || row.selectionGroup.groupVersion !== value.groupVersion) throw new DispatchInputError('选货组组成已变化,请重新读取并选择货物') return row }) + candidatePage.assertCurrent(chosen) requireBatchVersions(chosen.flatMap(row => row.appointmentBatches)) - if (!chosen.length || chosen.some(row => row.blockReasons.length || !row.sourceVersion || row.sourceVersion !== row.selection.sourceVersion || row.appointmentBatches.some(batch => batch.customerId !== row.customerId))) throw new DispatchInputError('请选择来源完整、预约客户一致且可排的货物') + if (!chosen.length || chosen.some(row => row.warehouseId !== candidateWarehouseId.value || row.blockReasons.length || !row.sourceVersion || row.sourceVersion !== row.selection.sourceVersion || row.appointmentBatches.some(batch => batch.customerId !== row.customerId))) throw new DispatchInputError('请选择来源完整、预约客户一致且可排的货物') return { ...common, cargo: expandSelectionGroups(chosen), batchAllocations: chosen.flatMap(row => row.appointmentBatches.flatMap(batch => batch.sources.map(source => ({ planPalletId: requirePlanPallet(row), batchKey: batch.batchKey, customerId: batch.customerId, ...source, recordVersion: batch.recordVersion })))) } satisfies AddCargo } case 'DISPATCH_REVIEW': case 'LOADING_REVIEW': @@ -221,7 +241,7 @@ async function submit() { } async function refreshFacts() { const sequence = ++generation, no = currentNo.value - loading.value = true; factsStale.value = true + working.value = true; factsStale.value = true try { const value = await api.getDispatch(no) if (sequence !== generation) return @@ -238,11 +258,11 @@ async function refreshFacts() { } catch (cause) { // Retain the original rejection and every editor value if its follow-up read also fails. if (sequence === generation && !error.value) error.value = getApiErrorDetails(cause, '当前操作资格读取失败,请重试刷新') - } finally { if (sequence === generation) loading.value = false } + } finally { if (sequence === generation) working.value = false } } async function retryError() { if (pending.value) await submit(); else if (detail.value) await refreshFacts(); else await load() } function moveStop(index: number, offset: number) { const target = index + offset; if (frozen.value || target < 0 || target >= stops.value.length) return; [stops.value[index], stops.value[target]] = [stops.value[target]!, stops.value[index]!] } -watch([open, () => props.dispatchNo, () => props.action, () => props.operation], ([value]) => { if (value) void load(); else generation++ }, { immediate: true }) +watch([open, () => props.dispatchNo, () => props.action, () => props.operation], ([value]) => { if (value) void load(); else { generation++; candidatePage.reset() } }, { immediate: true })