Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
1b7d6048
authored
Mar 30, 2024
by
YunaiV
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CRM:code review【客户统计】的代码实现
parent
b51397fe
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
28 deletions
+45
-28
src/utils/index.ts
+15
-1
src/views/crm/statistics/customer/components/CustomerFollowUpType.vue
+3
-2
src/views/crm/statistics/customer/components/CustomerSummary.vue
+21
-18
src/views/crm/statistics/customer/index.vue
+6
-7
No files found.
src/utils/index.ts
View file @
1b7d6048
...
@@ -329,10 +329,11 @@ const ERP_PRICE_DIGIT = 2
...
@@ -329,10 +329,11 @@ const ERP_PRICE_DIGIT = 2
* 例如说:库存数量
* 例如说:库存数量
*
*
* @param num 数量
* @param num 数量
* @package digit 保留的小数位数
* @return 格式化后的数量
* @return 格式化后的数量
*/
*/
export
const
erpNumberFormatter
=
(
num
:
number
|
string
|
undefined
,
digit
:
number
)
=>
{
export
const
erpNumberFormatter
=
(
num
:
number
|
string
|
undefined
,
digit
:
number
)
=>
{
if
(
num
==
=
null
)
{
if
(
num
==
null
)
{
return
''
return
''
}
}
if
(
typeof
num
===
'string'
)
{
if
(
typeof
num
===
'string'
)
{
...
@@ -404,3 +405,16 @@ export const erpPriceMultiply = (price: number, count: number) => {
...
@@ -404,3 +405,16 @@ export const erpPriceMultiply = (price: number, count: number) => {
}
}
return
parseFloat
((
price
*
count
).
toFixed
(
ERP_PRICE_DIGIT
))
return
parseFloat
((
price
*
count
).
toFixed
(
ERP_PRICE_DIGIT
))
}
}
/**
* 【ERP】百分比计算,四舍五入保留两位小数
*
* 如果 total 为 0,则返回 0
*
* @param value 当前值
* @param total 总值
*/
export
const
erpCalculatePercentage
=
(
value
:
number
,
total
:
number
)
=>
{
if
(
total
===
0
)
return
0
return
((
value
/
total
)
*
100
).
toFixed
(
2
)
}
src/views/crm/statistics/customer/components/CustomerFollowUpType.vue
View file @
1b7d6048
...
@@ -27,8 +27,9 @@ import {
...
@@ -27,8 +27,9 @@ import {
CrmStatisticsFollowUpSummaryByTypeRespVO
CrmStatisticsFollowUpSummaryByTypeRespVO
}
from
'@/api/crm/statistics/customer'
}
from
'@/api/crm/statistics/customer'
import
{
EChartsOption
}
from
'echarts'
import
{
EChartsOption
}
from
'echarts'
import
{
round
,
sumBy
}
from
'lodash-es'
import
{
sumBy
}
from
'lodash-es'
import
{
DICT_TYPE
,
getDictLabel
}
from
'@/utils/dict'
import
{
DICT_TYPE
,
getDictLabel
}
from
'@/utils/dict'
import
{
erpCalculatePercentage
}
from
'@/utils'
defineOptions
({
name
:
'CustomerFollowupType'
})
defineOptions
({
name
:
'CustomerFollowupType'
})
const
props
=
defineProps
<
{
queryParams
:
any
}
>
()
// 搜索参数
const
props
=
defineProps
<
{
queryParams
:
any
}
>
()
// 搜索参数
...
@@ -95,7 +96,7 @@ const loadData = async () => {
...
@@ -95,7 +96,7 @@ const loadData = async () => {
list
.
value
=
followUpSummaryByType
.
map
((
row
:
CrmStatisticsFollowUpSummaryByTypeRespVO
)
=>
{
list
.
value
=
followUpSummaryByType
.
map
((
row
:
CrmStatisticsFollowUpSummaryByTypeRespVO
)
=>
{
return
{
return
{
...
row
,
...
row
,
portion
:
round
((
row
.
followUpRecordCount
/
totalCount
)
*
100
,
2
)
portion
:
erpCalculatePercentage
(
row
.
followUpRecordCount
,
totalCount
)
}
}
})
})
loading
.
value
=
false
loading
.
value
=
false
...
...
src/views/crm/statistics/customer/components/CustomerSummary.vue
View file @
1b7d6048
...
@@ -10,8 +10,8 @@
...
@@ -10,8 +10,8 @@
<!-- 统计列表 -->
<!-- 统计列表 -->
<el-card
shadow=
"never"
class=
"mt-16px"
>
<el-card
shadow=
"never"
class=
"mt-16px"
>
<el-table
v-loading=
"loading"
:data=
"list"
>
<el-table
v-loading=
"loading"
:data=
"list"
>
<el-table-column
label=
"序号"
align=
"center"
type=
"index"
width=
"80"
/>
<el-table-column
label=
"序号"
align=
"center"
type=
"index"
width=
"80"
fixed=
"left"
/>
<el-table-column
label=
"员工姓名"
prop=
"ownerUserName"
min-width=
"100"
/>
<el-table-column
label=
"员工姓名"
prop=
"ownerUserName"
min-width=
"100"
fixed=
"left"
/>
<el-table-column
<el-table-column
label=
"新增客户数"
label=
"新增客户数"
align=
"right"
align=
"right"
...
@@ -21,28 +21,31 @@
...
@@ -21,28 +21,31 @@
<el-table-column
label=
"成交客户数"
align=
"right"
prop=
"customerDealCount"
min-width=
"200"
/>
<el-table-column
label=
"成交客户数"
align=
"right"
prop=
"customerDealCount"
min-width=
"200"
/>
<el-table-column
label=
"客户成交率(%)"
align=
"right"
min-width=
"200"
>
<el-table-column
label=
"客户成交率(%)"
align=
"right"
min-width=
"200"
>
<template
#
default=
"scope"
>
<template
#
default=
"scope"
>
{{
{{
erpCalculatePercentage
(
scope
.
row
.
customerDealCount
,
scope
.
row
.
customerCreateCount
)
}}
scope
.
row
.
customerCreateCount
!==
0
?
round
((
scope
.
row
.
customerDealCount
/
scope
.
row
.
customerCreateCount
)
*
100
,
2
)
:
0
}}
</
template
>
</
template
>
</el-table-column>
</el-table-column>
<el-table-column
label=
"合同总金额"
align=
"right"
prop=
"contractPrice"
min-width=
"200"
/>
<el-table-column
<el-table-column
label=
"回款金额"
align=
"right"
prop=
"receivablePrice"
min-width=
"200"
/>
label=
"合同总金额"
align=
"right"
prop=
"contractPrice"
min-width=
"200"
:formatter=
"erpPriceTableColumnFormatter"
/>
<el-table-column
label=
"回款金额"
align=
"right"
prop=
"receivablePrice"
min-width=
"200"
:formatter=
"erpPriceTableColumnFormatter"
/>
<el-table-column
label=
"未回款金额"
align=
"right"
min-width=
"200"
>
<el-table-column
label=
"未回款金额"
align=
"right"
min-width=
"200"
>
<!-- TODO @dhb52:参考 util/index.ts 的 // ========== ERP 专属方法 ========== 部分,搞个两个方法,一个格式化百分比,一个计算百分比 -->
<
template
#
default=
"scope"
>
<
template
#
default=
"scope"
>
{{
round
(
scope
.
row
.
contractPrice
-
scope
.
row
.
receivablePrice
,
2
)
}}
{{
erpCalculatePercentage
(
scope
.
row
.
receivablePrice
,
scope
.
row
.
contractPrice
)
}}
</
template
>
</
template
>
</el-table-column>
</el-table-column>
<el-table-column
label=
"回款完成率(%)"
align=
"right"
min-width=
"200"
>
<el-table-column
label=
"回款完成率(%)"
align=
"right"
min-width=
"200"
fixed=
"right"
>
<
template
#
default=
"scope"
>
<
template
#
default=
"scope"
>
{{
{{
erpCalculatePercentage
(
scope
.
row
.
receivablePrice
,
scope
.
row
.
contractPrice
)
}}
scope
.
row
.
contractPrice
!==
0
?
round
((
scope
.
row
.
receivablePrice
/
scope
.
row
.
contractPrice
)
*
100
,
2
)
:
0
}}
</
template
>
</
template
>
</el-table-column>
</el-table-column>
</el-table>
</el-table>
...
@@ -55,7 +58,7 @@ import {
...
@@ -55,7 +58,7 @@ import {
CrmStatisticsCustomerSummaryByUserRespVO
CrmStatisticsCustomerSummaryByUserRespVO
}
from
'@/api/crm/statistics/customer'
}
from
'@/api/crm/statistics/customer'
import
{
EChartsOption
}
from
'echarts'
import
{
EChartsOption
}
from
'echarts'
import
{
round
}
from
'lodash-e
s'
import
{
erpCalculatePercentage
,
erpPriceTableColumnFormatter
}
from
'@/util
s'
defineOptions
({
name
:
'CustomerSummary'
})
defineOptions
({
name
:
'CustomerSummary'
})
const
props
=
defineProps
<
{
queryParams
:
any
}
>
()
// 搜索参数
const
props
=
defineProps
<
{
queryParams
:
any
}
>
()
// 搜索参数
...
...
src/views/crm/statistics/customer/index.vue
View file @
1b7d6048
...
@@ -124,32 +124,31 @@ const userListByDeptId = computed(() =>
...
@@ -124,32 +124,31 @@ const userListByDeptId = computed(() =>
:
[]
:
[]
)
)
//
const
activeTab
=
ref
(
'customerSummary'
)
// 活跃标签
const
activeTab
=
ref
(
'customerSummary'
)
// 活跃标签
const
customerSummaryRef
=
ref
()
// 1. 客户总量分析
const
customerSummaryRef
=
ref
()
// 1. 客户总量分析
const
followUpSummaryRef
=
ref
()
// 2. 客户跟进次数分析
const
followUpSummaryRef
=
ref
()
// 2. 客户跟进次数分析
const
followUpTypeRef
=
ref
()
// 3. 客户跟进方式分析
const
followUpTypeRef
=
ref
()
// 3. 客户跟进方式分析
const
conversionStatRef
=
ref
()
// 4. 客户转化率分析
const
conversionStatRef
=
ref
()
// 4. 客户转化率分析
// 5. TODO 公海客户分析
// 5. TODO 公海客户分析
// 缺 crm_owner_record 表
// 缺 crm_owner_record 表
TODO @dhb52:可以先做界面 + 接口,接口数据直接写死返回,相当于 mock 出来
const
dealCycleRef
=
ref
()
// 6. 成交周期分析
const
dealCycleRef
=
ref
()
// 6. 成交周期分析
/** 搜索按钮操作 */
/** 搜索按钮操作 */
const
handleQuery
=
()
=>
{
const
handleQuery
=
()
=>
{
switch
(
activeTab
.
value
)
{
switch
(
activeTab
.
value
)
{
case
'customerSummary'
:
case
'customerSummary'
:
// 客户总量分析
customerSummaryRef
.
value
?.
loadData
?.()
customerSummaryRef
.
value
?.
loadData
?.()
break
break
case
'followUpSummary'
:
case
'followUpSummary'
:
// 客户跟进次数分析
followUpSummaryRef
.
value
?.
loadData
?.()
followUpSummaryRef
.
value
?.
loadData
?.()
break
break
case
'followUpType'
:
case
'followUpType'
:
// 客户跟进方式分析
followUpTypeRef
.
value
?.
loadData
?.()
followUpTypeRef
.
value
?.
loadData
?.()
break
break
case
'conversionStat'
:
case
'conversionStat'
:
// 客户转化率分析
conversionStatRef
.
value
?.
loadData
?.()
conversionStatRef
.
value
?.
loadData
?.()
break
break
case
'dealCycle'
:
case
'dealCycle'
:
// 成交周期分析
dealCycleRef
.
value
?.
loadData
?.()
dealCycleRef
.
value
?.
loadData
?.()
break
break
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment