Skip to content

Commit 762b51a

Browse files
committed
fix: [CRM-客户统计]根据Code-Review 修改
1 parent d0501ee commit 762b51a

File tree

9 files changed

+490
-335
lines changed

9 files changed

+490
-335
lines changed

src/api/crm/statistics/customer.ts

Lines changed: 86 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,116 @@
11
import request from '@/config/axios'
22

3-
export interface StatisticsCustomerRespVO {
4-
count: number
5-
cycle: number
6-
category: string
3+
export interface CrmStatisticsCustomerSummaryByDateRespVO {
4+
time: string
5+
customerCreateCount: number
6+
customerDealCount: number
77
}
88

9-
// 客户总量分析 API
9+
export interface CrmStatisticsCustomerSummaryByUserRespVO {
10+
ownerUserName: string
11+
customerCreateCount: number
12+
customerDealCount: number
13+
contractPrice: number
14+
receivablePrice: number
15+
}
16+
17+
export interface CrmStatisticsFollowupSummaryByDateRespVO {
18+
time: string
19+
followupRecordCount: number
20+
followupCustomerCount: number
21+
}
22+
23+
export interface CrmStatisticsFollowupSummaryByUserRespVO {
24+
ownerUserName: string
25+
followupRecordCount: number
26+
followupCustomerCount: number
27+
}
28+
29+
export interface CrmStatisticsFollowupSummaryByTypeRespVO {
30+
followupType: string
31+
followupRecordCount: number
32+
}
33+
34+
export interface CrmStatisticsCustomerContractSummaryRespVO {
35+
customerName: string
36+
contractName: string
37+
totalPrice: number
38+
receivablePrice: number
39+
customerType: string
40+
customerSource: string
41+
ownerUserName: string
42+
creatorUserName: string
43+
createTime: Date
44+
orderDate: Date
45+
}
46+
47+
export interface CrmStatisticsCustomerDealCycleByDateRespVO {
48+
time: string
49+
customerDealCycle: number
50+
}
51+
52+
export interface CrmStatisticsCustomerDealCycleByUserRespVO {
53+
ownerUserName: string
54+
customerDealCycle: number
55+
customerDealCount: number
56+
}
57+
58+
// 客户分析 API
1059
export const StatisticsCustomerApi = {
11-
// 客户总量(新建)
12-
getTotalCustomerCount: (params: any) => {
60+
// 1.1 客户总量分析(按日期)
61+
getCustomerSummaryByDate: (params: any) => {
62+
return request.get({
63+
url: '/crm/statistics-customer/get-customer-summary-by-date',
64+
params
65+
})
66+
},
67+
// 1.2 客户总量分析(按用户)
68+
getCustomerSummaryByUser: (params: any) => {
1369
return request.get({
14-
url: '/crm/statistics-customer/get-total-customer-count',
70+
url: '/crm/statistics-customer/get-customer-summary-by-user',
1571
params
1672
})
1773
},
18-
// 客户总量(成交)
19-
getDealTotalCustomerCount: (params: any) => {
74+
// 2.1 客户跟进次数分析(按日期)
75+
getFollowupSummaryByDate: (params: any) => {
2076
return request.get({
21-
url: '/crm/statistics-customer/get-deal-total-customer-count',
77+
url: '/crm/statistics-customer/get-followup-summary-by-date',
2278
params
2379
})
2480
},
25-
// 获取客户跟进次数
26-
getRecordCount: (params: any) => {
81+
// 2.2 客户跟进次数分析(按用户)
82+
getFollowupSummaryByUser: (params: any) => {
2783
return request.get({
28-
url: '/crm/statistics-customer/get-record-count',
84+
url: '/crm/statistics-customer/get-followup-summary-by-user',
2985
params
3086
})
3187
},
32-
// 获取客户跟进次数
33-
getDistinctRecordCount: (params: any) => {
88+
// 3.1 获取客户跟进方式统计数
89+
getFollowupSummaryByType: (params: any) => {
3490
return request.get({
35-
url: '/crm/statistics-customer/get-distinct-record-count',
91+
url: '/crm/statistics-customer/get-followup-summary-by-type',
3692
params
3793
})
3894
},
39-
// 获取客户跟进方式统计数
40-
getRecordTypeCount: (params: any) => {
95+
// 4.1 合同摘要信息(客户转化率页面)
96+
getContractSummary: (params: any) => {
4197
return request.get({
42-
url: '/crm/statistics-customer/get-record-type-count',
98+
url: '/crm/statistics-customer/get-followup-summary-by-type',
4399
params
44100
})
45101
},
46-
// 获取客户成交周期
47-
getCustomerCycle: (params: any) => {
102+
// 5.1 获取客户成交周期(按日期)
103+
getCustomerDealCycleByDate: (params: any) => {
48104
return request.get({
49-
url: '/crm/statistics-customer/get-customer-cycle',
105+
url: '/crm/statistics-customer/get-customer-deal-cycle-by-date',
50106
params
51107
})
52108
},
109+
// 5.2 获取客户成交周期(按用户)
110+
getCustomerDealCycleByUser: (params: any) => {
111+
return request.get({
112+
url: '/crm/statistics-customer/get-customer-deal-cycle-by-user',
113+
params
114+
})
115+
}
53116
}

src/views/crm/statistics/customer/components/ConversionRate.vue

Lines changed: 0 additions & 112 deletions
This file was deleted.
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
<!-- 客户转化率分析 -->
2+
<template>
3+
<!-- Echarts图 -->
4+
<el-card shadow="never">
5+
<el-skeleton :loading="loading" animated>
6+
<Echart :height="500" :options="echartsOption" />
7+
</el-skeleton>
8+
</el-card>
9+
10+
<!-- 统计列表 -->
11+
<el-card shadow="never" class="mt-16px">
12+
<el-table v-loading="loading" :data="list">
13+
<el-table-column label="序号" align="center" type="index" width="80" />
14+
<el-table-column label="客户名称" align="center" prop="customerName" min-width="200" />
15+
<el-table-column label="合同名称" align="center" prop="contractName" min-width="200" />
16+
<el-table-column label="合同总金额" align="center" prop="totalPrice" min-width="200" />
17+
<el-table-column label="回款金额" align="center" prop="receivablePrice" min-width="200" />
18+
<el-table-column label="负责人" align="center" prop="ownerUserName" min-width="200" />
19+
<el-table-column label="创建人" align="center" prop="creatorUserName" min-width="200" />
20+
<el-table-column
21+
label="创建时间"
22+
align="center"
23+
prop="createTime"
24+
:formatter="dateFormatter"
25+
min-width="200"
26+
/>
27+
<el-table-column
28+
label="下单日期"
29+
align="center"
30+
prop="orderDate"
31+
:formatter="dateFormatter2"
32+
min-width="200"
33+
/>
34+
</el-table>
35+
</el-card>
36+
</template>
37+
<script setup lang="ts">
38+
import {
39+
StatisticsCustomerApi,
40+
CrmStatisticsCustomerSummaryByDateRespVO
41+
} from '@/api/crm/statistics/customer'
42+
import { EChartsOption } from 'echarts'
43+
import { round } from 'lodash-es'
44+
import { dateFormatter, dateFormatter2 } from '@/utils/formatTime'
45+
46+
defineOptions({ name: 'CustomerConversionStat' })
47+
const props = defineProps<{ queryParams: any }>() // 搜索参数
48+
49+
const loading = ref(false) // 加载中
50+
const list = ref<CrmStatisticsCustomerSummaryByDateRespVO[]>([]) // 列表的数据
51+
52+
/** 柱状图配置:纵向 */
53+
const echartsOption = reactive<EChartsOption>({
54+
grid: {
55+
left: 20,
56+
right: 20,
57+
bottom: 20,
58+
containLabel: true
59+
},
60+
legend: {},
61+
series: [
62+
{
63+
name: '客户转化率',
64+
type: 'line',
65+
data: []
66+
}
67+
],
68+
toolbox: {
69+
feature: {
70+
dataZoom: {
71+
xAxisIndex: false // 数据区域缩放:Y 轴不缩放
72+
},
73+
brush: {
74+
type: ['lineX', 'clear'] // 区域缩放按钮、还原按钮
75+
},
76+
saveAsImage: { show: true, name: '客户转化率分析' } // 保存为图片
77+
}
78+
},
79+
tooltip: {
80+
trigger: 'axis',
81+
axisPointer: {
82+
type: 'shadow'
83+
}
84+
},
85+
yAxis: {
86+
type: 'value',
87+
name: '转化率(%)'
88+
},
89+
xAxis: {
90+
type: 'category',
91+
name: '日期',
92+
data: []
93+
}
94+
}) as EChartsOption
95+
96+
/** 获取统计数据 */
97+
const loadData = async () => {
98+
// 1. 加载统计数据
99+
loading.value = true
100+
const customerCount = await StatisticsCustomerApi.getCustomerSummaryByDate(props.queryParams)
101+
const contractSummary = await StatisticsCustomerApi.getContractSummary(props.queryParams)
102+
// 2.1 更新 Echarts 数据
103+
if (echartsOption.xAxis && echartsOption.xAxis['data']) {
104+
echartsOption.xAxis['data'] = customerCount.map(
105+
(s: CrmStatisticsCustomerSummaryByDateRespVO) => s.time
106+
)
107+
}
108+
if (echartsOption.series && echartsOption.series[0] && echartsOption.series[0]['data']) {
109+
echartsOption.series[0]['data'] = customerCount.map(
110+
(item: CrmStatisticsCustomerSummaryByDateRespVO) => {
111+
return {
112+
name: item.time,
113+
value: item.customerCreateCount
114+
? round((item.customerDealCount / item.customerCreateCount) * 100, 2)
115+
: 0
116+
}
117+
}
118+
)
119+
}
120+
// 2.2 更新列表数据
121+
list.value = contractSummary
122+
loading.value = false
123+
}
124+
defineExpose({ loadData })
125+
126+
/** 初始化 */
127+
onMounted(() => {
128+
loadData()
129+
})
130+
</script>

0 commit comments

Comments
 (0)