From 6fc34c13b88000b14b47bdb6a5c5e908e702c5fd Mon Sep 17 00:00:00 2001 From: xingyy Date: Wed, 27 Aug 2025 16:02:51 +0800 Subject: [PATCH] =?UTF-8?q?fix(ContactModal):=20=E5=AE=8C=E5=96=84?= =?UTF-8?q?=E9=80=9A=E8=AE=AF=E5=BD=95=E6=8F=90=E4=BA=A4=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E5=B9=B6=E6=B7=BB=E5=8A=A0=E9=94=99=E8=AF=AF=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加对空选择的验证,实现异步获取用户信息并过滤无效数据 处理提交过程中的错误情况,提供用户友好的错误提示 --- src/components/user/ContactModal.vue | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/components/user/ContactModal.vue b/src/components/user/ContactModal.vue index 55f510a..fced95a 100644 --- a/src/components/user/ContactModal.vue +++ b/src/components/user/ContactModal.vue @@ -378,9 +378,31 @@ const onAddressBookCancel = () => { state.isShowAddressBookModal = false } -const onAddressBookSubmit = () => { - // 用户可自行实现提交逻辑 - console.log('选中的联系人:', state.selectedRowKeys) +const onAddressBookSubmit = async () => { + if (!Array.isArray(state.selectedRowKeys) || state.selectedRowKeys.length === 0) { + processError('请选择联系人') + return + } + + try { + const results = await Promise.all( + state.selectedRowKeys.map((erpId) => getUserInfoByERPUserId({ erp_user_id: erpId })) + ) + + const data = results + .filter((res) => res && res.code === 200 && res.data && res.data.sys_id) + .map((res) => ({ receiver_id: res.data.sys_id, talk_type: 1 })) + + if (data.length === 0) { + processError('未获取到有效联系人') + return + } + + emit('on-submit', data) + state.isShowAddressBookModal = false + } catch (e) { + processError('发送失败,请稍后重试') + } } watch(() => {