Skip to content

Commit 014d1f8

Browse files
author
puhui999
committed
CRM: 新增商机赢单转化率分析
1 parent 6acfc77 commit 014d1f8

File tree

5 files changed

+304
-7
lines changed

5 files changed

+304
-7
lines changed

src/api/crm/statistics/funnel.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ export interface CrmStatisticsBusinessSummaryByDateRespVO {
1212
totalPrice: number | string // 商机金额
1313
}
1414

15+
export interface CrmStatisticsBusinessInversionRateSummaryByDateRespVO {
16+
time: string // 时间
17+
businessCount: number // 商机数量
18+
businessWinCount: number // 赢单商机数
19+
}
20+
1521
// 客户分析 API
1622
export const StatisticFunnelApi = {
1723
// 1. 获取销售漏斗统计数据
@@ -35,7 +41,14 @@ export const StatisticFunnelApi = {
3541
params
3642
})
3743
},
38-
// 4. 获取商机列表(按日期)
44+
// 4. 获取商机转化率分析(按日期)
45+
getBusinessInversionRateSummaryByDate: (params: any) => {
46+
return request.get({
47+
url: '/crm/statistics-funnel/get-business-inversion-rate-summary-by-date',
48+
params
49+
})
50+
},
51+
// 5. 获取商机列表(按日期)
3952
getBusinessPageByDate: (params: any) => {
4053
return request.get({
4154
url: '/crm/statistics-funnel/get-business-page-by-date',
Lines changed: 278 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,278 @@
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 class="mt-16px" shadow="never">
12+
<el-table v-loading="loading" :data="list">
13+
<el-table-column align="center" fixed="left" label="序号" type="index" width="80" />
14+
<el-table-column align="center" fixed="left" label="商机名称" prop="name" width="160">
15+
<template #default="scope">
16+
<el-link :underline="false" type="primary" @click="openDetail(scope.row.id)">
17+
{{ scope.row.name }}
18+
</el-link>
19+
</template>
20+
</el-table-column>
21+
<el-table-column align="center" fixed="left" label="客户名称" prop="customerName" width="120">
22+
<template #default="scope">
23+
<el-link
24+
:underline="false"
25+
type="primary"
26+
@click="openCustomerDetail(scope.row.customerId)"
27+
>
28+
{{ scope.row.customerName }}
29+
</el-link>
30+
</template>
31+
</el-table-column>
32+
<el-table-column
33+
:formatter="erpPriceTableColumnFormatter"
34+
align="center"
35+
label="商机金额(元)"
36+
prop="totalPrice"
37+
width="140"
38+
/>
39+
<el-table-column
40+
:formatter="dateFormatter"
41+
align="center"
42+
label="预计成交日期"
43+
prop="dealTime"
44+
width="180px"
45+
/>
46+
<el-table-column align="center" label="备注" prop="remark" width="200" />
47+
<el-table-column
48+
:formatter="dateFormatter"
49+
align="center"
50+
label="下次联系时间"
51+
prop="contactNextTime"
52+
width="180px"
53+
/>
54+
<el-table-column align="center" label="负责人" prop="ownerUserName" width="100px" />
55+
<el-table-column align="center" label="所属部门" prop="ownerUserDeptName" width="100px" />
56+
<el-table-column
57+
:formatter="dateFormatter"
58+
align="center"
59+
label="最后跟进时间"
60+
prop="contactLastTime"
61+
width="180px"
62+
/>
63+
<el-table-column
64+
:formatter="dateFormatter"
65+
align="center"
66+
label="更新时间"
67+
prop="updateTime"
68+
width="180px"
69+
/>
70+
<el-table-column
71+
:formatter="dateFormatter"
72+
align="center"
73+
label="创建时间"
74+
prop="createTime"
75+
width="180px"
76+
/>
77+
<el-table-column align="center" label="创建人" prop="creatorName" width="100px" />
78+
<el-table-column
79+
align="center"
80+
fixed="right"
81+
label="商机状态组"
82+
prop="statusTypeName"
83+
width="140"
84+
/>
85+
<el-table-column
86+
align="center"
87+
fixed="right"
88+
label="商机阶段"
89+
prop="statusName"
90+
width="120"
91+
/>
92+
</el-table>
93+
<!-- 分页 -->
94+
<Pagination
95+
v-model:limit="queryParams0.pageSize"
96+
v-model:page="queryParams0.pageNo"
97+
:total="total"
98+
@pagination="getList"
99+
/>
100+
</el-card>
101+
</template>
102+
<script lang="ts" setup>
103+
import {
104+
CrmStatisticsBusinessInversionRateSummaryByDateRespVO,
105+
StatisticFunnelApi
106+
} from '@/api/crm/statistics/funnel'
107+
import { EChartsOption } from 'echarts'
108+
import { erpCalculatePercentage, erpPriceTableColumnFormatter } from '@/utils'
109+
import { dateFormatter } from '@/utils/formatTime'
110+
111+
defineOptions({ name: 'BusinessSummary' })
112+
113+
const props = defineProps<{ queryParams: any }>() // 搜索参数
114+
const queryParams0 = reactive({
115+
pageNo: 1,
116+
pageSize: 10
117+
})
118+
const loading = ref(false) // 加载中
119+
const list = ref([]) // 列表的数据
120+
const total = ref(0)
121+
/** 将传进来的值赋值给 queryParams0 */
122+
watch(
123+
() => props.queryParams,
124+
(data) => {
125+
if (!data) {
126+
return
127+
}
128+
const newObj = { ...queryParams0, ...data }
129+
Object.assign(queryParams0, newObj)
130+
},
131+
{
132+
immediate: true
133+
}
134+
)
135+
/** 柱状图配置:纵向 */
136+
const echartsOption = reactive<EChartsOption>({
137+
grid: {
138+
left: 30,
139+
right: 30, // 让 X 轴右侧显示完整
140+
bottom: 20,
141+
containLabel: true
142+
},
143+
legend: {},
144+
series: [
145+
{
146+
name: '商机总数',
147+
type: 'bar',
148+
yAxisIndex: 0,
149+
data: []
150+
},
151+
{
152+
name: '赢单商机数',
153+
type: 'bar',
154+
yAxisIndex: 1,
155+
data: []
156+
},
157+
{
158+
name: '赢单转化率',
159+
type: 'bar',
160+
yAxisIndex: 2,
161+
data: []
162+
}
163+
],
164+
toolbox: {
165+
feature: {
166+
dataZoom: {
167+
xAxisIndex: false // 数据区域缩放:Y 轴不缩放
168+
},
169+
brush: {
170+
type: ['lineX', 'clear'] // 区域缩放按钮、还原按钮
171+
},
172+
saveAsImage: { show: true, name: '商机转化率分析' } // 保存为图片
173+
}
174+
},
175+
tooltip: {
176+
trigger: 'axis',
177+
axisPointer: {
178+
type: 'shadow'
179+
}
180+
},
181+
yAxis: [
182+
{
183+
type: 'value',
184+
name: '商机总数',
185+
min: 0,
186+
minInterval: 1 // 显示整数刻度
187+
},
188+
{
189+
type: 'value',
190+
name: '赢单商机数',
191+
min: 0,
192+
minInterval: 1 // 显示整数刻度
193+
},
194+
{
195+
type: 'value',
196+
name: '赢单转化率',
197+
min: 0,
198+
minInterval: 1, // 显示整数刻度
199+
splitLine: {
200+
lineStyle: {
201+
type: 'dotted', // 右侧网格线虚化, 减少混乱
202+
opacity: 0.7
203+
}
204+
}
205+
}
206+
],
207+
xAxis: {
208+
type: 'category',
209+
name: '日期',
210+
data: []
211+
}
212+
}) as EChartsOption
213+
214+
/** 获取数据并填充图表 */
215+
const fetchAndFill = async () => {
216+
// 1. 加载统计数据
217+
const businessSummaryByDate = await StatisticFunnelApi.getBusinessInversionRateSummaryByDate(
218+
props.queryParams
219+
)
220+
// 2.1 更新 Echarts 数据
221+
if (echartsOption.xAxis && echartsOption.xAxis['data']) {
222+
echartsOption.xAxis['data'] = businessSummaryByDate.map(
223+
(s: CrmStatisticsBusinessInversionRateSummaryByDateRespVO) => s.time
224+
)
225+
}
226+
if (echartsOption.series && echartsOption.series[0] && echartsOption.series[0]['data']) {
227+
echartsOption.series[0]['data'] = businessSummaryByDate.map(
228+
(s: CrmStatisticsBusinessInversionRateSummaryByDateRespVO) => s.businessCount
229+
)
230+
}
231+
if (echartsOption.series && echartsOption.series[1] && echartsOption.series[1]['data']) {
232+
echartsOption.series[1]['data'] = businessSummaryByDate.map(
233+
(s: CrmStatisticsBusinessInversionRateSummaryByDateRespVO) => s.businessWinCount
234+
)
235+
}
236+
if (echartsOption.series && echartsOption.series[2] && echartsOption.series[2]['data']) {
237+
echartsOption.series[2]['data'] = businessSummaryByDate.map(
238+
(s: CrmStatisticsBusinessInversionRateSummaryByDateRespVO) =>
239+
erpCalculatePercentage(s.businessWinCount, s.businessCount)
240+
)
241+
}
242+
// 2.2 更新列表数据
243+
await getList()
244+
}
245+
/** 获取商机列表 */
246+
const getList = async () => {
247+
const data = await StatisticFunnelApi.getBusinessPageByDate(props.queryParams)
248+
list.value = data.list
249+
total.value = data.total
250+
}
251+
/** 打开客户详情 */
252+
const { push } = useRouter()
253+
const openDetail = (id: number) => {
254+
push({ name: 'CrmBusinessDetail', params: { id } })
255+
}
256+
257+
/** 打开客户详情 */
258+
const openCustomerDetail = (id: number) => {
259+
push({ name: 'CrmCustomerDetail', params: { id } })
260+
}
261+
262+
/** 获取统计数据 */
263+
const loadData = async () => {
264+
loading.value = true
265+
try {
266+
await fetchAndFill()
267+
} finally {
268+
loading.value = false
269+
}
270+
}
271+
272+
defineExpose({ loadData })
273+
274+
/** 初始化 */
275+
onMounted(() => {
276+
loadData()
277+
})
278+
</script>

src/views/crm/statistics/funnel/components/BusinessSummary.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ const echartsOption = reactive<EChartsOption>({
163163
brush: {
164164
type: ['lineX', 'clear'] // 区域缩放按钮、还原按钮
165165
},
166-
saveAsImage: { show: true, name: '客户总量分析' } // 保存为图片
166+
saveAsImage: { show: true, name: '新增商机分析' } // 保存为图片
167167
}
168168
},
169169
tooltip: {

src/views/crm/statistics/funnel/index.vue

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,12 @@
8787
<el-tab-pane label="新增商机分析" lazy name="businessSummaryRef">
8888
<BusinessSummary ref="businessSummaryRef" :query-params="queryParams" />
8989
</el-tab-pane>
90-
<el-tab-pane label="商机转化率分析" lazy name="sourceRef" />
90+
<el-tab-pane label="商机转化率分析" lazy name="businessInversionRateSummaryRef">
91+
<BusinessInversionRateSummary
92+
ref="businessInversionRateSummaryRef"
93+
:query-params="queryParams"
94+
/>
95+
</el-tab-pane>
9196
</el-tabs>
9297
</el-col>
9398
</template>
@@ -100,6 +105,7 @@ import { beginOfDay, defaultShortcuts, endOfDay, formatDate } from '@/utils/form
100105
import { defaultProps, handleTree } from '@/utils/tree'
101106
import FunnelBusiness from './components/FunnelBusiness.vue'
102107
import BusinessSummary from './components/BusinessSummary.vue'
108+
import BusinessInversionRateSummary from './components/BusinessInversionRateSummary.vue'
103109
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
104110
105111
defineOptions({ name: 'CrmStatisticsFunnel' })
@@ -129,7 +135,7 @@ const userListByDeptId = computed(() =>
129135
const activeTab = ref('funnelRef') // 活跃标签
130136
const funnelRef = ref() // 销售漏斗
131137
const businessSummaryRef = ref() // 新增商机分析
132-
const sourceRef = ref() // 客户来源
138+
const businessInversionRateSummaryRef = ref() // 商机转化率分析
133139
134140
/** 搜索按钮操作 */
135141
const handleQuery = () => {
@@ -140,8 +146,8 @@ const handleQuery = () => {
140146
case 'businessSummaryRef':
141147
businessSummaryRef.value?.loadData?.()
142148
break
143-
case 'sourceRef':
144-
sourceRef.value?.loadData?.()
149+
case 'businessInversionRateSummaryRef':
150+
businessInversionRateSummaryRef.value?.loadData?.()
145151
break
146152
}
147153
}

src/views/crm/statistics/portrait/components/PortraitCustomerArea.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ const loadData = async () => {
106106
areaStatisticsList.value = areaList.map((item: CrmStatisticCustomerAreaRespVO) => {
107107
return {
108108
...item,
109-
areaName: item.areaName // TODO @puhui999:这里最好注释下原因哈, 🤣 我从 mall copy 过来的
109+
areaName: item.areaName
110110
// .replace('维吾尔自治区', '')
111111
// .replace('壮族自治区', '')
112112
// .replace('回族自治区', '')

0 commit comments

Comments
 (0)