fix: remove sealed smart-loading rows by pallet

This commit is contained in:
2026-09-14 14:35:30 +08:00
parent 85b3606eca
commit afa49bf1f1
4 changed files with 58 additions and 3 deletions
@@ -22,6 +22,7 @@ import {
removeAllUnpickedSmartLoadingItems,
removeSmartLoadingGroup,
removeSmartLoadingItem,
removeSmartLoadingPallet,
} from '../api/platformContainerLoading'
const { routerPush } = vi.hoisted(() => ({ routerPush: vi.fn() }))
@@ -50,6 +51,7 @@ vi.mock('../api/platformContainerLoading', () => ({
adjustSmartLoadingItem: vi.fn(),
removeSmartLoadingItem: vi.fn(),
removeSmartLoadingGroup: vi.fn(),
removeSmartLoadingPallet: vi.fn(),
removeAllUnpickedSmartLoadingItems: vi.fn(),
pushSmartLoadingPreload: vi.fn(),
}))
@@ -861,6 +863,29 @@ describe('GlobalSmartLoadingView', () => {
expect(wrapper.findAll('button').some((button) => button.text().includes('移除未拣'))).toBe(false)
})
it('removes a sealed pallet row through the whole-pallet command', async () => {
const palletItem = {
...plan.items[0], unitType: 'SEALED_PALLET' as const, palletId: '801', palletNo: 'DP-260914-0021',
indivisible: true, packageCount: 10, pickedPackageCount: 0, minPackageCount: 10,
canAdjust: false, canRemove: true,
}
const palletPlan = { ...plan, items: [palletItem] }
const emptyPlan = { ...palletPlan, version: 3, items: [] }
vi.mocked(getSmartLoadingPlanByBooking).mockResolvedValue(palletPlan)
vi.mocked(removeSmartLoadingPallet).mockResolvedValue(emptyPlan)
const wrapper = mount(GlobalSmartLoadingView, { global: { plugins: [ElementPlus] } })
await flushPromises()
const row = wrapper.findAll('tr').find((candidateRow) => candidateRow.text().includes('DP-260914-0021'))
expect(row).toBeDefined()
await row!.find('.el-button--danger').trigger('click')
await flushPromises()
expect(removeSmartLoadingPallet).toHaveBeenCalledWith(plan.id, '801', 2)
expect(removeSmartLoadingItem).not.toHaveBeenCalled()
})
it('renders final completion capability as read-only with the server reason', async () => {
vi.mocked(getSmartLoadingPlanByBooking).mockResolvedValue({
...plan,
@@ -26,6 +26,7 @@ import {
removeAllUnpickedSmartLoadingItems,
removeSmartLoadingGroup,
removeSmartLoadingItem,
removeSmartLoadingPallet,
} from '../api/platformContainerLoading'
import type {
SmartLoadingCandidate,
@@ -585,10 +586,14 @@ async function remove(source: object) {
const item = itemRow(source)
if (!plan.value || !item.canRemove) return
const row = source as SmartLoadingPlanRow
const sealedPallet = item.unitType === 'SEALED_PALLET' && Boolean(item.palletId)
const confirmed = await ElMessageBox.confirm(row.coLoadGroup
? `确认整组移除 ${row.coLoadGroup.groupNo}(${groupMemberLabel(row.coLoadGroup)}、${row.packageCount} 箱)吗?组内所有入仓片段将联动移除。`
: `确认从当前柜次移除入仓码“${item.inboundCode || '—'}”的 ${item.packageCount} 箱吗?`, row.coLoadGroup ? '移除同柜不可拆组' : '移除装柜明细', {
type: 'warning', confirmButtonText: row.coLoadGroup ? '移除整组' : '移除', cancelButtonText: '取消',
: sealedPallet
? `确认从当前柜次整托移除托盘“${item.palletNo || '—'}”(${item.packageCount} 箱)吗?`
: `确认从当前柜次移除入仓码“${item.inboundCode || '—'}”的 ${item.packageCount} 箱吗?`,
row.coLoadGroup ? '移除同柜不可拆组' : sealedPallet ? '整托移除' : '移除装柜明细', {
type: 'warning', confirmButtonText: row.coLoadGroup ? '移除整组' : sealedPallet ? '整托移除' : '移除', cancelButtonText: '取消',
}).catch(() => false)
if (!confirmed || !plan.value) return
await mutate(async () => {
@@ -598,6 +603,12 @@ async function remove(source: object) {
ElMessage.success(`同柜不可拆组 ${row.coLoadGroup.groupNo} 已整组移除`)
return
}
if (sealedPallet && item.palletId) {
acceptPlan(await removeSmartLoadingPallet(plan.value!.id, item.palletId, plan.value!.version))
await loadCandidateData()
ElMessage.success(`托盘 ${item.palletNo || '—'} 已整托移除`)
return
}
let current = plan.value!
for (const original of item.sourceItems) {
const currentItem = current.items.find((value) => value.id === original.id)