Merge branch 'release/test' of http://8.163.30.128:10082/html/admin-web into dev
This commit is contained in:
@@ -312,13 +312,13 @@ describe('GlobalSmartLoadingView', () => {
|
||||
const wrapper = mount(GlobalSmartLoadingView, { global: { plugins: [ElementPlus] } })
|
||||
await flushPromises()
|
||||
vi.mocked(getSmartLoadingPlanByBooking).mockResolvedValue({ ...plan, version: 3 })
|
||||
vi.mocked(recommendSmartLoading).mockRejectedValue(new AxiosError(
|
||||
vi.mocked(recommendSmartLoading).mockRejectedValueOnce(new AxiosError(
|
||||
'conflict',
|
||||
'ERR_BAD_REQUEST',
|
||||
undefined,
|
||||
undefined,
|
||||
{ data: { code: 'A0409', message: '数据已被修改', requestId: 'request-1', traceId: 'trace-1' }, status: 200, statusText: 'OK', headers: {}, config: {} as never },
|
||||
))
|
||||
)).mockResolvedValueOnce({ ...plan, version: 4 })
|
||||
|
||||
const button = wrapper.findAll('button').find((item) => item.text().includes('智能推荐'))
|
||||
expect(button).toBeDefined()
|
||||
@@ -326,8 +326,9 @@ describe('GlobalSmartLoadingView', () => {
|
||||
await flushPromises()
|
||||
|
||||
expect(recommendSmartLoading).toHaveBeenCalledWith(plan.id, 2)
|
||||
expect(getSmartLoadingPlanByBooking).toHaveBeenCalledTimes(2)
|
||||
expect(warningMessage).toHaveBeenCalledWith('计划或 PDA 明细已变化,已刷新最新版本并保留筛选条件,请重新操作')
|
||||
expect(recommendSmartLoading).toHaveBeenCalledWith(plan.id, 3)
|
||||
expect(getSmartLoadingPlanByBooking).toHaveBeenCalledTimes(3)
|
||||
expect(warningMessage).not.toHaveBeenCalled()
|
||||
expect(wrapper.text()).not.toContain('装柜操作失败')
|
||||
expect(wrapper.text()).not.toContain('request-1')
|
||||
})
|
||||
|
||||
@@ -296,7 +296,15 @@ async function assign() {
|
||||
async function recommend() {
|
||||
if (!plan.value) return
|
||||
await mutate(async () => {
|
||||
acceptPlan(await recommendSmartLoading(plan.value!.id, plan.value!.version))
|
||||
try {
|
||||
acceptPlan(await recommendSmartLoading(plan.value!.id, plan.value!.version))
|
||||
} catch (error) {
|
||||
const details = getApiErrorDetails(error, '智能推荐失败')
|
||||
if (details.code !== 'A0409' || !/(版本|并发|已被修改|已变化)/.test(details.message)) throw error
|
||||
await loadSelectedData()
|
||||
if (!plan.value) throw error
|
||||
acceptPlan(await recommendSmartLoading(plan.value.id, plan.value.version))
|
||||
}
|
||||
await loadSelectedData()
|
||||
ElMessage.success('智能推荐已生成')
|
||||
}, '智能推荐失败')
|
||||
@@ -377,7 +385,7 @@ async function mutate(
|
||||
const pickingMessage = recovery.pickingConflict && details.message.includes('拣货')
|
||||
? '该订单在拣货中不许删除'
|
||||
: null
|
||||
const message = pickingMessage || '计划或 PDA 明细已变化,已刷新最新版本并保留筛选条件,请重新操作'
|
||||
const message = pickingMessage || details.message || '计划或 PDA 明细已变化,已刷新最新版本并保留筛选条件,请重新操作'
|
||||
if (recovery.preserveAssign) assignOpen.value = true
|
||||
if (pickingMessage) ElMessage.error(pickingMessage)
|
||||
else ElMessage.warning(message)
|
||||
|
||||
@@ -75,10 +75,10 @@ describe('SmartLoadingWorkbenchView', () => {
|
||||
vi.mocked(getSmartLoadingPlanByBooking)
|
||||
.mockResolvedValueOnce(planResponse)
|
||||
.mockResolvedValueOnce({ ...planResponse, version: 3 })
|
||||
vi.mocked(recommendSmartLoading).mockRejectedValue(new AxiosError(
|
||||
vi.mocked(recommendSmartLoading).mockRejectedValueOnce(new AxiosError(
|
||||
'conflict', 'ERR_BAD_REQUEST', undefined, undefined,
|
||||
{ data: { code: 'A0409', message: '数据已被修改', requestId: 'request-1', traceId: 'trace-1' }, status: 200, statusText: 'OK', headers: {}, config: {} as never },
|
||||
))
|
||||
)).mockResolvedValueOnce({ ...planResponse, version: 4 })
|
||||
const router = createRouter({ history: createMemoryHistory(), routes: [{ path: '/container-loading/:containerId/smart-loading', component: SmartLoadingWorkbenchView }] })
|
||||
await router.push(`/container-loading/${container.id}/smart-loading`); await router.isReady()
|
||||
const wrapper = mount(SmartLoadingWorkbenchView, { global: { plugins: [ElementPlus, router] } })
|
||||
@@ -87,8 +87,9 @@ describe('SmartLoadingWorkbenchView', () => {
|
||||
await wrapper.findAll('button').find((button) => button.text().includes('智能推荐'))!.trigger('click')
|
||||
await flushPromises()
|
||||
expect(getSmartLoadingPlanByBooking).toHaveBeenCalledTimes(2)
|
||||
expect(wrapper.text()).toContain('已刷新最新版本')
|
||||
expect(wrapper.text()).toContain('request-1')
|
||||
expect(recommendSmartLoading).toHaveBeenCalledWith(planResponse.id, 2)
|
||||
expect(recommendSmartLoading).toHaveBeenCalledWith(planResponse.id, 3)
|
||||
expect(wrapper.text()).not.toContain('排柜操作失败')
|
||||
})
|
||||
|
||||
it('uses bordered row actions and keeps push independent from containerNo', () => {
|
||||
|
||||
@@ -149,7 +149,18 @@ async function recommend() {
|
||||
if (!plan.value) return
|
||||
mutating.value = true
|
||||
mutationError.value = null
|
||||
try { acceptPlan(await recommendSmartLoading(plan.value.id, plan.value.version)); ElMessage.success('智能建议已生成,请人工核对后再推送') }
|
||||
try {
|
||||
try {
|
||||
acceptPlan(await recommendSmartLoading(plan.value.id, plan.value.version))
|
||||
} catch (error) {
|
||||
const details = getApiErrorDetails(error, '智能推荐失败')
|
||||
if (details.code !== 'A0409' || !/(版本|并发|已被修改|已变化)/.test(details.message)) throw error
|
||||
await load()
|
||||
if (!plan.value) throw error
|
||||
acceptPlan(await recommendSmartLoading(plan.value.id, plan.value.version))
|
||||
}
|
||||
ElMessage.success('智能建议已生成,请人工核对后再推送')
|
||||
}
|
||||
catch (error) { await handleMutationError(error, '智能推荐失败') }
|
||||
finally { mutating.value = false }
|
||||
}
|
||||
@@ -196,7 +207,7 @@ async function handleMutationError(error: unknown, fallback: string, pickingConf
|
||||
const pickingMessage = pickingConflict && details.code === 'A0409' && details.message.includes('拣货')
|
||||
? '该订单在拣货中不许删除'
|
||||
: null
|
||||
mutationError.value = { ...details, message: pickingMessage || (details.code === 'A0409' ? '计划或 PDA 明细已变化,已刷新最新版本并保留本次输入,请重新操作' : details.message) }
|
||||
mutationError.value = { ...details, message: pickingMessage || details.message || (details.code === 'A0409' ? '计划或 PDA 明细已变化,已刷新最新版本并保留本次输入,请重新操作' : details.message) }
|
||||
ElMessage.error(mutationError.value.message)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user