diff --git a/AGENTS.md b/AGENTS.md index d1fe214c..33cb9591 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -58,9 +58,9 @@ | 财务账户、账单、收款与成本 | `modules/finance/` | `finance/`;费用来源与柜次成本快照联查 `firstleg/`,凭证联查 `file/` | | 货柜与智能排柜 | `modules/container-loading/` | `firstleg/loading/`、`firstleg/split/` | | 预装详情、装柜清单与柜次费用 | `modules/loading-lists/pages/PreloadPlanDetailView.vue`、`modules/loading-lists/components/LoadingListDetailDrawer.vue`、`modules/loading-lists/components/ContainerFeesPanel.vue`、`modules/loading-lists/api/containerFees.ts` | `firstleg/loading/`、`firstleg` 柜次费用、`finance/` 成本分摊、`file/`、`warehouse/` | -| 海运订舱与船期 | `modules/ocean-bookings/`、`modules/port-schedules/` | `firstleg/oceanbooking/`、`firstleg/portschedule/`、`integration-service/` | -| 拖车预约 | `modules/trucking/` | `firstleg/outbound/dispatch/`、`firstleg/` | -| 报关协同 | `modules/customs/` | `firstleg/customs/`、`file/` | +| 海运订舱与船期 | `modules/ocean-bookings/`、`modules/port-schedules/` | `firstleg/oceanbooking/`、`firstleg/portschedule/`、`integration-service/`;订舱代理联查 `modules/suppliers/` 与 `warehouse/src/main/resources/openapi/supplier-v1.yaml`,服务端契约见 `firstleg/src/main/resources/openapi/ocean-bookings-v1.yaml` | +| 拖车预约 | `modules/trucking/` | `firstleg/outbound/dispatch/`、`firstleg/`;承运商联查 `modules/suppliers/` 与 `warehouse/src/main/resources/openapi/supplier-v1.yaml`,服务端契约见 `firstleg/src/main/resources/openapi/truck-appointments-v1.yaml` | +| 报关协同 | `modules/customs/` | `firstleg/customs/`、`file/`;报关代理联查 `modules/suppliers/` 与 `warehouse/src/main/resources/openapi/supplier-v1.yaml`,服务端契约见 `firstleg/src/main/resources/openapi/customs-v1.yaml` | | 国内出仓确认 | `modules/outbound-dispatch/` | `firstleg/outbound/dispatch/` | | 主数据与下载 | `modules/master-data/`、`modules/downloads/` | `warehouse/`、`file/` | @@ -87,6 +87,7 @@ - 供应商菜单、列表和详情固定只使用 `platform:supplier:list`,`platform:supplier:view` 必须停用/移除。修改 `modules/suppliers/`、`core/navigation/adminNavigation.ts` 或根路由时,不得恢复或兼容 `platform:supplier:view`。 - `core/navigation/adminNavigation.ts`、`app/router/index.ts` 和模块 `routes.ts` 属于共享装配文件;并行业务任务不得用局部模块结论覆盖菜单与权限总控已经确认的权限语义,发现重叠改动时保留并回传总控处理。 - 认证统一经过 `src/core/auth/auth.ts` 和 `src/shared/api/http.ts`;不要在页面中复制令牌读写或手工拼装 `Authorization`。 +- 订舱代理、拖车承运商和报关代理必须提交服务端契约要求的供应商 ID,并从公共供应商列表选择 `ACTIVE` 且类别/范围匹配的记录;名称只作为展示或一致性提示,不得把名称输入当作 ID 的替代。修改这些请求参数时,必须同步检查 API 封装、类型、表单、详情展示、Mock/Fixture、契约测试和 Firstleg/Warehouse OpenAPI,不能只改页面或只改后端。 - 当前登录和部分数据仍可能是模拟实现。接入 `baiyue-firstleg` Gateway 真实接口时删除对应模拟路径,不允许让生产逻辑静默回退到假数据。 - 删除、停用、改权限等高风险操作必须有明确确认、处理中、成功和失败反馈;失败时保留用户上下文,避免误以为已生效。 - 日志、提示和示例数据不得包含真实账号、令牌、客户隐私或生产数据。 diff --git a/src/modules/customs/api/platformCustoms.ts b/src/modules/customs/api/platformCustoms.ts index 9061af92..636ede16 100644 --- a/src/modules/customs/api/platformCustoms.ts +++ b/src/modules/customs/api/platformCustoms.ts @@ -1,5 +1,5 @@ import { http, unwrapApiResponse, type ApiEnvelope } from '@/shared/api/http' -import type { CustomsCaseCreateRequest, CustomsCaseDetail, CustomsCasePage, CustomsCaseQuery, CustomsCaseResource } from '../types' +import type { CustomsCaseCreateRequest, CustomsCaseDetail, CustomsCasePage, CustomsCaseQuery, CustomsCaseResource, CustomsSubmitBatchRequest } from '../types' const basePath = '/platform/v1/customs' const keys = ['id', 'tenantId', 'orderId', 'inboundId', 'containerBookingId', 'checklistVersionId'] as const function item(raw: CustomsCaseResource) { const value = { ...raw } as CustomsCaseResource & Record; for (const key of keys) if (value[key] != null) value[key] = String(value[key]); value.version = Number(value.version ?? 0); return value } @@ -8,4 +8,4 @@ function idem() { return `customs-${Date.now()}-${Math.random().toString(36).sli export async function listCustomsCases(query: CustomsCaseQuery) { const response = await http.get, ApiEnvelope>(`${basePath}/cases`, { params: query }); const data = unwrapApiResponse(response); return { ...data, records: (data.records || []).map(item), page: Number(data.page), size: Number(data.size), total: Number(data.total), pages: Number(data.pages) } } export async function getCustomsCase(id: string) { const response = await http.get, ApiEnvelope>(`${basePath}/cases/${encodeURIComponent(id)}`); return detail(unwrapApiResponse(response)) } export async function createCustomsCase(request: CustomsCaseCreateRequest) { const response = await http.post, ApiEnvelope>(`${basePath}/cases`, request, { headers: { 'Idempotency-Key': idem() } }); return detail(unwrapApiResponse(response)) } -export async function submitCustomsCase(id: string, request: { customsAgentName: string; externalReference?: string; note?: string; expectedVersion: number }) { const response = await http.post, ApiEnvelope>(`${basePath}/cases/${encodeURIComponent(id)}/submission-batches`, request, { headers: { 'Idempotency-Key': idem() } }); return unwrapApiResponse(response) } +export async function submitCustomsCase(id: string, request: CustomsSubmitBatchRequest) { const response = await http.post, ApiEnvelope>(`${basePath}/cases/${encodeURIComponent(id)}/submission-batches`, request, { headers: { 'Idempotency-Key': idem() } }); return unwrapApiResponse(response) } diff --git a/src/modules/customs/pages/CustomsCasesView.vue b/src/modules/customs/pages/CustomsCasesView.vue index 8389437e..40cfb006 100644 --- a/src/modules/customs/pages/CustomsCasesView.vue +++ b/src/modules/customs/pages/CustomsCasesView.vue @@ -14,11 +14,13 @@ import { customsCaseStatusOptions, customsHistoryActionLabel, customsStatusLabel import { getApiErrorDetails, type ApiErrorDetails } from '@/shared/api/http' import { useAccessPreviewStore } from '@/core/access/accessPreview' import { listPlatformTenants, type PlatformTenantResource } from '@/modules/iam' +import { listSuppliers, type Supplier } from '@/modules/suppliers' import { getCustomsCase, listCustomsCases, submitCustomsCase } from '../api/platformCustoms' import type { CustomsCaseDetail, CustomsCaseResource } from '../types' const access = useAccessPreviewStore(); const rows = ref([]); const loading = ref(false); const error = ref(null); const page = ref(1); const pageSize = ref(20); const total = ref(0) const customers = ref([]); const customersLoading = ref(false) +const customsAgents = ref([]); const customsAgentsLoading = ref(false); const customsAgentsError = ref('') const filters = ref({ customerId: '', status: '' }); const fields = computed(() => [ { key: 'customerId', type: 'select', label: '客户', placeholder: '全部客户', width: 220, options: customers.value.filter((customer) => customer.status === 'ACTIVE').map((customer) => ({ label: customer.tenantName, value: String(customer.id) })), props: { filterable: true, loading: customersLoading.value } }, { key: 'status', type: 'select', label: '状态', options: customsCaseStatusOptions.map((option) => ({ ...option })) }, @@ -26,13 +28,15 @@ const filters = ref({ customerId: '', status: '' }); const fields = const columns = [{ key: 'actions', label: '操作', fixed: 'left', width: 175, slotName: 'actions', hideable: false, movable: false }, { prop: 'customsNo', label: '报关编号', minWidth: 145 }, { key: 'orderLink', label: '订单关联', minWidth: 120, formatter: (row: CustomsCaseResource) => associationLabel(row.orderId) }, { key: 'inboundLink', label: '入库单关联', minWidth: 120, formatter: (row: CustomsCaseResource) => associationLabel(row.inboundId) }, { prop: 'checklistCode', label: '资料清单', minWidth: 125 }, { prop: 'checklistVersionNo', label: '版本', width: 90 }, { prop: 'status', label: '状态', width: 110, slotName: 'status' }, { prop: 'updatedAt', label: '更新时间', minWidth: 160 }] function associationLabel(value: string | null | undefined) { return value ? '已关联' : '未关联' } async function loadCustomers() { customersLoading.value = true; try { const result = await listPlatformTenants({ page: 1, size: 200, status: 'ACTIVE' }); customers.value = result.records.filter((customer) => customer.status === 'ACTIVE') } catch { customers.value = [] } finally { customersLoading.value = false } } +async function loadCustomsAgents() { customsAgentsLoading.value = true; customsAgentsError.value = ''; try { const result = await listSuppliers({ page: 1, size: 200, category: 'CUSTOMS', status: 'ACTIVE' }); customsAgents.value = result.records.filter((supplier) => supplier.category === 'CUSTOMS' && supplier.status === 'ACTIVE') } catch (cause) { customsAgents.value = []; customsAgentsError.value = getApiErrorDetails(cause, '报关代理加载失败').message } finally { customsAgentsLoading.value = false } } async function load() { loading.value = true; error.value = null; try { const result = await listCustomsCases({ page: page.value, size: pageSize.value, customerId: String(filters.value.customerId || '') || undefined, status: String(filters.value.status || '') || undefined }); rows.value = result.records; total.value = result.total } catch (cause) { error.value = getApiErrorDetails(cause) } finally { loading.value = false } } function search() { if (page.value === 1) void load(); else page.value = 1 } -const detailOpen = ref(false); const detail = ref(null); const detailLoading = ref(false); const actionError = ref(null); const submitForm = reactive({ customsAgentName: '', externalReference: '', note: '' }); const canSubmit = computed(() => detail.value?.customsCase.status === 'READY_TO_SUBMIT' && access.can('platform:firstleg:customs:submit')) -async function openDetail(id: string) { detailOpen.value = true; detailLoading.value = true; actionError.value = null; try { detail.value = await getCustomsCase(id) } catch (cause) { actionError.value = getApiErrorDetails(cause) } finally { detailLoading.value = false } } -async function submit() { if (!detail.value || !submitForm.customsAgentName.trim()) return; actionError.value = null; try { await submitCustomsCase(detail.value.customsCase.id, { ...submitForm, expectedVersion: detail.value.customsCase.version }); ElMessage.success('已登记线下提交批次'); detail.value = await getCustomsCase(detail.value.customsCase.id) } catch (cause) { actionError.value = getApiErrorDetails(cause); if (actionError.value.code === 'A0409') detail.value = await getCustomsCase(detail.value.customsCase.id) } } -watch([page, pageSize], () => void load()); onMounted(() => { void load(); void loadCustomers() }) +const detailOpen = ref(false); const detail = ref(null); const detailLoading = ref(false); const actionError = ref(null); const submitForm = reactive({ customsAgentId: '', customsAgentName: '', externalReference: '', note: '' }); const canSubmit = computed(() => detail.value?.customsCase.status === 'READY_TO_SUBMIT' && access.can('platform:firstleg:customs:submit')) +function selectCustomsAgent(supplierId: string) { const supplier = customsAgents.value.find((item) => item.id === supplierId); submitForm.customsAgentId = supplier?.id || ''; submitForm.customsAgentName = supplier?.name || '' } +async function openDetail(id: string) { detailOpen.value = true; detailLoading.value = true; actionError.value = null; selectCustomsAgent(''); try { detail.value = await getCustomsCase(id) } catch (cause) { actionError.value = getApiErrorDetails(cause) } finally { detailLoading.value = false } } +async function submit() { if (!detail.value || !submitForm.customsAgentId || !customsAgents.value.some((item) => item.id === submitForm.customsAgentId)) { actionError.value = { message: '请选择有效的合作中报关供应商' }; return } actionError.value = null; try { await submitCustomsCase(detail.value.customsCase.id, { ...submitForm, expectedVersion: detail.value.customsCase.version }); ElMessage.success('已登记线下提交批次'); detail.value = await getCustomsCase(detail.value.customsCase.id) } catch (cause) { actionError.value = getApiErrorDetails(cause); if (actionError.value.code === 'A0409') detail.value = await getCustomsCase(detail.value.customsCase.id) } } +watch([page, pageSize], () => void load()); onMounted(() => { void load(); void loadCustomers(); void loadCustomsAgents() }) + diff --git a/src/modules/customs/types.ts b/src/modules/customs/types.ts index 3692c9c4..4de27a46 100644 --- a/src/modules/customs/types.ts +++ b/src/modules/customs/types.ts @@ -2,6 +2,7 @@ export interface CustomsCaseResource { id: string; customsNo: string; tenantId?: export interface CustomsDocumentResource { id: string; itemCode: string; fileName?: string | null; status?: string | null; version?: number } export interface CustomsHistoryResource { id: string; action: string; fromStatus?: string | null; toStatus?: string | null; note?: string | null; operatorName?: string | null; createdAt: string } export interface CustomsCaseDetail { customsCase: CustomsCaseResource; documents: CustomsDocumentResource[]; supplements: unknown[]; submissionBatches: Array<{ id: string; customsAgentName?: string; status?: string; createdAt?: string }>; receipts: Array<{ id: string; receiptType?: string; status?: string; createdAt?: string }>; history: CustomsHistoryResource[] } +export interface CustomsSubmitBatchRequest { customsAgentId: string; customsAgentName: string; externalReference?: string; note?: string; expectedVersion: number } export interface CustomsCasePage { records: CustomsCaseResource[]; page: number; size: number; total: number; pages: number } export interface CustomsCaseQuery { page: number; size: number; customerId?: string; orderId?: string; inboundId?: string; containerBookingId?: string; status?: string } export interface CustomsCaseCreateRequest { customerId: string; orderId: string; inboundId: string; containerBookingId?: string | null; checklistVersionId: string; remark?: string | null; expectedVersion: number } diff --git a/src/modules/finance/pages/FinanceFormalSettlementPage.vue b/src/modules/finance/pages/FinanceFormalSettlementPage.vue index 1a122afb..25765cd1 100644 --- a/src/modules/finance/pages/FinanceFormalSettlementPage.vue +++ b/src/modules/finance/pages/FinanceFormalSettlementPage.vue @@ -4,7 +4,7 @@ import { ElMessage, ElMessageBox, type UploadFile } from 'element-plus' import { ArrowLeft, CreditCard, Download, Eye, HandCoins, Plus, RotateCcw, XCircle } from '@lucide/vue' import { useAccessPreviewStore } from '@/core/access/accessPreview' import { listPlatformTenants, type PlatformTenantResource } from '@/modules/iam' -import { listPlatformPartners, type PlatformPartnerResource } from '@/modules/master-data' +import { categoryLabels, listSuppliers, type Supplier } from '@/modules/suppliers' import { getApiErrorDetails, type ApiErrorDetails } from '@/shared/api/http' import AdminPage from '@/shared/components/AdminPage.vue' import ApiErrorMeta from '@/shared/components/ApiErrorMeta.vue' @@ -54,7 +54,7 @@ const createOpen = ref(false) const createBusy = ref(false) const statementOptions = ref([]) const feeOptions = ref([]) -const supplierOptions = ref([]) +const supplierOptions = ref([]) const createForm = ref({ reconciliationStatementId: '', supplierId: '', feeSourceIds: [] as string[], dueDate: '' }) const paymentOpen = ref(false) const paymentBusy = ref(false) @@ -208,10 +208,10 @@ async function openCreate() { } else { const [fees, suppliers] = await Promise.all([ listFinanceFeePool(customerId, 'PAYABLE'), - listPlatformPartners({ page: 1, size: 200, status: 'ACTIVE' }), + listSuppliers({ page: 1, size: 200, status: 'ACTIVE' }), ]) feeOptions.value = fees.filter((item) => item.feeSourceId && item.status === 'AVAILABLE') - supplierOptions.value = suppliers.records + supplierOptions.value = suppliers.records.filter((item) => item.status === 'ACTIVE') } } catch (cause) { error.value = getApiErrorDetails(cause, '结算来源加载失败') } } @@ -489,7 +489,7 @@ onMounted(() => { - + diff --git a/src/modules/finance/pages/FinanceG3G4Views.test.ts b/src/modules/finance/pages/FinanceG3G4Views.test.ts index 97c88bee..95b7dd3e 100644 --- a/src/modules/finance/pages/FinanceG3G4Views.test.ts +++ b/src/modules/finance/pages/FinanceG3G4Views.test.ts @@ -5,7 +5,7 @@ import { afterAll, afterEach, beforeEach, describe, expect, it, vi } from 'vites import { useAccessPreviewStore } from '@/core/access/accessPreview' import { useAuthStore } from '@/core/auth/auth' import { listPlatformTenants, type PlatformTenantResource } from '@/modules/iam' -import { listPlatformPartners, type PlatformPartnerResource } from '@/modules/master-data' +import { listSuppliers, type Supplier } from '@/modules/suppliers' import { ApiResponseError } from '@/shared/api/http' import { actionReconciliationStatement, @@ -25,7 +25,10 @@ import FinanceCustomerStatementsView from './FinanceCustomerStatementsView.vue' import FinanceFormalSettlementPage from './FinanceFormalSettlementPage.vue' vi.mock('@/modules/iam', () => ({ listPlatformTenants: vi.fn() })) -vi.mock('@/modules/master-data', () => ({ listPlatformPartners: vi.fn() })) +vi.mock('@/modules/suppliers', () => ({ + listSuppliers: vi.fn(), + categoryLabels: { BOOKING: '订舱', CUSTOMS: '报关', TRUCKING: '拖车', CERTIFICATE: '证书' }, +})) vi.mock('../api/finance', () => ({ actionReconciliationStatement: vi.fn(), createFinanceSettlementPayment: vi.fn(), createPayableSettlement: vi.fn(), createReceivableSettlement: vi.fn(), getFinanceSettlement: vi.fn(), getReconciliationStatement: vi.fn(), @@ -70,7 +73,7 @@ describe('Finance G3/G4 views', () => { document.body.innerHTML = '' const customer = { id: '10001', tenantName: '客户A', status: 'ACTIVE' } as PlatformTenantResource vi.mocked(listPlatformTenants).mockReset().mockResolvedValue({ records: [customer], page: 1, size: 200, total: 1, pages: 1 }) - vi.mocked(listPlatformPartners).mockReset().mockResolvedValue({ records: [{ id: '301', tenantId: '0', dataScopeId: '0', partnerCode: 'PARTNER-301', partnerName: '往来单位A', partnerType: 'CUSTOMER', types: ['CUSTOMER'], contactName: '', contactPhone: '', contactEmail: null, countryCode: 'CN', province: null, city: '', district: null, addressLine: '', postalCode: null, status: 'ACTIVE', remark: null } as PlatformPartnerResource], page: 1, size: 200, total: 1, pages: 1 }) + vi.mocked(listSuppliers).mockReset().mockResolvedValue({ records: [{ id: '301', tenantId: '0', name: '拖车供应商A', category: 'TRUCKING', scope: 'DOMESTIC', region: '宁波', legalRepresentative: '', contactName: '', phone: '', email: null, address: null, businessLicenseNo: null, licenseFileId: null, status: 'ACTIVE', settlementPeriod: 'MONTHLY_30', remark: null, createdBy: null, createdAt: '2026-08-01', updatedBy: null, updatedAt: '2026-08-01', deleted: false, version: 0 } as Supplier], page: 1, size: 200, total: 1, pages: 1 }) vi.mocked(listFinanceStatements).mockReset().mockResolvedValue([statement]) vi.mocked(getReconciliationStatement).mockReset().mockResolvedValue(statementDetail) vi.mocked(actionReconciliationStatement).mockReset().mockResolvedValue(statementDetail) @@ -106,8 +109,8 @@ describe('Finance G3/G4 views', () => { const wrapper = await mountWithAccess(FinanceFormalSettlementPage, ['platform:finance:settlement-ap:list', 'platform:finance:settlement-ap:create', 'platform:finance:payment:create'], { kind: 'payable' }) const vm = wrapper.vm as unknown as { load(model: Record): Promise; openCreate(): Promise; submitCreate(): Promise; openPayment(row: FinancePayableSettlement): void; submitPayment(): Promise; createForm: { supplierId: string; dueDate: string; feeSourceIds: string[] }; paymentFile: File | null; paymentForm: { amount: number; transactionDate: string; method: 'BANK_TRANSFER'; referenceNo: string; remark: string } } await vm.load({ customerId: '10001' }); await vm.openCreate() - expect(listPlatformPartners).toHaveBeenCalledWith({ page: 1, size: 200, status: 'ACTIVE' }) - expect(document.body.textContent).toContain('往来单位A · PARTNER-301') + expect(listSuppliers).toHaveBeenCalledWith({ page: 1, size: 200, status: 'ACTIVE' }) + expect(document.body.textContent).toContain('拖车供应商A · 拖车') Object.assign(vm.createForm, { supplierId: '301', dueDate: '2026-09-30', feeSourceIds: ['81'] }) await vm.submitCreate() expect(createPayableSettlement).toHaveBeenCalledWith({ customerId: '10001', supplierId: '301', feeSourceIds: ['81'], dueDate: '2026-09-30', currency: 'CNY' }) diff --git a/src/modules/suppliers/index.ts b/src/modules/suppliers/index.ts new file mode 100644 index 00000000..846c5946 --- /dev/null +++ b/src/modules/suppliers/index.ts @@ -0,0 +1,3 @@ +export { listSuppliers } from './api/platformSuppliers' +export { categoryLabels } from './types' +export type { Supplier, SupplierPage, SupplierQuery, SupplierCategory } from './types' diff --git a/src/modules/trucking/components/TruckAppointmentForm.test.ts b/src/modules/trucking/components/TruckAppointmentForm.test.ts index 1ba7ed5b..1d3398bb 100644 --- a/src/modules/trucking/components/TruckAppointmentForm.test.ts +++ b/src/modules/trucking/components/TruckAppointmentForm.test.ts @@ -7,19 +7,22 @@ const source = readFileSync(resolve(process.cwd(), 'src/modules/trucking/compone describe('TruckAppointmentForm interaction contract', () => { it('uses searchable business selectors for shared resources', () => { expect(source).toContain('listPlatformTenants') - expect(source).toContain('listPlatformPartners') + expect(source).toContain('listSuppliers') expect(source).toContain('listContainers') expect(source).toContain('listOceanBookings') expect(source).toContain('listAllPlatformWarehouses') expect(source).not.toContain('label="承运商 ID"') expect(source).not.toContain('label="客户关联 ID"') expect(source).toContain("listPlatformTenants({ page: 1, size: 200, status: 'ACTIVE' })") + expect(source).toContain("listSuppliers({ page: 1, size: 200, category: 'TRUCKING', status: 'ACTIVE' })") expect(source).toContain('function customerLabel(customer: PlatformTenantResource) { return customer.tenantName }') expect(source).not.toContain('customer.tenantCode') }) it('synchronizes ids and names and recovers failed option loading', () => { expect(source).toContain('selectCarrier') + expect(source).toContain("item.category === 'TRUCKING' && item.status === 'ACTIVE'") + expect(source).toContain('请选择有效的合作中拖车供应商') expect(source).toContain('draft.carrierName') expect(source).toContain('selectCustomer') expect(source).toContain('draft.customerName') @@ -29,7 +32,7 @@ describe('TruckAppointmentForm interaction contract', () => { }) it('hides inactive options while preserving resources already bound to an appointment', () => { - expect(source).toContain("item.status === 'ACTIVE' || String(item.id) === String(draft.customerId)") + expect(source).toContain("item.status === 'ACTIVE'") expect(source).toContain("item.status === 'ACTIVE' || String(item.id) === String(draft.warehouseId)") expect(source).toContain('v-for="item in selectableCustomers"') expect(source).toContain('v-for="item in selectableWarehouses"') diff --git a/src/modules/trucking/components/TruckAppointmentForm.vue b/src/modules/trucking/components/TruckAppointmentForm.vue index f25b2765..d7f175f3 100644 --- a/src/modules/trucking/components/TruckAppointmentForm.vue +++ b/src/modules/trucking/components/TruckAppointmentForm.vue @@ -4,7 +4,7 @@ import type { FormInstance, FormRules } from 'element-plus' import { Eye, Save } from '@lucide/vue' import type { SaveTruckAppointmentRequest, TruckAppointmentResource } from '../types' import { listPlatformTenants, type PlatformTenantResource } from '@/modules/iam' -import { listPlatformPartners, type PlatformPartnerResource } from '@/modules/master-data' +import { listSuppliers, type Supplier } from '@/modules/suppliers' import { listContainers, type ContainerBookingResource } from '@/modules/container-loading' import { listOceanBookings, type OceanBookingResource } from '@/modules/ocean-bookings' import { listAllPlatformWarehouses, type PlatformWarehouseSummaryResource } from '@/modules/warehouses' @@ -27,7 +27,7 @@ const phoneRule = (label: string) => ({ validator: (_rule: unknown, value: unkno else callback(new Error(`${label}格式不正确`)) }, trigger: 'blur' }) const rules: FormRules = { - carrierId: [{ required: true, message: '请选择承运商', trigger: 'change' }], + carrierId: [{ required: true, message: '请选择承运商', trigger: 'change' }, { validator: (_rule, value, callback) => callback(selectableCarriers.value.some((item) => String(item.id) === String(value)) ? undefined : new Error('请选择有效的合作中拖车供应商')), trigger: 'change' }], plannedLoadingAt: [{ required: true, message: '请选择预计装箱时间', trigger: 'change' }], fleetPhone: [phoneRule('车队电话')], driverPhone: [phoneRule('司机电话')], storePhone: [phoneRule('门店电话')], packageCount: [nonNegative('件数', true)], palletCount: [nonNegative('托盘数量', true)], transitMinutes: [nonNegative('在途分钟', true)], @@ -36,7 +36,7 @@ const rules: FormRules = { } const relationText = computed(() => [props.resource?.customerName, props.resource?.outboundOrderId, props.resource?.containerBookingId].filter(Boolean).join(' / ') || '由服务端关联资源返回') const customers = ref([]) -const carriers = ref([]) +const carriers = ref([]) const containers = ref([]) const bookings = ref([]) const warehouses = ref([]) @@ -49,24 +49,24 @@ const selectableWarehouses = computed(() => warehouses.value.filter((item) => ( item.status === 'ACTIVE' || String(item.id) === String(draft.warehouseId) ))) const selectableCarriers = computed(() => carriers.value.filter((item) => ( - item.status === 'ACTIVE' || String(item.id) === String(draft.carrierId) + item.status === 'ACTIVE' ))) function customerLabel(customer: PlatformTenantResource) { return customer.tenantName } function selectCustomer(customerId: string) { const customer = customers.value.find((item) => String(item.id) === customerId); draft.customerId = customerId || null; draft.customerName = customer ? customerLabel(customer) : null } -function selectCarrier(carrierId: string) { draft.carrierId = carrierId || null; draft.carrierName = carriers.value.find((item) => String(item.id) === carrierId)?.partnerName || null } +function selectCarrier(carrierId: string) { const carrier = selectableCarriers.value.find((item) => String(item.id) === carrierId); draft.carrierId = carrier?.id || null; draft.carrierName = carrier?.name || null } function selectContainer(containerId: string) { const item = containers.value.find((entry) => entry.id === containerId); draft.containerBookingId = containerId || null; if (item) { draft.loadingPlanId = item.planId; draft.warehouseId = item.warehouseId } } function selectBooking(bookingId: string) { const item = bookings.value.find((entry) => entry.id === bookingId); draft.oceanBookingId = bookingId || null; if (item?.customerId) selectCustomer(item.customerId) } async function loadOptions() { optionsLoading.value = true; optionsError.value = '' const results = await Promise.allSettled([ listPlatformTenants({ page: 1, size: 200, status: 'ACTIVE' }), - listPlatformPartners({ page: 1, size: 200, type: 'CARRIER', status: 'ACTIVE' }), + listSuppliers({ page: 1, size: 200, category: 'TRUCKING', status: 'ACTIVE' }), listContainers({ page: 1, size: 200 }), listOceanBookings({ page: 1, size: 200 }), listAllPlatformWarehouses(), ]) if (results[0].status === 'fulfilled') customers.value = results[0].value.records.filter((customer) => customer.status === 'ACTIVE') - if (results[1].status === 'fulfilled') carriers.value = results[1].value.records + if (results[1].status === 'fulfilled') carriers.value = results[1].value.records.filter((item) => item.category === 'TRUCKING' && item.status === 'ACTIVE') if (results[2].status === 'fulfilled') containers.value = results[2].value.records if (results[3].status === 'fulfilled') bookings.value = results[3].value.records if (results[4].status === 'fulfilled') warehouses.value = results[4].value @@ -93,7 +93,7 @@ watch(() => props.readonly, (readonly) => { if (!readonly && !customers.value.le 运输与时间计划 - +