Commit f9aec177 by Lin

重构(客户页面):更新客户信息处理并优化数据同步

- 重构了客户详情显示逻辑,采用新的 displayInfo 对象以实现更好的数据管理。
- 更新了计算属性,使其引用 displayInfo 而非 customerInfo,以保持一致性。
- 增强了 submitCustomerProfileAPI 方法,增加了验证和错误处理功能。
- 引入了 syncDisplayInfo 方法,以简化客户数据的同步流程。
- 调整了客户资料提交过程中 inviteDate 的日期处理方式。
1 parent 02b8e1d2
......@@ -15,7 +15,7 @@
<view class="user-tag">
<text class="user-tag-text">{{ customerSurname }}</text>
</view>
<view class="user-name">{{ customerInfo.customerName || '-' }}</view>
<view class="user-name">{{ displayInfo.customerName || '-' }}</view>
<view class="active-list flex">
<view
v-for="(tag, index) in goodsSubOrderList"
......@@ -27,10 +27,10 @@
</view>
</view>
<view
v-if="getCustomerStatusLabel(customerInfo.customerStatus)"
:class="['customer-item-status', getCustomerStatusClass(customerInfo.customerStatus)]"
v-if="getCustomerStatusLabel(displayInfo.customerStatus)"
:class="['customer-item-status', getCustomerStatusClass(displayInfo.customerStatus)]"
>
<text class="customer-item-status-text">{{ getCustomerStatusLabel(customerInfo.customerStatus) }}</text>
<text class="customer-item-status-text">{{ getCustomerStatusLabel(displayInfo.customerStatus) }}</text>
</view>
</view>
</view>
......@@ -275,8 +275,8 @@
},
{
label: '到店日期',
valueKey: 'createdDate',
key: 'createdDate',
valueKey: 'inviteDate',
key: 'inviteDate',
type: 'date'
},
{
......@@ -321,7 +321,7 @@
components: { CarBrands, ReceptionSence, Employee },
computed: {
customerSurname () {
const name = this.customerInfo.customerName || ''
const name = this.displayInfo.customerName || ''
return name ? name.charAt(0) : ''
},
activityTagList () {
......@@ -329,7 +329,7 @@
return [customerInfo.packageName, customerInfo.activityName].filter(Boolean)
},
goodsSubOrderList () {
const list = this.customerInfo.goodsSubOrderDTOS
const list = this.displayInfo.goodsSubOrderDTOS
if (!Array.isArray(list)) return []
return list.filter(item => item)
},
......@@ -361,6 +361,11 @@
optionalForm: [],
groupForm: [],
customerInfo: {},
displayInfo: {
customerName: '',
customerStatus: '',
goodsSubOrderDTOS: []
},
groupMemberList: [],
startDate: '',
endDate: ''
......@@ -407,16 +412,79 @@
console.log('getCustomerGroupInfoAPI**customerForm*', this.customerForm)
},
async submitCustomerProfileAPI() {
// carModel:问界M7,
// carModelId: 1149147,
// carBrand:AITO 问界,
// carBrandId:3454,
// oneCarBrand:鸿蒙智行,
// oneCarBrandId:2978
let requestParams = this.customerInfo
console.log('submitCustomerProfileAPI***', requestParams)
const res = await uni.$api.customerApi.submitCustomerProfileAPI(requestParams)
try {
this.customerForm.forEach(e => {
e.error = false
})
const { customerInfo, customerForm } = this
customerForm.forEach(e => {
if (e.required && !customerInfo[e.key]) throw e.key
})
if (!phoneRex.test(customerInfo.customerPhone)) throw 'customerPhone'
} catch (error) {
const index = this.customerForm.findIndex(e => e.key == error)
if (index !== -1) {
this.customerForm[index].error = true
}
return
}
const requestParams = {
id: this.customerInfo.id,
customerName: this.customerInfo.customerName,
carBrand: this.customerInfo.carBrand,
carBrandId: this.customerInfo.carBrandId,
carChildsBrandName: this.customerInfo.carChildsBrandName,
carChildsBrandId: this.customerInfo.carChildsBrandId,
carSeriesName: this.customerInfo.carSeriesName,
carSeriesId: this.customerInfo.carSeriesId,
deliveryDate: this.formatDateTime(this.customerInfo.deliveryDate),
createdDate: this.formatDateTime(this.customerInfo.createdDate),
inviteDate: this.formatDateTime(this.customerInfo.inviteDate),
merchantId: this.customerInfo.merchantId,
merchantName: this.customerInfo.merchantName,
userId: this.customerInfo.userId,
employeeName: this.customerInfo.employeeName,
remark: this.customerInfo.remark,
advanceUserId: this.customerInfo.advanceUserId,
advanceUserName: this.customerInfo.advanceUserName,
qwGroupId: this.customerInfo.qwGroupId,
qwGroupName: this.customerInfo.qwGroupName,
wxId:this.customerInfo.wxId,
wxName:this.customerInfo.wxName,
}
console.log('submitCustomerProfileAPI***',requestParams)
uni.showLoading({
mask: true
})
const res = await uni.$api.customerApi.submitCustomerProfileAPI(requestParams),
_this = this
console.log('submitCustomerProfileAPI***', res)
if (res) {
this.syncDisplayInfo()
uni.$emit('refreshCustomerProfileGroupInfo')
if (res == '1') {
this.$refs.successRef.open()
setTimeout(() => {
uni.hideLoading()
this.backPage()
}, 1e3)
} else {
uni.showModal({
content: '存在与该手机号相同的接待记录,系统将自动归类到已接待',
showCancel: false,
confirmText: '确认',
confirmColor: '#347BFF',
success (res) {
if (res.confirm) {
_this.backPage()
}
}
})
uni.hideLoading()
}
} else {
uni.hideLoading()
}
},
async getCustomerGroupInfo() {
if (!this.customerInfo.customerName || !this.customerInfo.customerPhone) {
......@@ -441,6 +509,13 @@
console.log('群成员getCustomerGroupMemberInfoAPI***', data)
this.groupMemberList = Array.isArray(data) ? data : []
},
syncDisplayInfo (info = this.customerInfo) {
this.displayInfo = {
customerName: info.customerName || '',
customerStatus: info.customerStatus,
goodsSubOrderDTOS: Array.isArray(info.goodsSubOrderDTOS) ? info.goodsSubOrderDTOS : []
}
},
getUpgradeStatusType (label) {
if (label === '已升级') return 'success'
if (label === '待跟进') return 'warning'
......@@ -455,6 +530,11 @@
this.customerForm = JSON.parse(JSON.stringify(default_customerForm))
this.optionalForm = JSON.parse(JSON.stringify(default_optionalForm))
this.groupForm = JSON.parse(JSON.stringify(default_groupForm))
this.displayInfo = {
customerName: '',
customerStatus: '',
goodsSubOrderDTOS: []
}
this.customerInfo = {
customerName: '',
customerPhone: '',
......@@ -484,7 +564,9 @@
})
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")
this.customerInfo = res
this.syncDisplayInfo(res)
console.log('findVisitsInfo**customerInfo*', this.customerInfo)
await this.getCustomerGroupInfo()
},
......@@ -537,6 +619,10 @@
bindDateChange (e, valueKey) {
this.customerInfo[valueKey] = e.detail.value
},
formatDateTime (value) {
if (!value) return value
return dayjs(value).format('YYYY-MM-DD HH:mm:ss')
},
async submit () {
this.submitCustomerProfileAPI()
try {
......@@ -576,6 +662,7 @@
const res = await uni.$api.customerApi[targetApi](params),
_this = this
if (res) {
this.syncDisplayInfo()
uni.$emit('refreshCustomerProfileGroupInfo')
if (res == '1') {
this.$refs.successRef.open()
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!