fix(admin): resolve preload detail lifecycle
This commit is contained in:
@@ -7,7 +7,7 @@ import ApiErrorMeta from '@/shared/components/ApiErrorMeta.vue'
|
||||
import OperationErrorToast from '@/shared/components/OperationErrorToast.vue'
|
||||
import AppDialog from '@/shared/components/AppDialog.vue'
|
||||
import LoadErrorState from '@/shared/components/LoadErrorState.vue'
|
||||
import { getApiErrorDetails, type ApiErrorDetails } from '@/shared/api/http'
|
||||
import { getApiErrorDetails, http, unwrapApiResponse, type ApiEnvelope, type ApiErrorDetails } from '@/shared/api/http'
|
||||
import { useAccessPreviewStore } from '@/core/access/accessPreview'
|
||||
import LoadingListDetailDrawer from '../components/LoadingListDetailDrawer.vue'
|
||||
import { confirmPreloadPlan, getPreloadPlan, updateLoadingItemWarehouseRemark, updatePreloadTransport, type LoadingDetail, type LoadingItem, type PreloadSummary } from '../api/platformLoadingLists'
|
||||
@@ -36,6 +36,15 @@ const remarkOperationId = ref('')
|
||||
let loadSequence = 0
|
||||
const planId = computed(() => String(route.params.planId || ''))
|
||||
const warehouseId = computed(() => typeof route.query.warehouseId === 'string' ? route.query.warehouseId : '')
|
||||
type LoadingPlanLifecycle = { planId: string | number; planStatus: string; detailResource: 'PRELOAD' | 'LOADING_LIST' }
|
||||
|
||||
async function resolveLoadingPlanLifecycle() {
|
||||
const response = await http.get<ApiEnvelope<LoadingPlanLifecycle>, ApiEnvelope<LoadingPlanLifecycle>>(
|
||||
`/platform/v1/first-leg/loading-plans/${encodeURIComponent(planId.value)}/lifecycle`,
|
||||
{ params: { warehouseId: warehouseId.value } },
|
||||
)
|
||||
return unwrapApiResponse(response)
|
||||
}
|
||||
const canEdit = computed(() => access.can('platform:firstleg:preload:edit'))
|
||||
const canCorrectTransport = computed(() => {
|
||||
const summary = detail.value?.summary
|
||||
@@ -76,6 +85,21 @@ async function loadDetail() {
|
||||
loading.value = true
|
||||
error.value = null
|
||||
try {
|
||||
const lifecycle = await resolveLoadingPlanLifecycle()
|
||||
if (sequence !== loadSequence) return
|
||||
if (lifecycle.detailResource === 'LOADING_LIST') {
|
||||
if (lifecycle.planStatus !== 'COMPLETED') {
|
||||
error.value = { code: 'MODE_STATUS_MISMATCH', message: '装柜计划阶段异常,暂时无法切换详情,请稍后重试。' }
|
||||
return
|
||||
}
|
||||
await router.replace({ name: 'loading-list-detail', params: { planId: planId.value }, query: { warehouseId: warehouseId.value } })
|
||||
if (sequence === loadSequence) ElMessage.success('装柜已完成,已切换至装柜清单详情')
|
||||
return
|
||||
}
|
||||
if (lifecycle.detailResource !== 'PRELOAD') {
|
||||
error.value = { code: 'MODE_STATUS_MISMATCH', message: '无法识别当前装柜计划阶段,请稍后重试。' }
|
||||
return
|
||||
}
|
||||
const result = await getPreloadPlan(planId.value, warehouseId.value)
|
||||
if (sequence !== loadSequence) return
|
||||
if (!['EDITING', 'LOADING'].includes(result.summary.status)) {
|
||||
|
||||
Reference in New Issue
Block a user