Commit e880ecc8 by Lin

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

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