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}') }}
-
+
@@ -103,6 +103,15 @@
+
+
+
@@ -227,7 +236,13 @@