From e85482ac73865b37566165362e182c8020f7747b Mon Sep 17 00:00:00 2001 From: yinq Date: Tue, 12 May 2026 18:09:26 +0800 Subject: [PATCH] =?UTF-8?q?1.1.34=20=E7=A4=BC=E5=93=81=E7=94=B3=E8=AF=B7?= =?UTF-8?q?=E5=AE=A2=E6=88=B7=E5=90=8D=E7=A7=B0=E6=94=B9=E4=B8=BA=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E8=BE=93=E5=85=A5=E7=9A=84=E6=96=87=E5=AD=97=EF=BC=8C?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=B8=A6=E5=87=BA=E9=83=A8=E9=97=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/oa/crm/crmGiftApply/types.ts | 10 ++++ src/components/GiftSelect/index.vue | 14 ++--- src/views/oa/crm/crmGiftApply/edit.vue | 76 ++++++++++++++++++------- src/views/oa/crm/crmGiftApply/index.vue | 31 +++++----- 4 files changed, 87 insertions(+), 44 deletions(-) diff --git a/src/api/oa/crm/crmGiftApply/types.ts b/src/api/oa/crm/crmGiftApply/types.ts index 5e7130d..cb7a648 100644 --- a/src/api/oa/crm/crmGiftApply/types.ts +++ b/src/api/oa/crm/crmGiftApply/types.ts @@ -96,6 +96,16 @@ export interface CrmGiftApplyVO { */ remark: string; + /** + * 创建时间 + */ + createTime?: string; + + /** + * 更新时间 + */ + updateTime?: string; + /** * 礼品申请明细列表 */ diff --git a/src/components/GiftSelect/index.vue b/src/components/GiftSelect/index.vue index 8ae8168..f2885b6 100644 --- a/src/components/GiftSelect/index.vue +++ b/src/components/GiftSelect/index.vue @@ -53,19 +53,19 @@ @checkbox-all="handleCheckboxAll" @checkbox-change="handleCheckboxChange" > - - - - - + + + + + - + - + - - - - + + @@ -82,8 +88,8 @@ - - + + - - + + - - + + - + - + - + @@ -266,7 +273,7 @@ const rules = reactive({ applicationCode: [], // 编号由后端自动生成,前端不需要校验 applicationDate: [{ required: true, message: '申请日期不能为空', trigger: 'change' }], applicantId: [{ required: true, message: '申请人不能为空', trigger: 'blur' }], - customerUnitId: [{ required: true, message: '客户不能为空', trigger: 'change' }] + customerUnitName: [{ required: true, message: '客户名称不能为空', trigger: ['blur', 'change'] }] // 'variables.approverId': [ // { // validator: (rule: any, value: any, callback: any) => { @@ -341,7 +348,7 @@ const initUserInfo = async () => { form.value.applicantId = user.userId; form.value.applicantName = user.nickName; form.value.applicantDeptId = user.deptId; - form.value.applicantDeptName = user.dept?.deptName; + form.value.applicantDeptName = user.deptName; // 默认领用人为申请人 form.value.recipientId = user.userId; form.value.recipientName = user.nickName; @@ -371,12 +378,38 @@ const handleApproverSelectChange = (approverId: number | string) => { } }; -/** 客户选择变更 */ -const handleCustomerChange = (customerId: number | string) => { - const customer = customerList.value.find((c) => c.customerId === customerId); - if (customer) { - form.value.customerUnitName = customer.customerName; +/** 根据客户名称与档案列表同步 customerUnitId(手填无匹配则清空关联 ID) */ +const syncCustomerUnitIdFromName = () => { + const name = form.value.customerUnitName?.trim(); + if (!name) { + form.value.customerUnitId = undefined; + return; } + const matched = customerList.value.find((c) => c.customerName?.trim() === name); + form.value.customerUnitId = matched?.customerId; +}; + +type CustomerNameSuggest = { value: string; customerId: string | number }; + +/** 客户名称联想(档案客户,可点选) */ +const queryCustomerSuggestions = (queryString: string, cb: (rows: CustomerNameSuggest[]) => void) => { + const q = (queryString || '').trim().toLowerCase(); + const rows = customerList.value + .filter((c) => c.customerName) + .filter((c) => !q || String(c.customerName).toLowerCase().includes(q)) + .map((c) => ({ value: c.customerName!, customerId: c.customerId })); + cb(rows); +}; + +/** 从联想列表选中时写入档案客户 ID */ +const handleCustomerSuggestSelect = (item: CustomerNameSuggest) => { + form.value.customerUnitName = item.value; + form.value.customerUnitId = item.customerId; +}; + +/** 失焦保留手输内容并同步关联客户 ID */ +const onCustomerNameBlur = () => { + syncCustomerUnitIdFromName(); }; /** 礼品选择回填 */ @@ -450,6 +483,7 @@ const handleDeleteDetail = (index: number) => { const submitForm = async (status: string) => { try { await formRef.value?.validate(); + syncCustomerUnitIdFromName(); // P0-1: 校验业务状态 - 只有草稿状态才能修改 if (form.value.giftApplyId && form.value.applicationStatus !== '1') { diff --git a/src/views/oa/crm/crmGiftApply/index.vue b/src/views/oa/crm/crmGiftApply/index.vue index 1a0cc12..0b02fda 100644 --- a/src/views/oa/crm/crmGiftApply/index.vue +++ b/src/views/oa/crm/crmGiftApply/index.vue @@ -41,24 +41,24 @@ - - - - - + + + + + - - - - + + + + - + @@ -68,12 +68,12 @@ --> - + - +