feat(wmsShippingBill): 增加客户联系人选择及发货单打印功能

- 在发货单编辑页面新增客户联系人下拉选择组件,支持客户变更时加载联系人列表
- 自动带出选中联系人对应的收货人姓名和联系电话
- 调整收货地址输入位置,收货地址可手动修改,默认来源客户详细地址
- 支持编辑模式进入时加载已有客户的联系人列表数据
- 发货日期字段新增,支持日期时间选择
- 列表页操作栏新增打印按钮,支持导出发货单Word文档
- 添加导出发货单Word的接口调用及文件下载逻辑
- 更新接口类型定义,新增客户联系人ID字段支持
dev
zangch@mesnac.com 6 days ago
parent 9a271ef19e
commit 92c1b26432

@ -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;
/**
* 便
*/

@ -97,8 +97,17 @@
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="收货地址" prop="shippingAddress">
<el-input v-model="form.shippingAddress" placeholder="请输入收货地址" />
<el-form-item label="客户联系人" prop="customerContactId">
<el-select
v-model="form.customerContactId"
placeholder="请先选择客户"
filterable
style="width: 100%"
@change="handleCustomerContactChange"
:disabled="!form.customerId"
>
<el-option v-for="item in customerContactList" :key="item.contactId" :label="item.contactName" :value="item.contactId" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
@ -111,6 +120,22 @@
<el-input v-model="form.receiverPhone" placeholder="请输入收货联系电话" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="收货地址" prop="shippingAddress">
<el-input v-model="form.shippingAddress" placeholder="请输入收货地址" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="发货日期" prop="shippingTime">
<el-date-picker
v-model="form.shippingTime"
type="datetime"
value-format="YYYY-MM-DD HH:mm:ss"
placeholder="请选择发货日期"
style="width: 100%"
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="计划到货时间" prop="planArrivalTime">
<el-date-picker
@ -212,6 +237,7 @@
:precision="2"
size="small"
style="width: 100%"
@change="calculateTotalPrice(scope.row)"
:disabled="routeParams.type === 'view' || routeParams.type === 'approval'"
/>
</template>
@ -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<any[]>([]);
const supplierList = ref<any[]>([]);
const warehouseList = ref<any[]>([]);
const customerContactList = ref<CustomerContactVO[]>([]); //
//
const selectedProjectName = ref<string>('');
@ -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);
}

@ -92,7 +92,7 @@
<span>{{ proxy?.parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" fixed="right" width="150" class-name="small-padding fixed-width">
<el-table-column label="操作" align="center" fixed="right" width="180" class-name="small-padding fixed-width">
<template #default="scope">
<el-tooltip content="查看" placement="top">
<el-button link type="primary" icon="View" @click="handleView(scope.row)" v-hasPermi="['wms:wmsShippingBill:query']"></el-button>
@ -103,6 +103,15 @@
<el-tooltip content="删除" placement="top">
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['wms:wmsShippingBill:remove']"></el-button>
</el-tooltip>
<el-tooltip content="打印" placement="top">
<el-button
link
type="primary"
icon="Printer"
@click="handleExportWord(scope.row)"
v-hasPermi="['wms:wmsShippingBill:export']"
></el-button>
</el-tooltip>
</template>
</el-table-column>
</el-table>
@ -227,7 +236,13 @@
</template>
<script setup name="WmsShippingBill" lang="ts">
import { addWmsShippingBill, delWmsShippingBill, listWmsShippingBill, updateWmsShippingBill } from '@/api/wms/wmsShippingBill';
import {
addWmsShippingBill,
delWmsShippingBill,
exportShippingBillWord,
listWmsShippingBill,
updateWmsShippingBill
} from '@/api/wms/wmsShippingBill';
import { WmsShippingBillForm, WmsShippingBillQuery, WmsShippingBillVO } from '@/api/wms/wmsShippingBill/types';
const router = useRouter();
@ -451,6 +466,26 @@ const handleExport = () => {
);
};
/** 导出发货单Word文档 */
const handleExportWord = async (row: WmsShippingBillVO) => {
try {
const res = await exportShippingBillWord(row.shippingBillId);
// Blob
const blob = new Blob([res as any], { type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' });
const url = window.URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
link.download = `发货单_${row.shippingCode || row.shippingBillId}.docx`;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
window.URL.revokeObjectURL(url);
proxy?.$modal.msgSuccess('导出成功');
} catch (error) {
proxy?.$modal.msgError('导出失败,请检查模板配置');
}
};
onMounted(() => {
getList();
});

Loading…
Cancel
Save