diff --git a/src/modules/ocean-bookings/pages/OceanBookingDetailView.test.ts b/src/modules/ocean-bookings/pages/OceanBookingDetailView.test.ts index 076e8416..2b1f8f7e 100644 --- a/src/modules/ocean-bookings/pages/OceanBookingDetailView.test.ts +++ b/src/modules/ocean-bookings/pages/OceanBookingDetailView.test.ts @@ -29,8 +29,11 @@ describe('OceanBookingDetailView interaction contract', () => { expect(source).not.toContain("customerId: [{ required: true") expect(source).toContain('placeholder="请选择船公司"') expect(source).toContain('placeholder="请选择订舱代理"') - expect(source).toContain("selectPartner('shippingCompany'") - expect(source).toContain("selectPartner('bookingAgent'") + expect(source).toContain('listSuppliers({ page: 1, size: 200, category: \'BOOKING\', status: \'ACTIVE\' })') + expect(source).toContain('selectShippingCompany') + expect(source).toContain('selectBookingAgent') + expect(source).toContain('bookingAgentLabel') + expect(source).toContain('暂无启用的订舱供应商') expect(source).not.toContain('label="客户 ID"') expect(source).not.toContain('label="船公司 ID"') expect(source).not.toContain('label="订舱代理 ID"') @@ -49,6 +52,7 @@ describe('OceanBookingDetailView interaction contract', () => { expect(source).toContain("form.data.shippingCompanyName || '船公司名称缺失'") expect(source).toContain("form.data.bookingAgentName || '订舱代理名称缺失'") expect(source).toContain("from '@/modules/master-data'") + expect(source).toContain("from '@/modules/suppliers/api/platformSuppliers'") }) it('renders the translated status once in the detail heading', () => { diff --git a/src/modules/ocean-bookings/pages/OceanBookingDetailView.vue b/src/modules/ocean-bookings/pages/OceanBookingDetailView.vue index 5afbc040..b1e29153 100644 --- a/src/modules/ocean-bookings/pages/OceanBookingDetailView.vue +++ b/src/modules/ocean-bookings/pages/OceanBookingDetailView.vue @@ -14,6 +14,8 @@ import DetailPageLayout from '@/shared/components/DetailPageLayout.vue' import PageToolbar from '@/shared/components/PageToolbar.vue' import { listPlatformTenants, type PlatformTenantResource } from '@/modules/iam' import { listPlatformPartners, type PlatformPartnerResource } from '@/modules/master-data' +import { listSuppliers } from '@/modules/suppliers/api/platformSuppliers' +import type { Supplier } from '@/modules/suppliers/types' import { listPlatformWarehouses, type PlatformWarehouseResource } from '@/modules/warehouses' import { createOceanBooking, @@ -73,6 +75,7 @@ const actionError = ref | null>(null) const formRef = ref() const customers = ref([]) const partners = ref([]) +const bookingSuppliers = ref([]) const warehouses = ref([]) const optionsLoading = ref(false) const optionsError = ref('') @@ -85,7 +88,9 @@ const selectableCustomers = computed(() => customers.value.filter((customer) => customer.status === 'ACTIVE' || String(customer.id) === String(form.data.customerId) ))) const shippingCompanies = computed(() => partners.value.filter((partner) => partner.types.includes('CARRIER'))) -const bookingAgents = computed(() => partners.value.filter((partner) => partner.types.some((type) => ['SUPPLIER', 'CUSTOMS_BROKER'].includes(type)))) +const selectableBookingAgents = computed(() => bookingSuppliers.value.filter((supplier) => ( + supplier.status === 'ACTIVE' || String(supplier.id) === String(form.data.bookingAgentId) +))) const channelUnavailable = computed(() => Boolean(form.data.warehouseId) && !channelsLoading.value && !channelsError.value && channels.value.length === 0) function blankParties(): OceanBookingParty[] { @@ -127,16 +132,18 @@ async function loadOptions() { optionsLoading.value = true optionsError.value = '' try { - const [customerResult, partnerResult, warehouseResult] = await Promise.all([ + const [customerResult, partnerResult, supplierResult, warehouseResult] = await Promise.all([ listPlatformTenants({ page: 1, size: 200, status: 'ACTIVE' }), listPlatformPartners({ page: 1, size: 200, status: 'ACTIVE' }), + listSuppliers({ page: 1, size: 200, category: 'BOOKING', status: 'ACTIVE' }), listPlatformWarehouses({ page: 1, size: 200, warehouseType: 'DOMESTIC', status: 'ACTIVE' }), ]) customers.value = customerResult.records.filter((customer) => customer.status === 'ACTIVE') partners.value = partnerResult.records + bookingSuppliers.value = supplierResult.records warehouses.value = warehouseResult.records.filter((warehouse) => warehouse.status === 'ACTIVE' && warehouse.warehouseType === 'DOMESTIC') } catch (cause) { - optionsError.value = getApiErrorDetails(cause, '客户及合作单位选项加载失败').message + optionsError.value = getApiErrorDetails(cause, '客户、船公司或订舱代理选项加载失败').message } finally { optionsLoading.value = false } @@ -184,15 +191,18 @@ function selectChannel(channelCode: string) { form.data.channelCode = channelCode selectedChannelName.value = channel?.channelName || '' } -function selectPartner(kind: 'shippingCompany' | 'bookingAgent', partnerId: string) { +function selectShippingCompany(partnerId: string) { const partner = partners.value.find((item) => String(item.id) === partnerId) - if (kind === 'shippingCompany') { - form.data.shippingCompanyId = partnerId || null - form.data.shippingCompanyName = partner?.partnerName || null - } else { - form.data.bookingAgentId = partnerId || null - form.data.bookingAgentName = partner?.partnerName || null - } + form.data.shippingCompanyId = partnerId || null + form.data.shippingCompanyName = partner?.partnerName || null +} +function selectBookingAgent(supplierId: string) { + const supplier = bookingSuppliers.value.find((item) => String(item.id) === supplierId) + form.data.bookingAgentId = supplierId || null + form.data.bookingAgentName = supplier?.name || null +} +function bookingAgentLabel(supplier: Supplier) { + return `${supplier.name}(${supplier.scope === 'INTERNATIONAL' ? '国外' : '国内'})` } function applyDetail(value: OceanBookingDetail) { detail.value = value @@ -371,8 +381,8 @@ onMounted(() => { void load(); void loadOptions() }) {{ channel.channelName }}{{ channel.channelCode }}
{{ channelsError }}重新加载
该仓库暂无有效物流渠道,请更换仓库或联系管理员。
- - + +