diff --git a/src/modules/trucking/components/TruckAppointmentForm.test.ts b/src/modules/trucking/components/TruckAppointmentForm.test.ts index a7f12c03..6cecd88d 100644 --- a/src/modules/trucking/components/TruckAppointmentForm.test.ts +++ b/src/modules/trucking/components/TruckAppointmentForm.test.ts @@ -43,6 +43,8 @@ describe('TruckAppointmentForm interaction contract', () => { expect(source).toContain('最终资格仍由服务端校验') expect(source).toContain('所选订舱缺少有效的订舱确认文件或提单文件') expect(source).toContain('bookingContainersError') + expect(source).toContain("getApiErrorDetails(cause, '该订舱柜次加载失败,请重试')") + expect(source).toContain('') expect(source).toContain('重新加载选项') expect(source).toContain('重新加载') expect(source).toContain('请选择有效的合作中拖车供应商') diff --git a/src/modules/trucking/components/TruckAppointmentForm.vue b/src/modules/trucking/components/TruckAppointmentForm.vue index 1f724815..0b92e42d 100644 --- a/src/modules/trucking/components/TruckAppointmentForm.vue +++ b/src/modules/trucking/components/TruckAppointmentForm.vue @@ -5,6 +5,8 @@ import { Eye, Save } from '@lucide/vue' import type { SaveTruckAppointmentRequest, TruckAppointmentResource } from '../types' import { listSuppliers, type Supplier } from '@/modules/suppliers' import { getOceanBooking, listOceanBookings, type OceanBookingAllocatedContainer, type OceanBookingDocument, type OceanBookingResource } from '@/modules/ocean-bookings' +import ApiErrorMeta from '@/shared/components/ApiErrorMeta.vue' +import { getApiErrorDetails, type ApiErrorDetails } from '@/shared/api/http' import { isIso6346ContainerNumber } from '../iso6346' const props = defineProps<{ modelValue: SaveTruckAppointmentRequest; resource?: TruckAppointmentResource | null; readonly?: boolean; submitting?: boolean }>() @@ -12,7 +14,7 @@ const emit = defineEmits<{ 'update:modelValue': [SaveTruckAppointmentRequest]; s const formRef = ref() const relationWarning = ref('') const bookingContainersLoading = ref(false) -const bookingContainersError = ref('') +const bookingContainersError = ref(null) const bookingDocuments = ref([]) const defaults: Partial = { expectedVersion: 0, currency: 'RMB', payableAmount: '0.00', receivableAmount: '0.00', packageCount: 0, palletCount: 0, transitMinutes: 0 } function normalizeDraft(value: SaveTruckAppointmentRequest): SaveTruckAppointmentRequest { return { ...defaults, ...value, currency: value.currency?.trim().toUpperCase() || 'RMB' } } @@ -82,7 +84,7 @@ function selectContainer(containerId: string) { } async function loadBookingContainers(bookingId: string) { bookingContainersLoading.value = true - bookingContainersError.value = '' + bookingContainersError.value = null try { const booking = await getOceanBooking(bookingId) if (!bookings.value.some((item) => item.id === booking.id)) bookings.value.push(booking) @@ -92,12 +94,12 @@ async function loadBookingContainers(bookingId: string) { draft.containerBookingId = null draft.loadingPlanId = null } - } catch { + } catch (cause) { containers.value = [] bookingDocuments.value = [] draft.containerBookingId = null draft.loadingPlanId = null - bookingContainersError.value = '该订舱柜次加载失败,请重试' + bookingContainersError.value = getApiErrorDetails(cause, '该订舱柜次加载失败,请重试') } finally { bookingContainersLoading.value = false } @@ -151,7 +153,7 @@ watch(() => props.readonly, (readonly) => { if (!readonly && !bookings.value.len 订舱与柜次(必填) -
{{ bookingContainersError }}重新加载
只有已分配至该订舱且已录入真实 ISO 集装箱号的柜次可以预约拖车。
+
{{ bookingContainersError.message }}重新加载
只有已分配至该订舱且已录入真实 ISO 集装箱号的柜次可以预约拖车。
基本信息