This commit is contained in:
2026-10-28 11:30:00 +08:00
parent e41e9e6d3f
commit ee7386f401
5 changed files with 21 additions and 3 deletions
@@ -177,6 +177,7 @@ it.each([false, true])('confirms the %s photo stage with its own evidence and cu
const wrapper = mount(TransportExecutionPanel, { ...options, props: { dispatchNo: 'PC1', pickupApproved: true } }); await flushPromises()
expect(wrapper.text()).toContain(arriving ? '派送中' : '装货中')
expect(wrapper.findAll('button').some(button => button.text() === '确认发车')).toBe(false)
expect(wrapper.findAll('button').some(button => ['维护车辆信息', '取消排车'].includes(button.text()))).toBe(false)
await wrapper.findAll('button').find(button => button.text() === (arriving ? '上传到仓照片' : '上传装货照片'))!.trigger('click'); await flushPromises()
if (!arriving) {
const quantity = wrapper.get('input[role="spinbutton"]')
@@ -38,7 +38,9 @@ const pickupStage = computed(() => trip.value?.status === 'COMPLETED' ? '取货
const pending = ref<{ suffix: string; body: object; kind?: 'cancel' } | null>(null)
const trip = computed(() => detail.value?.execution.trip)
const editable = computed(() => !props.readonly && access.can(permission.EDIT))
const canChangeResources = computed(() => trip.value?.status === 'PLANNED' && props.pickupStage !== 'LOADING' && !detail.value?.pickups.some(row => row.status !== 'ASSIGNED'))
const canChangeResources = computed(() => trip.value?.status === 'PLANNED' && props.pickupStage !== 'LOADING'
&& !(detail.value?.taskType === 'PICKUP' && (props.pickupApproved || props.pickupReviewState === 'APPROVED' || (props.pickupStage && props.pickupStage !== 'BEFORE_LOADING')))
&& !detail.value?.pickups.some(row => row.status !== 'ASSIGNED'))
const resourceFormOpen = computed(() => canChangeResources.value && editable.value && (editingResources.value || !trip.value?.vehicleId || !trip.value?.driverId))
const locked = computed(() => busy.value || !!pending.value || licenseLoading.value || Object.values(photoBusy).some(Boolean))
const completionAction = computed(() => {
@@ -72,10 +72,14 @@ it('confirms cancelling pickup and linked transfers using the transport version'
wrapper.unmount(); confirm.mockRestore()
})
it.each([['LOADING', '上传装货照片'], ['DELIVERING', '上传到仓照片']] as const)('opens pickup %s work from the list while detail stays separate', async (stage, label) => {
vi.mocked(listDispatches).mockResolvedValue(page([listRow({ taskType: 'PICKUP', stage, reviewState: 'APPROVED', actions: {} })]))
const allowed = { allowed: true, blockCode: null, blockReason: null }
vi.mocked(listDispatches).mockResolvedValue(page([listRow({ taskType: 'PICKUP', stage, reviewState: 'APPROVED', actions: { EDIT: allowed, CANCEL: allowed } })]))
const wrapper = mount(DispatchesView, options); await flushPromises()
const row = wrapper.findAllComponents(RowActions).find(entry => entry.props('moreLabel') === '更多操作 · PC/1')!
expect(row.props('actions')).toEqual([expect.objectContaining({ key: 'transport', label }), expect.objectContaining({ key: 'detail', label: '详情' })])
row.vm.$emit('action', 'EDIT'); row.vm.$emit('action', 'CANCEL'); await flushPromises()
expect(wrapper.findComponent({ name: 'TransportExecutionPanel' }).exists()).toBe(false)
expect(cancelTransport).not.toHaveBeenCalled()
row.vm.$emit('action', 'transport'); await flushPromises()
expect(wrapper.getComponent({ name: 'TransportExecutionPanel' }).props()).toMatchObject({ dispatchNo: 'PC/1', pickupApproved: true, editResources: false })
expect(push).not.toHaveBeenCalled()
@@ -140,7 +140,9 @@ function rowActions(row: DispatchListRow): RowActionItem[] {
{ key: 'detail', label: '详情', priority: 500 },
]
}
const available = rowActionOrder.filter(value => (value !== 'SUBMIT_REVIEW' || row.taskType === 'PICKUP') && canDispatchAction(row.actions, value, access.can))
const available = rowActionOrder.filter(value => (value !== 'SUBMIT_REVIEW' || row.taskType === 'PICKUP')
&& !(row.taskType === 'PICKUP' && ['EDIT', 'CANCEL'].includes(value) && (row.stage !== 'BEFORE_LOADING' || row.reviewState === 'APPROVED'))
&& canDispatchAction(row.actions, value, access.can))
const primaryAction = available.find(value => value === 'EDIT') ?? available[0]
const execution = pickupExecutionLabel(row)
return [...(execution ? [{ key: 'transport', label: execution, priority: 650 }] : []), ...(canManageDocuments(row) ? [{ key: 'documents', label: '管理资料', priority: 700 }] : []), ...available.map((value, index) => ({
@@ -270,6 +270,15 @@ describe('LastMileOrderDetailView domestic detail alignment', () => {
settlementMode: payable ? 'ON_ACCOUNT' : undefined, chargeableQuantity: 2, quantityUnit: '托', unitPrice: 40,
})
})
it.each(['BILL', 'WALLET'])('submits receivable settlement mode %s from the fee editor', async settlementMode => {
const { dialog } = await openFeeEditor()
await fillFee(dialog, 'RECEIVABLE')
dialog.findAllComponents({ name: 'ElSelect' }).find(select => select.props('placeholder') === '按业务默认规则')!.vm.$emit('update:modelValue', settlementMode)
await flushPromises()
await dialog.findAll('button').find(button => button.text() === '保存费用')!.trigger('click')
await flushPromises()
expect(createLastMileOrderFee).toHaveBeenCalledWith('internal-order-id', expect.objectContaining({ direction: 'RECEIVABLE', settlementMode }))
})
it('keeps fee required-field validation before a request', async () => {
const { dialog } = await openFeeEditor()
await dialog.findAll('button').find(button => button.text() === '保存费用')!.trigger('click'); await flushPromises()