fix(ContactModal): 完善通讯录提交逻辑并添加错误处理
添加对空选择的验证,实现异步获取用户信息并过滤无效数据 处理提交过程中的错误情况,提供用户友好的错误提示
This commit is contained in:
parent
1946ef8e9c
commit
6fc34c13b8
@ -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(() => {
|
||||
|
Loading…
Reference in New Issue
Block a user