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(() => {