Skip to content

Commit cce1fad

Browse files
author
puhui999
committed
CRM: 新增客户行业、来源、级别统计、区域数据统计
1 parent 6b45ed7 commit cce1fad

File tree

7 files changed

+785
-20
lines changed

7 files changed

+785
-20
lines changed

src/api/crm/statistics/customer.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,36 @@ export interface CrmStatisticsCustomerDealCycleByDateRespVO {
4949
customerDealCycle: number
5050
}
5151

52+
export interface CrmStatisticCustomerBaseRespVO {
53+
customerCount: number
54+
dealCount: number
55+
dealPortion: number
56+
}
57+
58+
export interface CrmStatisticCustomerIndustryRespVO extends CrmStatisticCustomerBaseRespVO {
59+
industryId: number
60+
industryName: string
61+
industryPortion: number
62+
}
63+
64+
export interface CrmStatisticCustomerSourceRespVO extends CrmStatisticCustomerBaseRespVO {
65+
source: number
66+
sourceName: string
67+
sourcePortion: number
68+
}
69+
70+
export interface CrmStatisticCustomerLevelRespVO extends CrmStatisticCustomerBaseRespVO {
71+
level: number
72+
levelName: string
73+
levelPortion: number
74+
}
75+
76+
export interface CrmStatisticCustomerAreaRespVO extends CrmStatisticCustomerBaseRespVO {
77+
areaId: number
78+
areaName: string
79+
areaPortion: number
80+
}
81+
5282
export interface CrmStatisticsCustomerDealCycleByUserRespVO {
5383
ownerUserName: string
5484
customerDealCycle: number
@@ -112,5 +142,33 @@ export const StatisticsCustomerApi = {
112142
url: '/crm/statistics-customer/get-customer-deal-cycle-by-user',
113143
params
114144
})
145+
},
146+
// 6.1 获取客户行业统计数据
147+
getCustomerIndustry: (params: any) => {
148+
return request.get({
149+
url: '/crm/statistics-customer/get-customer-industry-summary',
150+
params
151+
})
152+
},
153+
// 6.1 获取客户来源统计数据
154+
getCustomerSource: (params: any) => {
155+
return request.get({
156+
url: '/crm/statistics-customer/get-customer-source-summary',
157+
params
158+
})
159+
},
160+
// 6.1 获取客户行业统计数据
161+
getCustomerLevel: (params: any) => {
162+
return request.get({
163+
url: '/crm/statistics-customer/get-customer-level-summary',
164+
params
165+
})
166+
},
167+
// 6.1 获取客户行业统计数据
168+
getCustomerArea: (params: any) => {
169+
return request.get({
170+
url: '/crm/statistics-customer/get-customer-area-summary',
171+
params
172+
})
115173
}
116174
}

src/api/mall/statistics/member.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { formatDate } from '@/utils/formatTime'
55

66
/** 会员分析 Request VO */
77
export interface MemberAnalyseReqVO {
8-
times: [dayjs.ConfigType, dayjs.ConfigType]
8+
times: dayjs.ConfigType[]
99
}
1010

