地址和star需要调整
This commit is contained in:
parent
cf8af5a1af
commit
937a51626f
|
|
@ -58,7 +58,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted } from 'vue';
|
import { ref, onMounted, nextTick } from 'vue';
|
||||||
import { onLoad } from '@dcloudio/uni-app';
|
import { onLoad } from '@dcloudio/uni-app';
|
||||||
import { updateCustomer, getCustomerDetail } from '@/common/api';
|
import { updateCustomer, getCustomerDetail } from '@/common/api';
|
||||||
import { useUserStore } from '@/store/user';
|
import { useUserStore } from '@/store/user';
|
||||||
|
|
@ -143,22 +143,23 @@ const loadCustomerDetail = async () => {
|
||||||
try {
|
try {
|
||||||
const res = await getCustomerDetail(customerId.value);
|
const res = await getCustomerDetail(customerId.value);
|
||||||
if (res) {
|
if (res) {
|
||||||
|
console.log('客户详情数据:', res);
|
||||||
// 将后端数据转换为表单数据格式
|
// 将后端数据转换为表单数据格式
|
||||||
formData.value = {
|
formData.value = {
|
||||||
id: res.id,
|
id: res.id,
|
||||||
customerType: res.type || '',
|
customerType: res.type || '',
|
||||||
name: res.name || '',
|
name: res.name || '',
|
||||||
mobile: res.mobile || '',
|
mobile: res.mobile || '',
|
||||||
wechat: res.wechat || '',
|
wechat: res.wechat ||'',
|
||||||
source: res.source || '',
|
source: res.source || '',
|
||||||
intents: Array.isArray(res.intents) ? res.intents : (res.intents ? res.intents.split(',') : []),
|
intents: Array.isArray(res.intents) ? res.intents : (res.intents ? res.intents.split(',') : []),
|
||||||
intentLevel: res.intentLevel || res.customerIntentLevel || '',
|
intentLevel: res.intentLevel || res.customerIntentLevel || '',
|
||||||
customerStatus: res.customerStatus || res.status || '',
|
customerStatus: res.customerStatus || res.status || '',
|
||||||
region: res.region || '',
|
region: res.region || res.regionName || '',
|
||||||
regionIds: res.regionIds || [],
|
regionIds: (res.regionIds && Array.isArray(res.regionIds) && res.regionIds.length > 0) ? res.regionIds : (res.regionId ? [res.regionId] : []),
|
||||||
workWechat: res.workWechat || '',
|
workWechat: res.wechatId || '',
|
||||||
workWechatId: res.workWechatId || null,
|
workWechatId: res.workWechatId || null,
|
||||||
rating: res.rating || 0,
|
rating: res.intentLevel ||'',
|
||||||
remark: res.remark || '',
|
remark: res.remark || '',
|
||||||
concern: res.concern || '',
|
concern: res.concern || '',
|
||||||
pain: res.pain || '',
|
pain: res.pain || '',
|
||||||
|
|
@ -166,6 +167,12 @@ const loadCustomerDetail = async () => {
|
||||||
demand: res.demand || '',
|
demand: res.demand || '',
|
||||||
nextFollowTime: res.nextFollowTime || ''
|
nextFollowTime: res.nextFollowTime || ''
|
||||||
};
|
};
|
||||||
|
console.log('表单数据:', formData.value);
|
||||||
|
// 数据加载完成后初始化地区数据
|
||||||
|
await nextTick();
|
||||||
|
if (formData.value.regionIds && formData.value.regionIds.length > 0 && pickersRef.value) {
|
||||||
|
handlePickValueDefault(formData.value, pickersRef.value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('加载客户详情失败:', error);
|
console.error('加载客户详情失败:', error);
|
||||||
|
|
@ -178,12 +185,6 @@ const loadCustomerDetail = async () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 加载客户详情后初始化地区数据
|
|
||||||
const initRegionData = () => {
|
|
||||||
if (formData.value.regionIds && formData.value.regionIds.length > 0) {
|
|
||||||
handlePickValueDefault(formData.value, pickersRef.value);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// 打开选择器
|
// 打开选择器
|
||||||
const handleOpenPicker = (pickerType) => {
|
const handleOpenPicker = (pickerType) => {
|
||||||
|
|
@ -264,8 +265,10 @@ onMounted(async () => {
|
||||||
loadDictData(),
|
loadDictData(),
|
||||||
loadWechatList()
|
loadWechatList()
|
||||||
]);
|
]);
|
||||||
// 数据加载完成后初始化地区选择器
|
// 如果客户详情已加载,初始化地区选择器
|
||||||
initRegionData();
|
if (formData.value.regionIds && formData.value.regionIds.length > 0 && pickersRef.value) {
|
||||||
|
handlePickValueDefault(formData.value, pickersRef.value);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 保存
|
// 保存
|
||||||
|
|
@ -312,7 +315,7 @@ const handleSave = async () => {
|
||||||
status: formData.value.customerStatus || null,
|
status: formData.value.customerStatus || null,
|
||||||
intentLevel: formData.value.intentLevel || null,
|
intentLevel: formData.value.intentLevel || null,
|
||||||
mobile: formData.value.mobile.trim(),
|
mobile: formData.value.mobile.trim(),
|
||||||
wechat: formData.value.wechat.trim() || null,
|
wechat: (formData.value.wechat && formData.value.wechat.trim()) ? formData.value.wechat.trim() : null,
|
||||||
source: formData.value.source || null,
|
source: formData.value.source || null,
|
||||||
intents: intentsArray,
|
intents: intentsArray,
|
||||||
followId: userId,
|
followId: userId,
|
||||||
|
|
@ -320,6 +323,7 @@ const handleSave = async () => {
|
||||||
type: formData.value.customerType || '2',
|
type: formData.value.customerType || '2',
|
||||||
workWechatId: formData.value.workWechatId || null,
|
workWechatId: formData.value.workWechatId || null,
|
||||||
regionIds: regionIdsArray,
|
regionIds: regionIdsArray,
|
||||||
|
|
||||||
attention: formData.value.attention.trim() || null,
|
attention: formData.value.attention.trim() || null,
|
||||||
concern: formData.value.concern.trim() || null,
|
concern: formData.value.concern.trim() || null,
|
||||||
demand: formData.value.demand.trim() || null,
|
demand: formData.value.demand.trim() || null,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user