Commit e880ecc8 by Lin

refactor(DetailFiles): 优化客户详情获取逻辑和错误处理

- 增加对 customerId 的有效性检查,确保在获取客户详情前进行验证。
- 添加对 API 返回数据的类型检查,避免潜在的错误。
- 格式化日期字段(deliveryDate, createdDate, inviteDate)为 'YYYY-MM-DD'。
- 优化获取客户群组成员信息的逻辑,增加错误处理和默认值设置。
1 parent 498dd4e0
......@@ -421,15 +421,39 @@ export default {
return map[status] || ''
},
async getCustormDetail() {
console.log('getCustormDetailAPI***', this.customerId)
const res = await uni.$api.customerApi.customerProfileInfoAPI({
id: this.customerId
})
console.log('getCustormDetailAPI***', res)
if(res) {
this.customerForm = res
if (!this.customerId) {
return false
}
try {
const res = await uni.$api.customerApi.customerProfileInfoAPI({
id: this.customerId
})
if (!res || typeof res !== 'object') {
return false
}
if (res.deliveryDate) {
res.deliveryDate = dayjs(res.deliveryDate).format('YYYY-MM-DD')
}
if (res.createdDate) {
res.createdDate = dayjs(res.createdDate).format('YYYY-MM-DD')
}
if (res.inviteDate) {
res.inviteDate = dayjs(res.inviteDate).format('YYYY-MM-DD')
}
Object.assign(this.customerInfo, res)
if (!this.customerInfo.contact_id && res.wxId) {
this.customerInfo.contact_id = res.wxId
}
if (!this.customerInfo.contact_name && res.wxName) {
this.customerInfo.contact_name = res.wxName
}
this.syncDisplayInfo(this.customerInfo)
await this.getCustomerGroupInfo()
return true
} catch (error) {
console.error('getCustormDetail 失败', error)
return false
}
console.log('getCustomerGroupInfoAPI**customerForm*', this.customerForm)
},
async submitCustomerProfileAPI(options = {}) {
const { fromReception = false } = options
......@@ -587,11 +611,22 @@ export default {
}
},
async getCustomerGroupMemberInfoAPI(contactId) {
const data = await uni.$api.customerApi.getCustomerGroupMemberInfoAPI({
qwGroupId: contactId
})
console.log('群成员getCustomerGroupMemberInfoAPI***', data)
this.groupMemberList = Array.isArray(data) ? data : []
const qwGroupId = contactId || this.customerInfo.qwGroupId
if (!qwGroupId) {
this.groupMemberList = []
return false
}
try {
const data = await uni.$api.customerApi.getCustomerGroupMemberInfoAPI({
qwGroupId
})
this.groupMemberList = Array.isArray(data) ? data : []
return this.groupMemberList.length > 0
} catch (error) {
console.error('getCustomerGroupMemberInfoAPI 失败', error)
this.groupMemberList = []
return false
}
},
syncDisplayInfo (info = this.customerInfo) {
this.headerSnapshot = {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!