Commit f9aec177 by Lin

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

- 重构了客户详情显示逻辑,采用新的 displayInfo 对象以实现更好的数据管理。
- 更新了计算属性,使其引用 displayInfo 而非 customerInfo,以保持一致性。
- 增强了 submitCustomerProfileAPI 方法,增加了验证和错误处理功能。
- 引入了 syncDisplayInfo 方法,以简化客户数据的同步流程。
- 调整了客户资料提交过程中 inviteDate 的日期处理方式。
1 parent 02b8e1d2
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<view class="user-tag"> <view class="user-tag">
<text class="user-tag-text">{{ customerSurname }}</text> <text class="user-tag-text">{{ customerSurname }}</text>
</view> </view>
<view class="user-name">{{ customerInfo.customerName || '-' }}</view> <view class="user-name">{{ displayInfo.customerName || '-' }}</view>
<view class="active-list flex"> <view class="active-list flex">
<view <view
v-for="(tag, index) in goodsSubOrderList" v-for="(tag, index) in goodsSubOrderList"
...@@ -27,10 +27,10 @@ ...@@ -27,10 +27,10 @@
</view> </view>
</view> </view>
<view <view
v-if="getCustomerStatusLabel(customerInfo.customerStatus)" v-if="getCustomerStatusLabel(displayInfo.customerStatus)"
:class="['customer-item-status', getCustomerStatusClass(customerInfo.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> </view>
</view> </view>
...@@ -275,8 +275,8 @@ ...@@ -275,8 +275,8 @@
}, },
{ {
label: '到店日期', label: '到店日期',
valueKey: 'createdDate', valueKey: 'inviteDate',
key: 'createdDate', key: 'inviteDate',
type: 'date' type: 'date'
}, },
{ {
...@@ -321,7 +321,7 @@ ...@@ -321,7 +321,7 @@
components: { CarBrands, ReceptionSence, Employee }, components: { CarBrands, ReceptionSence, Employee },
computed: { computed: {
customerSurname () { customerSurname () {
const name = this.customerInfo.customerName || '' const name = this.displayInfo.customerName || ''
return name ? name.charAt(0) : '' return name ? name.charAt(0) : ''
}, },
activityTagList () { activityTagList () {
...@@ -329,7 +329,7 @@ ...@@ -329,7 +329,7 @@
return [customerInfo.packageName, customerInfo.activityName].filter(Boolean) return [customerInfo.packageName, customerInfo.activityName].filter(Boolean)
}, },
goodsSubOrderList () { goodsSubOrderList () {
const list = this.customerInfo.goodsSubOrderDTOS const list = this.displayInfo.goodsSubOrderDTOS
if (!Array.isArray(list)) return [] if (!Array.isArray(list)) return []
return list.filter(item => item) return list.filter(item => item)
}, },
...@@ -361,6 +361,11 @@ ...@@ -361,6 +361,11 @@
optionalForm: [], optionalForm: [],
groupForm: [], groupForm: [],
customerInfo: {}, customerInfo: {},
displayInfo: {
customerName: '',
customerStatus: '',
goodsSubOrderDTOS: []
},
groupMemberList: [], groupMemberList: [],
startDate: '', startDate: '',
endDate: '' endDate: ''
...@@ -407,16 +412,79 @@ ...@@ -407,16 +412,79 @@
console.log('getCustomerGroupInfoAPI**customerForm*', this.customerForm) console.log('getCustomerGroupInfoAPI**customerForm*', this.customerForm)
}, },
async submitCustomerProfileAPI() { async submitCustomerProfileAPI() {
// carModel:问界M7, try {
// carModelId: 1149147, this.customerForm.forEach(e => {
// carBrand:AITO 问界, e.error = false
// carBrandId:3454, })
// oneCarBrand:鸿蒙智行, const { customerInfo, customerForm } = this
// oneCarBrandId:2978 customerForm.forEach(e => {
let requestParams = this.customerInfo if (e.required && !customerInfo[e.key]) throw e.key
console.log('submitCustomerProfileAPI***', requestParams) })
const res = await uni.$api.customerApi.submitCustomerProfileAPI(requestParams) 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) 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() { async getCustomerGroupInfo() {
if (!this.customerInfo.customerName || !this.customerInfo.customerPhone) { if (!this.customerInfo.customerName || !this.customerInfo.customerPhone) {
...@@ -441,6 +509,13 @@ ...@@ -441,6 +509,13 @@
console.log('群成员getCustomerGroupMemberInfoAPI***', data) console.log('群成员getCustomerGroupMemberInfoAPI***', data)
this.groupMemberList = Array.isArray(data) ? 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) { getUpgradeStatusType (label) {
if (label === '已升级') return 'success' if (label === '已升级') return 'success'
if (label === '待跟进') return 'warning' if (label === '待跟进') return 'warning'
...@@ -455,6 +530,11 @@ ...@@ -455,6 +530,11 @@
this.customerForm = JSON.parse(JSON.stringify(default_customerForm)) this.customerForm = JSON.parse(JSON.stringify(default_customerForm))
this.optionalForm = JSON.parse(JSON.stringify(default_optionalForm)) this.optionalForm = JSON.parse(JSON.stringify(default_optionalForm))
this.groupForm = JSON.parse(JSON.stringify(default_groupForm)) this.groupForm = JSON.parse(JSON.stringify(default_groupForm))
this.displayInfo = {
customerName: '',
customerStatus: '',
goodsSubOrderDTOS: []
}
this.customerInfo = { this.customerInfo = {
customerName: '', customerName: '',
customerPhone: '', customerPhone: '',
...@@ -484,7 +564,9 @@ ...@@ -484,7 +564,9 @@
}) })
if (res.deliveryDate) res.deliveryDate = dayjs(res.deliveryDate).format("YYYY-MM-DD") 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.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.customerInfo = res
this.syncDisplayInfo(res)
console.log('findVisitsInfo**customerInfo*', this.customerInfo) console.log('findVisitsInfo**customerInfo*', this.customerInfo)
await this.getCustomerGroupInfo() await this.getCustomerGroupInfo()
}, },
...@@ -537,6 +619,10 @@ ...@@ -537,6 +619,10 @@
bindDateChange (e, valueKey) { bindDateChange (e, valueKey) {
this.customerInfo[valueKey] = e.detail.value this.customerInfo[valueKey] = e.detail.value
}, },
formatDateTime (value) {
if (!value) return value
return dayjs(value).format('YYYY-MM-DD HH:mm:ss')
},
async submit () { async submit () {
this.submitCustomerProfileAPI() this.submitCustomerProfileAPI()
try { try {
...@@ -576,6 +662,7 @@ ...@@ -576,6 +662,7 @@
const res = await uni.$api.customerApi[targetApi](params), const res = await uni.$api.customerApi[targetApi](params),
_this = this _this = this
if (res) { if (res) {
this.syncDisplayInfo()
uni.$emit('refreshCustomerProfileGroupInfo') uni.$emit('refreshCustomerProfileGroupInfo')
if (res == '1') { if (res == '1') {
this.$refs.successRef.open() 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!