!419 feat: 客户成交周期分析(按区域、按产品)

Merge pull request !419 from dhb52/dev
This commit is contained in:
芋道源码 2024-04-14 10:23:40 +00:00 committed by Gitee
commit 6037ac4052
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 355 additions and 7 deletions

View File

@ -67,6 +67,18 @@ export interface CrmStatisticsCustomerDealCycleByUserRespVO {
customerDealCount: number customerDealCount: number
} }
export interface CrmStatisticsCustomerDealCycleByAreaRespVO {
areaName: string
customerDealCycle: number
customerDealCount: number
}
export interface CrmStatisticsCustomerDealCycleByProductRespVO {
productName: string
customerDealCycle: number
customerDealCount: number
}
// 客户分析 API // 客户分析 API
export const StatisticsCustomerApi = { export const StatisticsCustomerApi = {
// 1.1 客户总量分析(按日期) // 1.1 客户总量分析(按日期)
@ -138,5 +150,19 @@ export const StatisticsCustomerApi = {
url: '/crm/statistics-customer/get-customer-deal-cycle-by-user', url: '/crm/statistics-customer/get-customer-deal-cycle-by-user',
params params
}) })
},
// 6.2 获取客户成交周期(按用户)
getCustomerDealCycleByArea: (params: any) => {
return request.get({
url: '/crm/statistics-customer/get-customer-deal-cycle-by-area',
params
})
},
// 6.2 获取客户成交周期(按用户)
getCustomerDealCycleByProduct: (params: any) => {
return request.get({
url: '/crm/statistics-customer/get-customer-deal-cycle-by-product',
params
})
} }
} }

View File

@ -0,0 +1,153 @@
<!-- 成交周期分析 -->
<template>
<!-- Echarts图 -->
<el-card shadow="never">
<el-skeleton :loading="loading" animated>
<Echart :height="500" :options="echartsOption" />
</el-skeleton>
</el-card>
<!-- 统计列表 -->
<el-card shadow="never" class="mt-16px">
<el-table v-loading="loading" :data="list">
<el-table-column label="序号" align="center" type="index" width="80" />
<el-table-column label="区域" align="center" prop="areaName" min-width="200" />
<el-table-column
label="成交周期(天)"
align="center"
prop="customerDealCycle"
min-width="200"
/>
<el-table-column label="成交客户数" align="center" prop="customerDealCount" min-width="200" />
</el-table>
</el-card>
</template>
<script setup lang="ts">
import {
StatisticsCustomerApi,
CrmStatisticsCustomerDealCycleByAreaRespVO
} from '@/api/crm/statistics/customer'
import { EChartsOption } from 'echarts'
defineOptions({ name: 'CustomerDealCycleByArea' })
const props = defineProps<{ queryParams: any }>() //
const loading = ref(false) //
const list = ref<CrmStatisticsCustomerDealCycleByAreaRespVO[]>([]) //
/** 柱状图配置:纵向 */
const echartsOption = reactive<EChartsOption>({
grid: {
left: 20,
right: 40, // X
bottom: 20,
containLabel: true
},
legend: {},
series: [
{
name: '成交周期(天)',
type: 'bar',
data: [],
yAxisIndex: 0
},
{
name: '成交客户数',
type: 'bar',
data: [],
yAxisIndex: 1
}
],
toolbox: {
feature: {
dataZoom: {
xAxisIndex: false // Y
},
brush: {
type: ['lineX', 'clear'] //
},
saveAsImage: { show: true, name: '成交周期分析' } //
}
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
}
},
yAxis: [
{
type: 'value',
name: '成交周期(天)',
min: 0,
minInterval: 1 //
},
{
type: 'value',
name: '成交客户数',
min: 0,
minInterval: 1, //
splitLine: {
lineStyle: {
type: 'dotted', // 线,
opacity: 0.7
}
}
}
],
xAxis: {
type: 'category',
name: '区域',
data: []
}
}) as EChartsOption
/** 获取数据并填充图表 */
const fetchAndFill = async () => {
// 1.
const customerDealCycleByArea = (
await StatisticsCustomerApi.getCustomerDealCycleByArea(props.queryParams)
).map((s: CrmStatisticsCustomerDealCycleByAreaRespVO) => {
return {
areaName: s.areaName,
customerDealCycle: s.customerDealCycle,
customerDealCount: s.customerDealCount
}
})
// 2.1 Echarts
if (echartsOption.xAxis && echartsOption.xAxis['data']) {
echartsOption.xAxis['data'] = customerDealCycleByArea.map(
(s: CrmStatisticsCustomerDealCycleByAreaRespVO) => s.areaName
)
}
if (echartsOption.series && echartsOption.series[0] && echartsOption.series[0]['data']) {
echartsOption.series[0]['data'] = customerDealCycleByArea.map(
(s: CrmStatisticsCustomerDealCycleByAreaRespVO) => s.customerDealCycle
)
}
if (echartsOption.series && echartsOption.series[1] && echartsOption.series[1]['data']) {
echartsOption.series[1]['data'] = customerDealCycleByArea.map(
(s: CrmStatisticsCustomerDealCycleByAreaRespVO) => s.customerDealCount
)
}
// 2.2
list.value = customerDealCycleByArea
}
/** 获取统计数据 */
const loadData = async () => {
loading.value = true
try {
await fetchAndFill()
} finally {
loading.value = false
}
}
defineExpose({ loadData })
/** 初始化 */
onMounted(() => {
loadData()
})
</script>

