装柜优化
This commit is contained in:
@@ -99,6 +99,28 @@ describe('GlobalSmartLoadingView', () => {
|
||||
expect(wrapper.text()).toContain('CB-1 装柜方案')
|
||||
})
|
||||
|
||||
it('does not overwrite the container status when selecting it', async () => {
|
||||
const waiting = { ...container, id: '9007199254740995', planId: '9007199254740996', cabinetNo: 'CB-WAIT', planStatus: 'WAIT_LOADING' as const }
|
||||
vi.mocked(listContainers).mockResolvedValue({ records: [container, waiting], page: 1, size: 100, total: 2, pages: 1 })
|
||||
vi.mocked(getSmartLoadingPlanByBooking).mockImplementation(async (bookingId) => (
|
||||
bookingId === waiting.id
|
||||
? { ...plan, bookingId: waiting.id, status: 'LOADING' as const }
|
||||
: plan
|
||||
))
|
||||
const wrapper = mount(GlobalSmartLoadingView, { global: { plugins: [ElementPlus] } })
|
||||
await flushPromises()
|
||||
|
||||
const waitingOption = wrapper.findAll('.container-option').find((item) => item.text().includes('CB-WAIT'))!
|
||||
expect(waitingOption.text()).toContain('待装柜')
|
||||
|
||||
await waitingOption.trigger('click')
|
||||
await flushPromises()
|
||||
|
||||
expect(getSmartLoadingPlanByBooking).toHaveBeenCalledWith(waiting.id)
|
||||
expect(waitingOption.text()).toContain('待装柜')
|
||||
expect(waitingOption.text()).not.toContain('拣货中')
|
||||
})
|
||||
|
||||
it('keeps picking containers editable while hiding the push action', async () => {
|
||||
const pushed = { ...container, id: '9007199254740995', planId: '9007199254740996', cabinetNo: 'CB-2', planStatus: 'LOADING' as const }
|
||||
const pickingPlan = { ...plan, bookingId: pushed.id, status: 'LOADING' as const }
|
||||
|
||||
@@ -142,14 +142,14 @@ function syncDrafts(next: SmartLoadingPlan, preserved: Record<string, number> =
|
||||
for (const key of Object.keys(quantityDrafts)) delete quantityDrafts[key]
|
||||
for (const item of next.items || []) quantityDrafts[item.id] = preserved[item.id] ?? item.packageCount
|
||||
}
|
||||
function acceptPlan(next: SmartLoadingPlan, preserved: Record<string, number> = {}) {
|
||||
function acceptPlan(next: SmartLoadingPlan, preserved: Record<string, number> = {}, syncContainerStatus = true) {
|
||||
plan.value = next
|
||||
noDraft.value = false
|
||||
syncDrafts(next, preserved)
|
||||
const container = selectedContainer.value
|
||||
if (container) {
|
||||
container.planId = next.id
|
||||
container.planStatus = next.status
|
||||
if (syncContainerStatus) container.planStatus = next.status
|
||||
}
|
||||
}
|
||||
function clearSelectionData() {
|
||||
@@ -178,7 +178,7 @@ async function loadSelectedData(preserved: Record<string, number> = {}) {
|
||||
])
|
||||
if (request !== selectionRequest) return
|
||||
candidates.value = candidateResult
|
||||
if (planResult.value) acceptPlan(planResult.value, preserved)
|
||||
if (planResult.value) acceptPlan(planResult.value, preserved, false)
|
||||
else noDraft.value = planResult.missing
|
||||
} catch (error) {
|
||||
if (request === selectionRequest) selectionError.value = getApiErrorDetails(error, '柜次装柜数据加载失败')
|
||||
|
||||
Reference in New Issue
Block a user