From 92c1b26432665d2c270a78f135e8804021009eda Mon Sep 17 00:00:00 2001 From: "zangch@mesnac.com" Date: Thu, 11 Dec 2025 14:34:29 +0800 Subject: [PATCH] =?UTF-8?q?feat(wmsShippingBill):=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=AE=A2=E6=88=B7=E8=81=94=E7=B3=BB=E4=BA=BA=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E5=8F=8A=E5=8F=91=E8=B4=A7=E5=8D=95=E6=89=93=E5=8D=B0=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在发货单编辑页面新增客户联系人下拉选择组件,支持客户变更时加载联系人列表 - 自动带出选中联系人对应的收货人姓名和联系电话 - 调整收货地址输入位置,收货地址可手动修改,默认来源客户详细地址 - 支持编辑模式进入时加载已有客户的联系人列表数据 - 发货日期字段新增,支持日期时间选择 - 列表页操作栏新增打印按钮,支持导出发货单Word文档 - 添加导出发货单Word的接口调用及文件下载逻辑 - 更新接口类型定义,新增客户联系人ID字段支持 --- src/api/wms/wmsShippingBill/types.ts | 10 +++ src/views/wms/wmsShippingBill/edit.vue | 89 ++++++++++++++++++++++--- src/views/wms/wmsShippingBill/index.vue | 39 ++++++++++- 3 files changed, 128 insertions(+), 10 deletions(-) diff --git a/src/api/wms/wmsShippingBill/types.ts b/src/api/wms/wmsShippingBill/types.ts index 988ac08..14e67bf 100644 --- a/src/api/wms/wmsShippingBill/types.ts +++ b/src/api/wms/wmsShippingBill/types.ts @@ -46,6 +46,11 @@ export interface WmsShippingBillVO { */ customerId: string | number; + /** + * 客户联系人ID(逻辑外键) + */ + customerContactId?: string | number; + /** * 客户名称(冗余,方便导出) */ @@ -248,6 +253,11 @@ export interface WmsShippingBillForm extends BaseEntity { */ customerId?: string | number; + /** + * 客户联系人ID(逻辑外键) + */ + customerContactId?: string | number; + /** * 客户名称(冗余,方便导出) */ diff --git a/src/views/wms/wmsShippingBill/edit.vue b/src/views/wms/wmsShippingBill/edit.vue index 2f15e1c..7e08d39 100644 --- a/src/views/wms/wmsShippingBill/edit.vue +++ b/src/views/wms/wmsShippingBill/edit.vue @@ -97,8 +97,17 @@ - - + + + + @@ -111,6 +120,22 @@ + + + + + + + + + + @@ -382,6 +408,8 @@ import { listInventoryDetails } from '@/api/wms/inventoryDetails'; import { InventoryDetailsQuery, InventoryDetailsVO } from '@/api/wms/inventoryDetails/types'; import { getWmsWarehouseInfoList } from '@/api/wms/warehouseInfo'; import { getCrmCustomerInfoList } from '@/api/oa/crm/customerInfo'; +import { getCrmCustomerContactList } from '@/api/oa/crm/customerContact'; +import type { CustomerContactVO } from '@/api/oa/crm/customerContact/types'; import { getCrmSupplierInfoList } from '@/api/oa/crm/crmSupplierInfo'; import { getRuleGenerateCode } from '@/api/system/codeRule'; import SaleMaterialSelect from '@/components/SaleMaterialSelect/index.vue'; @@ -427,6 +455,7 @@ const materialSourceType = ref('2'); const customerList = ref([]); const supplierList = ref([]); const warehouseList = ref([]); +const customerContactList = ref([]); // 客户联系人列表 // 项目选择 const selectedProjectName = ref(''); @@ -477,6 +506,7 @@ const initFormData: WmsShippingBillForm = { projectCode: undefined, projectName: undefined, customerId: undefined, + customerContactId: undefined, customerName: undefined, shippingAddress: undefined, receiverName: undefined, @@ -611,14 +641,47 @@ const projectInfoSelectCallBack = (data: ProjectInfoVO[]) => { } }; -/** 客户选择变化 */ -const handleCustomerChange = (customerId: any) => { - const customer = customerList.value.find((c) => c.customerId === customerId); +/** 客户选择变化 - 加载对应的客户联系人列表 */ +const handleCustomerChange = async (customerId: any) => { + const customer = customerList.value.find((c: any) => c.customerId === customerId); if (customer) { form.value.customerName = customer.customerName; - form.value.shippingAddress = customer.address; - form.value.receiverName = customer.contactPerson; - form.value.receiverPhone = customer.contactPhone; + // 默认使用CRM客户的详细地址作为收货地址,用户仍可在界面上手动修改 + form.value.shippingAddress = customer.detailedAddress; + } + // 清空已选联系人和相关信息 + form.value.customerContactId = undefined; + form.value.receiverName = undefined; + form.value.receiverPhone = undefined; + customerContactList.value = []; + // 加载客户联系人列表 + if (customerId) { + try { + const res = await getCrmCustomerContactList({ customerId }); + customerContactList.value = res.data || []; + // 默认选择首要联系人(firstFlag='1'或1),若无则选择第一个 + let defaultContact = customerContactList.value.find((c: CustomerContactVO) => c.firstFlag === '1' || c.firstFlag === (1 as any)); + if (!defaultContact && customerContactList.value.length > 0) { + defaultContact = customerContactList.value[0]; + } + if (defaultContact) { + form.value.customerContactId = defaultContact.contactId; + // 带出收货联系人信息 + form.value.receiverName = defaultContact.contactName; + form.value.receiverPhone = defaultContact.phoneNumber; + } + } catch (error) { + console.error('加载客户联系人列表失败:', error); + } + } +}; + +/** 客户联系人选择变化 - 自动带出姓名和电话 */ +const handleCustomerContactChange = (contactId: any) => { + const contact = customerContactList.value.find((c: CustomerContactVO) => c.contactId === contactId); + if (contact) { + form.value.receiverName = contact.contactName; + form.value.receiverPhone = contact.phoneNumber; } }; @@ -857,6 +920,16 @@ const loadFormData = async (id: string | number) => { if (form.value.shippingCode) { isCodeGenerated.value = true; } + + // 编辑模式下:如果有客户ID,加载客户联系人列表 + if (form.value.customerId) { + try { + const contactRes = await getCrmCustomerContactList({ customerId: form.value.customerId }); + customerContactList.value = contactRes.data || []; + } catch (error) { + console.error('加载客户联系人列表失败:', error); + } + } } catch (error) { console.error('加载表单数据失败:', error); } diff --git a/src/views/wms/wmsShippingBill/index.vue b/src/views/wms/wmsShippingBill/index.vue index 32535b7..38747b7 100644 --- a/src/views/wms/wmsShippingBill/index.vue +++ b/src/views/wms/wmsShippingBill/index.vue @@ -92,7 +92,7 @@ {{ proxy?.parseTime(scope.row.createTime, '{y}-{m}-{d}') }} - + @@ -227,7 +236,13 @@