View File

@ -0,0 +1,153 @@
<!-- 成交周期分析 -->
<template>
<!-- Echarts图 -->
<el-card shadow="never">
<el-skeleton :loading="loading" animated>
<Echart :height="500" :options="echartsOption" />
</el-skeleton>
</el-card>
<!-- 统计列表 -->
<el-card shadow="never" class="mt-16px">
<el-table v-loading="loading" :data="list">
<el-table-column label="序号" align="center" type="index" width="80" />
<el-table-column label="产品名称" align="center" prop="productName" min-width="200" />
<el-table-column
label="成交周期(天)"
align="center"
prop="customerDealCycle"
min-width="200"
/>
<el-table-column label="成交客户数" align="center" prop="customerDealCount" min-width="200" />
</el-table>
</el-card>
</template>
<script setup lang="ts">
import {
StatisticsCustomerApi,
CrmStatisticsCustomerDealCycleByProductRespVO
} from '@/api/crm/statistics/customer'
import { EChartsOption } from 'echarts'
defineOptions({ name: 'CustomerDealCycleByProduct' })
const props = defineProps<{ queryParams: any }>() //
const loading = ref(false) //
const list = ref<CrmStatisticsCustomerDealCycleByProductRespVO[]>([]) //
/** 柱状图配置:纵向 */
const echartsOption = reactive<EChartsOption>({
grid: {
left: 20,
right: 40, // X
bottom: 20,
containLabel: true
},
legend: {},
series: [
{
name: '成交周期(天)',
type: 'bar',
data: [],
yAxisIndex: 0
},
{
name: '成交客户数',
type: 'bar',
data: [],
yAxisIndex: 1
}
],
toolbox: {
feature: {
dataZoom: {
xAxisIndex: false // Y
},
brush: {
type: ['lineX', 'clear'] //
},
saveAsImage: { show: true, name: '成交周期分析' } //
}
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
}
},
yAxis: [
{
type: 'value',
name: '成交周期(天)',
min: 0,
minInterval: 1 //
},
{
type: 'value',
name: '成交客户数',
min: 0,
minInterval: 1, //
splitLine: {
lineStyle: {
type: 'dotted', // 线,
opacity: 0.7
}
}
}
],
xAxis: {
type: 'category',
name: '产品名称',
data: []
}
}) as EChartsOption
/** 获取数据并填充图表 */
const fetchAndFill = async () => {
// 1.
const customerDealCycleByProduct = (
await StatisticsCustomerApi.getCustomerDealCycleByProduct(props.queryParams)
).map((s: CrmStatisticsCustomerDealCycleByProductRespVO) => {
return {
productName: s.productName ?? '未知',
customerDealCycle: s.customerDealCount,
customerDealCount: s.customerDealCount
}
})
// 2.1 Echarts
if (echartsOption.xAxis && echartsOption.xAxis['data']) {
echartsOption.xAxis['data'] = customerDealCycleByProduct.map(
(s: CrmStatisticsCustomerDealCycleByProductRespVO) => s.productName
)
}
if (echartsOption.series && echartsOption.series[0] && echartsOption.series[0]['data']) {
echartsOption.series[0]['data'] = customerDealCycleByProduct.map(
(s: CrmStatisticsCustomerDealCycleByProductRespVO) => s.customerDealCycle
)
}
if (echartsOption.series && echartsOption.series[1] && echartsOption.series[1]['data']) {
echartsOption.series[1]['data'] = customerDealCycleByProduct.map(
(s: CrmStatisticsCustomerDealCycleByProductRespVO) => s.customerDealCount
)
}
// 2.2
list.value = customerDealCycleByProduct
}
/** 获取统计数据 */
const loadData = async () => {
loading.value = true
try {
await fetchAndFill()
} finally {
loading.value = false
}
}
defineExpose({ loadData })
/** 初始化 */
onMounted(() => {
loadData()
})
</script>