1111
/** 会员分析 Response VO */
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
<!-- 客户城市分布 -->
2+
<template>
3+
<!-- Echarts图 -->
4+
<el-card shadow="never">
5+
<el-row :gutter="20">
6+
<el-col :span="12">
7+
<el-skeleton :loading="loading" animated>
8+
<Echart :height="500" :options="echartsOption" />
9+
</el-skeleton>
10+
</el-col>
11+
<el-col :span="12">
12+
<el-skeleton :loading="loading" animated>
13+
<Echart :height="500" :options="echartsOption2" />
14+
</el-skeleton>
15+
</el-col>
16+
</el-row>
17+
</el-card>
18+
</template>
19+
<script lang="ts" setup>
20+
import { EChartsOption } from 'echarts'
21+
import china from '@/assets/map/json/china.json'
22+
import echarts from '@/plugins/echarts'
23+
import {
24+
CrmStatisticCustomerAreaRespVO,
25+
StatisticsCustomerApi
26+
} from '@/api/crm/statistics/customer'
27+
28+
defineOptions({ name: 'CustomerAddress' })
29+
const props = defineProps<{ queryParams: any }>() // 搜索参数
30+
31+
// 注册地图
32+
echarts?.registerMap('china', china as any)
33+
34+
const loading = ref(false) // 加载中
35+
const areaStatisticsList = ref<CrmStatisticCustomerAreaRespVO[]>([]) // 列表的数据
36+
37+
/** 地图配置 */
38+
const echartsOption = reactive<EChartsOption>({
39+
title: {
40+
text: '全部客户',
41+
left: 'center'
42+
},
43+
tooltip: {
44+
trigger: 'item',
45+
showDelay: 0,
46+
transitionDuration: 0.2
47+
},
48+
visualMap: {
49+
text: ['', ''],
50+
realtime: false,
51+
calculable: true,
52+
top: 'middle',
53+
inRange: {
54+
color: ['#fff', '#3b82f6']
55+
}
56+
},
57+
series: [
58+
{
59+
name: '客户地域分布',
60+
type: 'map',
61+
map: 'china',
62+
roam: false,
63+
selectedMode: false,
64+
data: []
65+
}
66+
]
67+
}) as EChartsOption
68+
69+
/** 地图配置 */
70+
const echartsOption2 = reactive<EChartsOption>({
71+
title: {
72+
text: '成交客户',
73+
left: 'center'
74+
},
75+
tooltip: {
76+
trigger: 'item',
77+
showDelay: 0,
78+
transitionDuration: 0.2
79+
},
80+
visualMap: {
81+
text: ['', ''],
82+
realtime: false,
83+
calculable: true,
84+
top: 'middle',
85+
inRange: {
86+
color: ['#fff', '#3b82f6']
87+
}
88+
},
89+
series: [
90+
{
91+
name: '客户地域分布',
92+
type: 'map',
93+
map: 'china',
94+
roam: false,
95+
selectedMode: false,
96+
data: []
97+
}
98+
]
99+
}) as EChartsOption
100+
101+
/** 获取统计数据 */
102+
const loadData = async () => {
103+
// 1. 加载统计数据
104+
loading.value = true
105+
const areaList = await StatisticsCustomerApi.getCustomerArea(props.queryParams)
106+
areaStatisticsList.value = areaList.map((item: CrmStatisticCustomerAreaRespVO) => {
107+
return {
108+
...item,
109+
areaName: item.areaName
110+
.replace('维吾尔自治区', '')
111+
.replace('壮族自治区', '')
112+
.replace('回族自治区', '')
113+
.replace('自治区', '')
114+
.replace('', '')
115+
}
116+
})
117+
builderLeftMap()
118+
builderRightMap()
119+
loading.value = false
120+
}
121+
defineExpose({ loadData })
122+
123+
const builderLeftMap = () => {
124+
let min = 0
125+
let max = 0
126+
echartsOption.series![0].data = areaStatisticsList.value.map((item) => {
127+
min = Math.min(min, item.customerCount || 0)
128+
max = Math.max(max, item.customerCount || 0)
129+
return { ...item, name: item.areaName, value: item.customerCount || 0 }
130+
})
131+
echartsOption.visualMap!['min'] = min
132+
echartsOption.visualMap!['max'] = max
133+
}
134+
135+
const builderRightMap = () => {
136+
let min = 0
137+
let max = 0
138+
echartsOption2.series![0].data = areaStatisticsList.value.map((item) => {
139+
min = Math.min(min, item.dealCount || 0)
140+
max = Math.max(max, item.dealCount || 0)
141+
return { ...item, name: item.areaName, value: item.dealCount || 0 }
142+
})
143+
echartsOption2.visualMap!['min'] = min
144+
echartsOption2.visualMap!['max'] = max
145+
}
146+
/** 初始化 */
147+
onMounted(() => {
148+
loadData()
149+
})
150+
</script>

0 commit comments

Comments
 (0)