refactor(api): 重构客户信息接口路径并移除悬浮待办组件

将客户通话、聊天和表单信息的接口路径统一调整至sales_timeline下
移除不再使用的FloatingTodo组件及相关导入
添加客户信息获取逻辑至联系人选择流程
This commit is contained in:
2025-08-13 21:25:52 +08:00
parent 8bd8a9145f
commit 9cd3cc7167
2 changed files with 74 additions and 37 deletions

View File

@@ -1,8 +1,5 @@
<template>
<div class="sales-dashboard">
<!-- 悬浮待办组件 -->
<FloatingTodo />
<div class="sales-dashboard">
<!-- 页面加载状态 -->
<Loading :visible="isPageLoading" text="正在加载数据..." />
<!-- 顶部导航栏 -->
@@ -26,6 +23,7 @@
</div>
<UserDropdown />
</div>
<div class="section-content">
<!-- 数据分析区域加载状态 -->
<div v-if="isKpiLoading || isStatisticsLoading || isUrgentProblemLoading" class="section-loading">
@@ -116,7 +114,7 @@ import CustomerDetail from "./components/CustomerDetail.vue";
import PersonalDashboard from "./components/PersonalDashboard.vue";
import SalesTimelineWithTaskList from "./components/SalesTimelineWithTaskList.vue";
import RawDataCards from "./components/RawDataCards.vue";
import FloatingTodo from "./components/FloatingTodo.vue";
// import FloatingTodo from "./components/FloatingTodo.vue";
import UserDropdown from "@/components/UserDropdown.vue";
import Loading from "@/components/Loading.vue";
import {getCustomerAttendance,getTodayCall,getProblemDistribution,getTableFillingRate,getAverageResponseTime,
@@ -194,6 +192,13 @@ const courseCustomers = ref({});
const payMoneyCustomersList = ref([]);
const payMoneyCustomersCount = ref(0);
// 表单信息
const formInfo = ref({});
// 通话记录
const callRecords = ref([]);
// 聊天记录
const chatRecords = ref([]);
// MOCK DATA (Should ideally come from a store or API)
const MOCK_DATA = reactive({
contacts: [
@@ -328,13 +333,10 @@ async function getTimeline() {
if (res.data.all_customers_list) {
customersList.value = res.data.all_customers_list
}
// 处理客户总数
if (res.data.all_customers_count) {
customersCount.value = res.data.all_customers_count
}
}
// 后4个阶段
const classRes = await getCustomerAttendanceAfterClass4(hasParams ? params : undefined)
@@ -420,12 +422,10 @@ async function getTimeline() {
if (payRes.data.pay_money_customers_list) {
payMoneyCustomersList.value = payRes.data.pay_money_customers_list
}
// 处理成交阶段客户总数
if (payRes.data.pay_money_customers_count) {
payMoneyCustomersCount.value = payRes.data.pay_money_customers_count
}
// 成交阶段客户数据已存储在payMoneyCustomersList中不需要合并到customersList
}
} catch (error) {
@@ -440,19 +440,55 @@ async function getCustomerForm() {
console.warn('无法获取客户表单:客户信息不完整');
return;
}
const routeParams = getRequestParams()
const params = {
user_name: routeParams.user_name || userStore.userInfo.username,
customer_name: selectedContact.value.name,
}
try {
const res = await getCustomerFormInfo(params)
if(res.code === 200) {
MOCK_DATA.formFields = res.data
formInfo.value = res.data
}
} catch (error) {
// 静默处理错误
}
}
// 聊天记录
async function getCustomerChat() {
if (!selectedContact.value || !selectedContact.value.name) {
console.warn('无法获取客户聊天记录:客户信息不完整');
return;
}
const routeParams = getRequestParams()
const params = {
user_name: routeParams.user_name || userStore.userInfo.username,
customer_name: selectedContact.value.name,
}
try {
const res = await getCustomerChatInfo(params)
if(res.code === 200) {
chatRecords.value = res.data
}
} catch (error) {
// 静默处理错误
}
}
// 通话记录
async function getCustomerCall() {
if (!selectedContact.value || !selectedContact.value.name) {
console.warn('无法获取客户通话记录:客户信息不完整');
return;
}
const routeParams = getRequestParams()
const params = {
user_name: routeParams.user_name || userStore.userInfo.username,
customer_name: selectedContact.value.name,
}
try {
const res = await getCustomerCallInfo(params)
if(res.code === 200) {
callRecords.value = res.data
}
} catch (error) {
@@ -516,7 +552,6 @@ const filteredContacts = computed(() => {
if (selectedStage.value === '课1-4') {
return [];
}
// 如果有API数据使用API数据
if (formattedCustomersList.value.length > 0) {
if (selectedStage.value === 'all' || selectedStage.value === '全部') {
@@ -535,13 +570,13 @@ const filteredContacts = computed(() => {
// METHODS
const selectContact = (id) => {
selectedContactId.value = id;
// 当选中客户后,获取客户表单数据
nextTick(async () => {
if (selectedContact.value && selectedContact.value.name) {
await getCustomerForm();
await getCustomerChat();
await getCustomerCall();
}
contextPanelRef.value?.scrollIntoView({
behavior: "smooth",
block: "center",
@@ -640,8 +675,13 @@ const handleViewCallData = (contact) => {
onMounted(async () => {
try {
isPageLoading.value = true
await getCoreKpi()
await getCustomerForm()
await getCustomerChat()
await getUrgentProblem()
await getCustomerCall()
await getTimeline()
await getCustomerPayMoney()
// 等待数据加载完成后选择默认客户
await nextTick();