View File

@ -30,7 +30,7 @@ import {
} from '@/api/crm/statistics/customer' } from '@/api/crm/statistics/customer'
import { EChartsOption } from 'echarts' import { EChartsOption } from 'echarts'
defineOptions({ name: 'CustomerDealCycle' }) defineOptions({ name: 'CustomerDealCycleByUser' })
const props = defineProps<{ queryParams: any }>() // const props = defineProps<{ queryParams: any }>() //

View File

@ -102,8 +102,14 @@
<CustomerPoolSummary ref="customerPoolSummaryRef" :query-params="queryParams" /> <CustomerPoolSummary ref="customerPoolSummaryRef" :query-params="queryParams" />
</el-tab-pane> </el-tab-pane>
<!-- 成交周期分析 --> <!-- 成交周期分析 -->
<el-tab-pane label="成交周期分析" lazy name="dealCycle"> <el-tab-pane label="员工客户成交周期分析" lazy name="dealCycleByUser">
<CustomerDealCycle ref="dealCycleRef" :query-params="queryParams" /> <CustomerDealCycleByUser ref="dealCycleByUserRef" :query-params="queryParams" />
</el-tab-pane>
<el-tab-pane label="地区客户成交周期分析" lazy name="dealCycleByArea">
<CustomerDealCycleByArea ref="dealCycleByAreaRef" :query-params="queryParams" />
</el-tab-pane>
<el-tab-pane label="产品客户成交周期分析" lazy name="dealCycleByProduct">
<CustomerDealCycleByProduct ref="dealCycleByProductRef" :query-params="queryParams" />
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
</el-col> </el-col>
@ -117,7 +123,9 @@ import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import { beginOfDay, defaultShortcuts, endOfDay, formatDate } from '@/utils/formatTime' import { beginOfDay, defaultShortcuts, endOfDay, formatDate } from '@/utils/formatTime'
import { defaultProps, handleTree } from '@/utils/tree' import { defaultProps, handleTree } from '@/utils/tree'
import CustomerConversionStat from './components/CustomerConversionStat.vue' import CustomerConversionStat from './components/CustomerConversionStat.vue'
import CustomerDealCycle from './components/CustomerDealCycle.vue' import CustomerDealCycleByUser from './components/CustomerDealCycleByUser.vue'
import CustomerDealCycleByArea from './components/CustomerDealCycleByArea.vue'
import CustomerDealCycleByProduct from './components/CustomerDealCycleByProduct.vue'
import CustomerFollowUpSummary from './components/CustomerFollowUpSummary.vue' import CustomerFollowUpSummary from './components/CustomerFollowUpSummary.vue'
import CustomerFollowUpType from './components/CustomerFollowUpType.vue' import CustomerFollowUpType from './components/CustomerFollowUpType.vue'
import CustomerSummary from './components/CustomerSummary.vue' import CustomerSummary from './components/CustomerSummary.vue'
@ -153,7 +161,9 @@ const followUpSummaryRef = ref() // 2. 客户跟进次数分析
const followUpTypeRef = ref() // 3. const followUpTypeRef = ref() // 3.
const conversionStatRef = ref() // 4. const conversionStatRef = ref() // 4.
const customerPoolSummaryRef = ref() // 5. const customerPoolSummaryRef = ref() // 5.
const dealCycleRef = ref() // 6. const dealCycleByUserRef = ref() // 6. ()
const dealCycleByAreaRef = ref() // 7. ()
const dealCycleByProductRef = ref() // 8. ()
/** 搜索按钮操作 */ /** 搜索按钮操作 */
const handleQuery = () => { const handleQuery = () => {
@ -173,8 +183,14 @@ const handleQuery = () => {
case 'poolSummary': // case 'poolSummary': //
customerPoolSummaryRef.value?.loadData?.() customerPoolSummaryRef.value?.loadData?.()
break break
case 'dealCycle': // case 'dealCycleByUser': //
dealCycleRef.value?.loadData?.() dealCycleByUserRef.value?.loadData?.()
break
case 'dealCycleByArea': //
dealCycleByAreaRef.value?.loadData?.()
break
case 'dealCycleByProduct': //
dealCycleByProductRef.value?.loadData?.()
break break
} }
} }